Summary
When ACP session/cancel interrupts an in-flight prompt, the prompt result should represent a user cancellation, not an agent failure. In the agent_error event path added for failed LLM turns, MessageAbortedError should be filtered out.
Reproducer
- Start an ACP
session/prompt that streams for long enough to cancel.
- Send ACP
session/cancel while the turn is still active.
- Observe the emitted
session/update frames and final prompt result.
Expected
The final prompt result is:
{ "stopReason": "cancelled", "_meta": {} }
No agent_error session/update is emitted for the same user-cancel action.
Actual
Before the final cancelled result, the stream can emit:
{
"sessionUpdate": "agent_error",
"error": { "type": "unknown", "message": "Aborted", "retryable": true },
"stopReason": "error"
}
followed by:
{ "stopReason": "cancelled", "_meta": {} }
Why this matters
ACP clients receive both an error and a cancellation for one user action. Since MessageAbortedError is the normal result of session/cancel, surfacing it as agent_error makes an intentional stop look like an agent/LLM failure.
Proposed fix
In the ACP event handler, ignore session.error events whose error name is MessageAbortedError. The prompt RPC result remains responsible for reporting stopReason: "cancelled".
Related: #25899, #26352
Summary
When ACP
session/cancelinterrupts an in-flight prompt, the prompt result should represent a user cancellation, not an agent failure. In theagent_errorevent path added for failed LLM turns,MessageAbortedErrorshould be filtered out.Reproducer
session/promptthat streams for long enough to cancel.session/cancelwhile the turn is still active.session/updateframes and final prompt result.Expected
The final prompt result is:
{ "stopReason": "cancelled", "_meta": {} }No
agent_errorsession/updateis emitted for the same user-cancel action.Actual
Before the final cancelled result, the stream can emit:
{ "sessionUpdate": "agent_error", "error": { "type": "unknown", "message": "Aborted", "retryable": true }, "stopReason": "error" }followed by:
{ "stopReason": "cancelled", "_meta": {} }Why this matters
ACP clients receive both an error and a cancellation for one user action. Since
MessageAbortedErroris the normal result ofsession/cancel, surfacing it asagent_errormakes an intentional stop look like an agent/LLM failure.Proposed fix
In the ACP event handler, ignore
session.errorevents whose error name isMessageAbortedError. The prompt RPC result remains responsible for reportingstopReason: "cancelled".Related: #25899, #26352