Repository navigation
Description
Agent | Codex | Model/tier not exposed
Summary
Interactive Ctrl+C can return the composer to an apparently idle state while the Server has already admitted the request and continues executing it. If cancellation happens before the CLI captures the SSE run ID, notify_server_to_cancel_run() skips remote cancellation entirely. A subsequent message is rejected with Session execution is busy; the earlier run can remain waiting for local tool approval that the detached client no longer presents.
This is an explicit user-cancellation race, not permission to cancel Server runs on arbitrary transport errors.
Environment and evidence
Observed with a source-built Astra 0.2.12 CLI and matching Server revision 70a5ee3ec25bb3b02d3f591675a13abc33a85159 in QA. The relevant interactive cancellation path remains present in main 9e5f6e08.
Sanitized timeline from the same session (relative to Server admission):
- T+0: the Server durably creates the run for the user's document-analysis request.
- T+1.4s: the local journal records
user_interrupted (Ctrl+C)andparent turn cancelled by user. That cancellation record has no physical Server run ID. - T+23.9s: resubmitting the request receives
session_execution_slot_occupied; the CLI restores the draft and says no model/tool ran for this rejected attempt. - Read-only Server run/projection queries show the earlier run still exists, has executed model/tool work, and is
waitingfortool_approval. Its durable events include anapproval_requiredfor Bash withdelivery=edge_ledger.
The Pod was Ready with zero restarts. This evidence does not establish database slowness as the cause. No live run was cancelled or modified while collecting the evidence.
Reproduction
- Start an interactive turn against a hosted Server using local CLI/Edge tools.
- Delay delivery of the admission/run header after the Server accepts the request.
- Press Ctrl+C before the CLI observes the run ID.
- Allow the admitted Server run to continue, potentially reaching an approval wait.
- Submit another message in the same session.
Actual: the local turn is treated as interrupted, but the Server run is not cancelled and the next message is busy-rejected.
Expected: explicit cancellation must reconcile the in-flight admission and settle cancellation for the exact admitted run, or clearly retain an unresolved state with actionable recovery. The CLI must not imply that remote execution has stopped merely because its response stream closed.
Code evidence
crates/astra-cli/src/cli/turn/turn_stream_runner.rs,await_stream_with_interrupts: both signal and TUI cancellation cancel the local token, call the remote notifier, and drain the stream.notify_server_to_cancel_runsnapshots the incremental run ID only once. If it is absent, it logsno run_id captured yet; server-side cancel skippedand returns. It does not reconcile a subsequently admitted run.crates/astra-cli/src/cli/turn/turn_cancellation.rs,apply_user_cancelled_turn: records a cancelled local turn using a silent UI, even when remote cancellation has not been established.crates/astra-cli/src/cli/turn/turn_failure_reporting.rs: execution-slot conflicts use the generic busy message, without identifying the active approval wait or giving the same recovery guidance as writer conflicts.
Proposed approach and boundaries
- Keep explicit user cancellation separate from callback/parser/network detachment; do not regress fix(cli): report callback detach without promising cancellation #867's no-implicit-user-cancellation contract.
- Reuse the existing admission identity, exact-run cancellation, and bounded settlement owners. Cover cancellation before the first admission event, not just an already-observed run ID.
- Do not cancel an arbitrary run selected by session ID; an unrelated/newer execution must remain untouched.
- If admission/cancellation cannot be confirmed within its bounded budget, retain and visibly report the unresolved execution rather than silently implying success.
- Preserve session/workspace fencing and approval requirements. No automatic approval, direct database cleanup, schema change, or timeout increase as a substitute for fixing ownership.
Acceptance criteria
- Deterministic test: Server admits a run but delays its first response; interactive Ctrl+C still settles that exact run and releases its session slot.
- Cover cancellation before admission, after admission, after a run ID is observed, and after the run has already reached a terminal state.
- A slow/failed cancellation cannot be reported as confirmed success or silently drop the only recovery identity.
- A newer/unrelated run is never cancelled by recovery of the interrupted request.
- Internal transport/callback failures still detach without becoming user cancellation.
- The next turn is admissible after confirmed cancellation; unresolved conflicts provide actionable recovery guidance.
Related: #987 and #916 concern abandoned execution after detachment; #1064 addresses one-shot SIGINT, whereas this report is the interactive pre-run-header cancellation window.
Activity
loveRhythm1990 commentedon Oct 19, 2026
Draft fix: #1079. Not ready for review yet.
The change retains the original response to observe its accepted run identity, then awaits the existing exact-run cancellation within the original bounded budget. It does not look up a cancellation target by Session or execute newly received tools/approvals after cancellation. Unconfirmed cancellation remains visible with explicit recovery guidance.
The two new shared SSE regressions were verified to fail before the fix and pass afterward. The full shared SSE crate, focused CLI cancellation tests, repeat turn-module suite, formatting, and targeted Clippy have passed. Additional stream-render regression setup is being completed; full patched QA validation has not been run. No live run, deployment, database, or release version was changed.
fix(cli): settle interactive cancellation across admission (matrixori…