Skip to content

[Feature]: Agent turn blocks chat when polling long-running tasks — need turn interruption #9457

Closed

Description

@merc1305

Summary

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:

  1. The current tool call completes normally (no mid-execution kill)
  2. A system signal is injected (e.g., [USER_MESSAGE_PENDING]) between tool calls
  3. The agent is expected to yield — its accumulated responses are flushed to the user
  4. The new user message is then delivered as a fresh turn
  5. 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

  1. added
    enhancement
    on Feb 5, 2026
  2. sebslight commented on Feb 14, 2026

    @sebslight
    Contributor

    Closing as duplicate of #7450. If this is incorrect, please contact us.

  3. locked as resolved and limited conversation to collaborators on Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions