-
-
Notifications
You must be signed in to change notification settings - Fork 52.8k
Open
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Summary
When an agent run times out (embedded run timeout, default 600s), background exec processes continue running independently. When those exec processes later complete, their results are injected as System: messages into a new session that has zero context from the previous session. If the user then sends a message (e.g. "continue"), the agent has no idea what was being worked on and may start an entirely unrelated task.
Reproduction Steps
- Start a task that involves long-running background exec commands (e.g.
npm installin a slow environment, CI pipeline polling) - The agent run hits the 600s timeout → run is killed
- Background exec processes keep running (they are independent OS processes)
- Wait for exec to complete (could be minutes to hours later)
- User sends a message in the same topic/chat (e.g. "continue")
- A new session is created for that topic
- The accumulated
System: Exec completed/failedmessages + the user message are bundled into a single first user message in the new session
What Happens
The new session receives something like:
System: [01:51] Exec completed (session-a, code 0) :: apt done configure done
System: [01:57] Exec completed (session-b, code 0) :: 1min
System: [01:59] Exec failed (session-c, signal SIGKILL) :: proot warning...
[User]: continue
The agent has no prior conversation context. It:
- Sees cryptic exec output snippets with no semantic meaning
- Interprets "continue" by searching memory files
- Finds the most prominent recent TODO in memory (which may belong to a different topic/session)
- Starts working on the wrong task in the wrong topic
Root Causes
- Agent run timeout kills the run but not background exec processes — This creates orphaned exec results that arrive later with no consumer context
- Session rotation drops all conversation history — The new session has zero knowledge of what the old session was doing
- Accumulated System messages are batched with user messages — The signal-to-noise ratio is very low; the agent cannot distinguish which exec results are relevant
- No per-topic/per-session state persistence — There is no mechanism to carry forward "this session was working on task X" across session boundaries
Observed Impact
- Agent started working on Project A in a topic that was dedicated to Project B
- Cross-topic contamination: work intended for one topic bled into another
- User had to re-explain context that was already established in the previous session
- Wasted tokens and time on duplicate/wrong work
Suggested Improvements
- Carry forward session summary on rotation — When a session times out and a new one is created for the same topic, inject a compact summary of the previous session's last N messages as context
- Kill or re-parent orphaned exec processes — When an agent run times out, either kill associated exec processes or tag their results with the original session context
- Separate System exec results from user messages — Don't batch them into a single user turn; deliver them as distinct system events that the agent can triage
- Per-topic persistent state — Allow sessions to write a small state blob (e.g. "current task", "last working context") that survives session rotation
Environment
- OpenClaw latest (npm)
- Telegram channel with topic-based group chat
- Agent run timeout: 600000ms (default)
- Multiple background exec processes running concurrently
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity