You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Agent turn blocks chat when polling long-running tasks — need turn interruption #9457
When an agent enters a long chain of tool calls (e.g., process poll in a loop monitoring a background task), the main session is completely blocked. New user messages queue up and are only processed after the entire turn completes. The agent's intermediate text responses accumulate and get delivered as a batch — often out of order. The user experiences minutes of silence followed by a message dump.
Proposed solution
Turn interruption on new user message. When a user sends a message while the agent is mid-turn:
The current tool call completes normally (no mid-execution kill)
A system signal is injected (e.g., [USER_MESSAGE_PENDING]) between tool calls
The agent is expected to yield — its accumulated responses are flushed to the user
The new user message is then delivered as a fresh turn
If the agent doesn't yield within N seconds, the turn is forcibly ended
Additionally (or alternatively): a configurable maxToolCallsPerTurn limit that forces a flush + yield after N tool calls.
Alternatives considered
System prompt instructions ("don't poll in main session, use sub-agents"): soft control only, no enforcement. Agent can still accidentally block the session.
sessions_spawn pattern: offloads long tasks to sub-agents, works well but nothing prevents the main session from blocking anyway.
Short poll timeouts: agent can use 10s polls, but even a few back-to-back polls accumulate responses that get batched.
Additional context
Real-world scenario: agent monitors IMAP email migration (~1500 messages) via process poll with 5-min timeouts in a loop. User sends a voice message — it sits in queue for 5+ minutes. When the loop ends, all responses dump at once in wrong order.
The sessions_spawn workaround is documented but the core issue remains: there's no mechanism to preempt a runaway turn in the main session.
Activity
sebslight commentedon Feb 14, 2026
Closing as duplicate of #7450. If this is incorrect, please contact us.