-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
fix: Reset subagent session idle timeout on successful tool calls to prevent premature termination #94124
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Problem
When a subagent (
sessions_spawnwithmode: "run") performs tool calls (e.g.,web_fetch,read,exec) that take time, the LLM is idle during those calls. If no LLM response happens for 120 seconds, the subagent session is terminated with:This kills research/analysis subagents that are mid-data-collection — they may have gathered all the data and be about to output the final report, but the 120s window expires and the session is killed.
Root Cause
The 120s idle timeout is a hardcoded kernel-level protection (
SessionWriteLockTimeoutError/EmbeddedAttemptSessionTakeoverError). The embedded agent runner releases the prompt lock while waiting for tools. If no new LLM turn happens within 120 seconds, another attempt can take over the session and the original one is killed.agents.defaults.subagents.runTimeoutSeconds(default 900s / 15min) only controls total wall-clock time, not idle time between LLM turns — so a subagent can be well within its total budget but still get killed because no LLM output happened for 2 minutes during tool calls.Proposed Fix
Not adding a configurable parameter. Instead, make the session timeout smarter:
Instead of a fixed 120s idle timer, add a tool heartbeat mechanism:
This way:
Implementation Sketch
In the embedded agent runner (
dist/run-embedded-agent-*.jsor similar):No new config fields. No breaking changes. Just a smarter timeout origin.