Skip to content

Feature: Interrupt tool execution on priority message #7450

Closed

Description

@kawhite81

Problem

When an agent is executing a chain of tool calls, user messages queue until the chain completes. This means urgent messages (like 'STOP') don't interrupt the agent until it finishes its current work.

Proposed Solution

Add a mechanism to interrupt tool execution when a priority message arrives from the user. Options:

  1. Check for queued messages between tool calls
  2. Allow certain message patterns (e.g., 'STOP') to abort the current run
  3. Expose a 'check for messages' tool the agent can call

Use Case

User sends 'STOP' while agent is running 5+ tool calls. Agent should see the message immediately, not after completing all 5 calls.

Context

Requested by user who needs real-time interrupt capability for agent oversight.

Activity

  1. added
    enhancement
    on Feb 3, 2026
  2. Alannjaf commented on Feb 10, 2026

    @Alannjaf

    +1 on this. Running an agent on Telegram — when I send a message while the agent is mid-turn (doing tool calls, polling Claude Code, etc.), it queues up and I can't interrupt or redirect. Would love a priority message flag or /stop that actually cancels the current turn immediately.

  3. steipete commented on Apr 24, 2026

    @steipete
    Contributor

    Closing this as implemented after Codex review.

    Current main already implements priority-run interruption through explicit stop handling, interrupt queue mode, and the interrupt-and-steer session API, so the issue request is satisfied.

    What I checked:

    • Inbound interrupt queue mode aborts the active embedded run: get-reply-run checks for messages.queue.mode === "interrupt"; when the session lane is busy it clears queued lane work and calls abortEmbeddedPiRun(...) before continuing. (src/auto-reply/reply/get-reply-run.ts:597, a2221d6b4709)
    • Queue docs describe interrupt semantics: The queue concept doc now says interrupt aborts the active run for that session and runs the newest message; steer injects into the active run at the next model boundary. (docs/concepts/queue.md:29, a2221d6b4709)
    • Gateway sessions.steer explicitly interrupts active runs: interruptSessionRunIfActive aborts tracked chat runs, aborts embedded runs, clears queues, and waits for shutdown; sessions.steer invokes that path with interruptIfActive: true. (src/gateway/server-methods/sessions.ts:368, a2221d6b4709)
    • STOP-style messages are handled as out-of-band aborts: Gateway stop detection delegates to abort-text matching; tests cover /STOP!!!, stop please, halt, and multilingual stop phrases, and chat.send short-circuits to the abort path when such text arrives. (src/gateway/chat-abort.ts:13, a2221d6b4709)
    • Docs and changelog record shipped interrupt behavior: The public docs say /stop aborts the current run and sessions.steer is the interrupt-and-steer variant; the changelog records both /stop aborting between tool calls and Telegram keeping true abort requests on the control lane. (CHANGELOG.md:4702, a2221d6b4709)

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review notes: reviewed against a2221d6b4709; fix evidence: commit 9a14e1695dbd.

  4. locked as resolved and limited conversation to collaborators on Apr 27, 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