Skip to content

docs(unstable-v2): let cancelled cover a child its parent cancels - #2943

Merged
benbrandt merged 1 commit into
mainfrom
docs/v2-child-cancelled-stop-reason
Nov 20, 2026
Merged

benbrandt merged 1 commit into
mainfrom
docs/v2-child-cancelled-stop-reason

Conversation

@benbrandt

Copy link
Copy Markdown
Member

Summary

The stop reason rules reserve cancelled for a stop the user or Client chose, and send every other stop the Agent makes to error, which means "something failed". The Subagents page says the Agent can cancel work it delegated at any time, and gives no stop reason for that case. A parent that stops a child on its own, for example a model that calls a stop tool, is neither a user choice nor a failure.

A child session now also reports cancelled when its parent cancels its work.

Why cancelled

  • The adapters already send it, and cannot tell the cases apart. The Claude Agent adapter maps a stopped or killed task to stopReason: "cancelled" (src/v2/tasks.ts at a4f0f78). The Codex adapter maps an interrupted turn to cancelled (src/subagents/StandardSubagentEventRouter.ts at e49d438). Neither provider reports who asked for the stop. Both were checked on 2026-11-20.
  • The Client cleanup rules are keyed on it. Marking a child's unfinished tool calls as cancelled, and answering its pending permission requests, both wait for the child's idle update with stopReason: "cancelled".
  • error would misreport the child. It carries an error object and reads as a failure, so a Client would show a child that was stopped on purpose as failed.

Changes

  • Prompt lifecycle page, stable and draft: the paragraph on stops the Agent makes for its own reasons names the exception for a child session.
  • Subagents page, stable and draft: the cancellation rule says it includes cancellation by the parent.
  • StopReason::Cancelled description in the v2 schema, with the schema and the schema reference pages regenerated.

No keyword is added. The existing rule "Agents MUST report this stop reason on an idle state_update when cancellation ends active foreground work" now covers this case. The Subagent Sessions RFD already says a child confirms cancellation with cancelled, so it needs no change.

v1

Unchanged.

For implementers

  • An Agent that reports cancelled for a child its parent stopped needs no change. One that reports error for it should switch.
  • The child's own limits and failures keep their reasons. An internal timeout of the child is still error.
  • A Client needs no change.

Checks

  • The tests, cargo fmt, Prettier and the spell check pass.
  • Regenerating the schema a second time gives no diff.

The stop reason rules reserved `cancelled` for a stop the user or Client
chose and sent every other Agent-initiated stop to `error`. The subagents
page says the Agent can cancel delegated work at any time and gave no
stop reason for that case, which is neither a user choice nor a failure.

A child session now also reports `cancelled` when its parent cancels its
work. The Client cleanup rules on the subagents page are already keyed on
a child's `cancelled` idle update.
@benbrandt
benbrandt requested a review from a team as a code owner November 20, 2026 18:50
@benbrandt
benbrandt enabled auto-merge (squash) November 20, 2026 18:51
@benbrandt
benbrandt merged commit e9d9517 into main Nov 20, 2026
15 checks passed
@benbrandt
benbrandt deleted the docs/v2-child-cancelled-stop-reason branch November 20, 2026 18:54
@acp-release-bot acp-release-bot Bot mentioned this pull request Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant