Skip to content

[Bug] Approval callback failure promises cancellation but detaches, leaving resumed sessions blocked by the active run #854

Closed

Description

@loveRhythm1990

Agent | Codex | Model/tier not exposed

Summary

The interactive CLI reports that a durable run will be cancelled fail-closed after approval callback transport retries are exhausted. However, its internal-failure path only detaches the client: it deliberately does not cancel the server run. The run can keep executing and renewing its canonical writer lease. After restarting with astra --resume <session>, submitting a new message is rejected with session_writer_conflict while that previous run remains active.

This is not a request to weaken the single-writer guard or treat an internal transport failure as user authorization to cancel. The bug is the mismatch between the user-facing cancellation promise and actual lifecycle behavior, plus the lack of effective recovery in the observed resume flow.

Environment and user-visible symptoms

  • MOI QA integration, Astra CLI v0.2.7; server source commit cfa329a9dbe178da73deda2b7c281f794a4f73fd.
  • Code investigation below is pinned to that commit. The colleague's exact installed binary digest has not been independently collected; the version label alone does not prove its source SHA.
  • User was asking Astra to list MOI workspaces and encountered a tool approval.
  • The CLI reported:
[stream_transport] Astra could not settle the approval callback after bounded transport retries.
The affected run will be cancelled fail-closed so it does not remain stuck waiting.
Details: HTTP error: error sending request for url (.../approval/respond)
  • A subsequent screenshot shows astra --resume fbfa5bd9-e2db-472b-9435-9e3d74ff198c, restored conversation cells, and a new workspace-list request failing with:
[invalid_request] Error: another controller owns this canonical session branch

The backend error code is session_writer_conflict (HTTP 409), rather than merely the generic CLI classification.

Read-only QA investigation

Session: fbfa5bd9-e2db-472b-9435-9e3d74ff198c

Previous root run: b6742d65-f5f1-43fa-8058-99c7c25e3814

The following timestamps are 2026-09-21 UTC+8; database/log UTC timestamps were converted by adding eight hours.

Time Evidence
19:35:34 Authority audit records acquire_writer/acquired and reserve_turn/reserved for the previous root run, writer epoch 2.
19:37:15–16 Run events record approval_required and interaction_wait_started, interaction call_00_nzpbndZKakp6qCygHrCT6804.
19:38:09 Durable events record approval_resolved and run_resumed for that interaction. The server had recorded a decision despite the missing HTTP acknowledgement.
19:38:11 Ingress records /approval/respond as 499 after 9.999 seconds, request 58cf9329dfc07a837ae80db4bbff07af.
19:38:21 Another /approval/respond request is 499 after 10.002 seconds, request f6687a0fa0cb82ea52f488ec913b0980.
19:38:27 onward The previous run emits further tool requests and continues processing.
19:39:36, 19:43:37, 19:47:43 Authority audit records successful lease renewals by the same previous root run.
19:40:19 / response 19:40:25 A new admission records writer_conflict; HTTP error request ID e238788ea986a271155e5a769e6909f7.
19:45:32 / response 19:45:38 Another new admission records writer_conflict; HTTP error request ID 7e3b925f84f7ba4d0daa5291c89854c1.
19:50:35–38 The previous run commits, releases the writer, and reaches completed, not cancelled.

Additional findings:

  • Both conflicts have equal expected and observed canonical roots in session_context_authority_events: this incident was an active writer conflict, not a stale-cursor conflict hidden behind the same message.
  • At inspection time session_context_heads.active_writer_json and writer/reservation expiry fields were NULL. This was not a permanent leaked lock; the task continued until normal completion.
  • agent_runs.cancellation_requested_at was NULL for the old run. No DELETE /chat/runs/<old-run> was found in the inspected ingress log window.
  • The old run also spawned a child run; the child waited for an approval and later recorded an approval timeout. Continued server execution was not merely an inert lock record.
  • The server process did not restart in this time window.

Evidence boundary: ingress records do not include approval request bodies, so the two 499 records cannot independently prove identical interaction IDs. Their timing and server events closely match the report. The screenshot's session ID does definitively match the two writer-conflict records and the continuing old run.

Relevant code

Pinned source: cfa329a9dbe178da73deda2b7c281f794a4f73fd.

  1. astra-thin-client/src/client.rs: CONTROL_CALLBACK_TIMEOUT_SECS = 10, CONTROL_CALLBACK_ATTEMPTS = 2; post_approval_with_policy retries qualifying transport failures.
  2. stream_render.rs: mark_edge_callback_failure creates the cancellation promise and cancels the local token. The failure is propagated as callback_delivery_failed / remote_cancel_required.
  3. turn_stream_runner.rs: the interactive internal-failure branch calls report_server_run_detach_after_internal_failure instead of issuing cancellation.
  4. That helper only logs a warning. Its comment explicitly says internal failures must not be rewritten as the public User cancellation command; server execution remains authoritative until an attached-stream capability can express exact-generation Runtime cancellation.
  5. run/lifecycle/mod.rs rejects new admission when another writer holds the canonical branch. The observed guard behaved correctly.

Expected behavior

  • The UI must accurately distinguish client detachment, requested cancellation, and confirmed server termination.
  • When resuming a session with a still-active run, reconcile/reattach to that run or present an explicit supported recovery action; do not leave users believing the failed task was cancelled and then only report an internal controller conflict.
  • Preserve the distinction between User cancellation and Runtime failure handling. If runtime cancellation is needed, use the canonical authority model with exact run/generation binding rather than unconditionally calling the public user-cancel endpoint.
  • Preserve idempotent approval delivery: a timed-out HTTP response does not prove that approval was not committed.

Suggested investigation and regression coverage

  • Reproduce an approval that commits server-side while both acknowledgement attempts exceed the client deadline, then exercise interactive error handling and --resume.
  • Verify the actual durable outcome, not just a local cancellation token or an error string.
  • Cover resume while the previous run is active, after it completes, and after an explicit user cancellation.
  • Ensure no duplicate run/tool execution, misleading cancellation claim, or indefinite wait; preserve the single-writer invariant.
  • Review interactive and headless paths for intentionally different authority semantics and consistent public messages.

Related

Approval transport timeout / slow database investigation: https://github.com/matrixorigin/matrixflow/issues/17793

This issue focuses on lifecycle messaging and recovery after that failure, not on assuming a particular database performance root cause. Investigation was read-only; no run state, credentials, or deployment configuration was changed.

Activity

  1. added a commit that references this issue on Sep 22, 2026
    ede9017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions