Repository navigation
Description
Agent | Codex
Summary
Cancelling a run does not currently propagate cancellation to an already-running server-side MCP tool call. The cancellation token reaches workspace-authority acquisition, but the actual MCP request continues waiting independently. If it does not settle within the local ownership cleanup budget, Astra quarantines the workspace and rejects subsequent writers.
This issue tracks the Astra cancellation-propagation gap and the execution-settlement contract needed to close it safely. Sending a cancellation notification alone is insufficient.
Related issues and pull requests
- Downstream MOI report: matrixorigin/matrixflow#18270.
- Detailed investigation and evidence boundaries: MOI investigation comment.
- Related MOI settlement-status fix: matrixorigin/matrixflow#18832, already merged. It distinguishes cancellation acceptance from execution settlement; it does not stop an in-flight MCP operation.
- Draft Astra implementation: #1017. This implements the sender-side portion and preserves ownership safety; it is not the complete end-to-end fix.
Reported symptoms and verified evidence
The downstream report describes cancelling an active long-running Bash tool, receiving a cancellation API error, and later observing a failed task with the workspace-quarantine/ownership-cleanup error.
The code findings below were rechecked against Astra main at b95f23418b73600039eac5b52059132dcffbf29a. They establish a current cancellation gap and a mechanism that can exceed the cleanup deadline. They do not establish the direct cause of the historical HTTP 500, identify the exact deployed build, or prove that a remote process remained alive. The complete historical failure sequence has not been reproduced against the current deployment.
Current execution path
execute_local_transportpasses the run token into the server-local executor. On cancellation it continues polling the original execution for a production cleanup budget of 10 seconds. If that budget expires, it retains ownership, marks the workspace unsettled, and rejects later writers. This protection must remain.RuntimeToolExecutor::execute_server_local_toolandexecute_mcp_tooluse the token while acquiring workspace authority, but do not pass it into the subsequent MCP invocation. The dynamic MCP adapter also checks cancellation only at entry.AgentBindingMcpRuntime::call_tool_by_mcp_nameissues a stateless HTTPtools/callwith its own 120-second RPC deadline and no run token. Every exchange also reuses one fixed JSON-RPC request ID; the separate businesscall_idis preserved across interaction rounds.- The ordinary MCP connection similarly waits for
peer.call_toolwithout receiving the run token. Its timeout is a separate transport contract; the Agent Binding 120-second value should not be generalized to all transports.
The resulting sequence is: run cancellation is accepted, the active MCP operation receives no cancellation request from this token, the original call remains pending beyond the ownership cleanup budget, and the workspace is quarantined. This finding applies to the MCP route; it must not be generalized to directly bound executor Bash, which has a different execution/cancellation owner.
Expected behavior
- Cancellation closes admission to new tool dispatch and further provider-interaction rounds.
- The active execution owner receives an authenticated cancellation request correlated to the exact invocation.
- Cancellation acceptance remains distinct from execution settlement. Neither a local cancelled future nor an HTTP acknowledgement proves that remote effects have stopped.
- Workspace authority is released only after the existing owner has sufficient settlement evidence. Unknown outcomes retain quarantine and block subsequent writers.
Proposed implementation
1. Propagate cancellation through the existing sender owners
Draft #1017 carries the run token through the normal MCP connection, stateless Agent Binding HTTP call, and dynamic MCP adapter. It sends notifications/cancelled for the exact protocol request ID. Agent Binding uses a fresh protocol request ID for each exchange while keeping the business call_id stable. The identity-less dynamic adapter must continue rejecting forged invocation identities supplied in tool arguments.
The implementation keeps the original response receiver rather than treating rmcp cancellation as a settlement receipt: rmcp 1.6.0 typed cancellation removes the local response slot and synthesizes ServiceError::Cancelled. That local state is not remote-process evidence. A rejected or hanging notification must not prevent observation of a racing original completion.
2. Complete the receiving/execution owner contract
The receiving gateway must deliver cancellation to the owner of the exact invocation, including across replicas or ownership generations. A process-local cancellation map alone is not sufficient without an established routing/ownership contract.
The execution provider must expose verifiable, owner-scoped settlement evidence: cancellation was requested versus execution has stopped and cleanup has completed. For subprocess execution this includes termination and wait/reap of the owned execution boundary. Repeated cancellation and readback must be idempotent, and stale/foreign invocations must not cancel a newer execution.
This receiving/settlement portion is not implemented by #1017. The downstream MOI gateway and remote-execution integration still require matching work and validation. It is a prerequisite for claiming that the original active-tool cancellation problem is fixed.
3. Preserve the protocol and safety boundaries
The pinned rmcp client uses MCP 2025-11-25 cancellation. A receiver may stop replying to the original request after cancellation. Therefore, retaining the receiver only preserves the opportunity to observe a racing completion; it does not guarantee a reply or prove settlement. A late workspace-mutating result still needs the existing explicit workspace-effect settlement evidence.
A provider-owned settlement/readback contract is needed beyond the one-way notification. Do not remove quarantine, abandon the ownership future, extend timeouts to conceal the gap, or forcibly release an active writer.
Validation and closure criteria
- Pre-cancelled calls do not dispatch; active cancellation reaches the correct request; interaction rounds cannot restart dispatch after cancellation.
- Cover accepted, rejected, hanging, and ignored cancellation notifications. An acknowledgement alone must leave unresolved execution pending.
- Preserve the existing non-cooperative cleanup regression: the original owner is retained and a second writer is rejected after the deadline.
- Test repeated cancellation, completion racing cancellation, invalid/stale identities, remote disconnect, and ownership/replica changes at their actual owners.
- Run a controlled long-running process through the real MOI/Astra/provider chain. Observe process termination/cleanup, verify that the completion marker is not written late, and admit a subsequent writer only after confirmed settlement.
- Investigate the historical API error separately using deployment/version and server-side correlation evidence; the sender gap alone must not be labelled its proven root cause.
Keep the downstream MOI issue open until the end-to-end criteria are satisfied. The sender-only draft must not automatically close this tracking issue while the receiving and settlement requirements remain outstanding.
Activity
[-]fix(runtime): propagate active MCP cancellation without abandoning settlement[/-][+]Bug: run cancellation does not reach active MCP calls or establish execution settlement[/+][-]Bug: run cancellation does not reach active MCP calls or establish execution settlement[/-][+]Bug: run cancellation does not reach active MCP calls and can leave ownership unsettled[/+]fix(runtime): propagate MCP cancellation while retaining execution ow…
fix(runtime): preserve summary continuity and correlate MCP settlement (
perf(compaction): reuse accepted request summaries (#1033)
XuPeng-SH commentedon Oct 20, 2026
Cross-repository status update: Astra sender-side propagation/ownership hardening is merged in #1017 and #1031. The receiving follow-up matrixorigin/matrixflow#18920 is also merged, but explicitly remains an advisory process-local receiver; it does not provide cross-replica delivery, remote process termination/wait/reap, absence of late writes or subsequent-writer admission proof. Keep this issue and matrixflow#18270 open until those end-to-end settlement criteria are met. Cancellation acknowledgement must not release an unsettled writer or remove quarantine.
fix(runtime): bound gateway waits and preserve failure reasons (#1094)
XuPeng-SH commentedon Nov 15, 2026
已合并追踪至 #1302 的第 1 节。跨副本取消、远端进程停止与 owner 结算仍需完成;matrixorigin/matrixflow#18270 继续独立跟踪。
此关闭仅表示将追踪入口合并,不表示原问题已全部修复。原报告、讨论和尚未满足的验收条件继续作为新 issue 的证据与验收来源。