Skip to content

ESC cancel does not stop a queued or still-preparing prompt/command from starting a new LLM run #693

Closed

Description

@agenteinstinct1-max

Pressing ESC (SessionPrompt.cancel / SessionPrompt.cancelForeground) after submitting a prompt or slash command does not reliably cancel it: a fresh provider LLM run can still start after the user cancelled.

Scenarios:

  1. Cancel lands while SessionPrompt.prompt / command is still doing async preparation (revert cleanup, command template / ! shell / @file / MCP resolution, message/part persistence, plugin hooks) before entering the run loop. The loop then samples the post-cancel cancelEpoch and starts a run anyway.
  2. Cancel on an idle session (or during the loop's re-entry gap after Runner.onIdle removed the runner) makes cancelForeground return early without incrementing cancelEpoch, and the loop does not re-check the epoch at the top before ensureRunning.
  3. A queued caller that exits early on an epoch change while cancellation is still settling can read lastAssistant before the interrupted assistant settles (MessageAbortedError / time.completed).

Expected: after ESC, no new provider run starts for the cancelled prompt/command, and queued callers observe the settled interruption.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions