Skip to content

fix(a2aacp): fail turns of a stopped agent with ErrAgentStopped - #573

Merged
yarolegovich merged 2 commits into
a2aproject:mainfrom
yuminn-k:fix/a2aacp-agent-stopped-error
Nov 17, 2026
Merged

yarolegovich merged 2 commits into
a2aproject:mainfrom
yuminn-k:fix/a2aacp-agent-stopped-error

Conversation

@yuminn-k

@yuminn-k yuminn-k commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #566

When a canceled turn doesn't end within Config.CancelTimeout, the executor stops the agent, and every other turn on that agent failed with acp agent error: acp agent exited, the same error as a crash.

stopAgent now takes the reason and closes the connection with it (new acp.Conn.CloseWithError / acp.Client.CloseWithError; Close keeps failing calls with acp.ErrAgentExited). The turns that end because of the stop fail with:

acp agent error: the agent was stopped because a canceled task didn't stop (task <id>): acp agent exited

The error wraps the new exported ErrAgentStopped and acp.ErrAgentExited, so Config.Failure and Config.Abandoned can tell it from a crash, and the retry in execute (which matches acp.ErrAgentExited) behaves as before. If the agent already exited on its own before the timeout fires, the connection keeps the earlier error, so crashes still report acp agent exited only.

I went with the sentinel plus the task ID in the message rather than a typed error. Happy to switch to a typed error carrying the task ID if you'd rather expose it as a field.

Tests: TestExecutor_CancelTimeoutFailsOtherTurns runs a second task on the same agent, cancels a stuck one, and checks the second task's failure text and that the error passed to Config.Failure matches both ErrAgentStopped and acp.ErrAgentExited. It fails on main (the message is the bare acp agent exited). go test -race ./integrations/... ./internal/acp/..., go vet and golangci-lint run (2.15.0) pass. Not tested against a real ACP agent process.

This change was written with Claude Code (AI-assisted).

🤖 Generated with Claude Code

yuminn-k and others added 2 commits November 10, 2026 02:01
When a canceled turn doesn't end within Config.CancelTimeout, the
executor stops the agent, and the other turns on that agent failed with
a bare "acp agent exited", the same error as a crash. stopAgent now
closes the connection with the reason, so those turns fail with an
error wrapping the exported ErrAgentStopped, the canceled task's ID and
acp.ErrAgentExited. Crashes still fail with acp.ErrAgentExited alone.

Fixes a2aproject#566

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: YuMin Kim <[email protected]>
The failed tasks may belong to other callers, and with no Failure hook the
error text becomes their status message, so the canceled task's ID moves to
a TaskID field instead of the text. Tests cover tasks waiting for input,
which reach Config.Abandoned, and CloseWithError keeping the error of an
exited agent.
@yarolegovich

Copy link
Copy Markdown
Member

merging with a minor change for keeping task id from other callers'

@yarolegovich
yarolegovich added this pull request to the merge queue Nov 17, 2026
Merged via the queue into a2aproject:main with commit 4acb390 Nov 17, 2026
5 checks passed
ickeep pushed a commit to HuashiCloud/a2a-go that referenced this pull request Nov 18, 2026
🤖 I have created a release *beep* *boop*
---


## [2.9.0](a2aproject/a2a-go@v2.8.0...v2.9.0)
(2026-11-17)


### Features

* **plugins:** extend clients and servers with `a2aclient.WithPlugins`
and `a2asrv.WithPlugins`. Client plugins wrap calls; server plugins wrap
calls, the agent executor, the task store and push delivery. The
`a2aplugin` package builds plugins from hooks
([a2aproject#572](a2aproject#572),
[a2aproject#581](a2aproject#581))
([5216340](a2aproject@5216340),
[b25d155](a2aproject@b25d155))
* **a2aclient/oauth:** OAuth 2.0 client support. `oauth.Manager`
discovers authorization servers from agent cards and Protected Resource
Metadata, signs users in (authorization code or device grant), and its
plugin attaches and refreshes tokens
([a2aproject#568](a2aproject#568),
[a2aproject#570](a2aproject#570))
([c42999a](a2aproject@c42999a),
[50dd177](a2aproject@50dd177))
* **a2aclient:** errors received from a server carry the response HTTP
headers or gRPC metadata in `a2a.Error.ServiceParams`
([a2aproject#595](a2aproject#595))
([d6a1d26](a2aproject@d6a1d26))
* **a2asrv:** pass the client's accepted output modes to agents in
`ExecutorContext.AcceptedOutputModes`
([a2aproject#603](a2aproject#603))
([57ee56c](a2aproject@57ee56c))


### Behavior Changes

* **a2asrv:** `SendMessage` and `SendStreamingMessage` return at most
`Config.HistoryLength` messages of task history
([a2aproject#603](a2aproject#603))
([57ee56c](a2aproject@57ee56c))
* **a2asrv:** `NewAgentCardEnforcer` rejects messages with a push config
when the card doesn't support push notifications
([a2aproject#603](a2aproject#603))
([57ee56c](a2aproject@57ee56c))
* **a2asrv:** a message reply gets the execution's contextId when the
agent doesn't set one, and its taskId is cleared
([a2aproject#577](a2aproject#577),
[a2aproject#609](a2aproject#609))
([eee75ec](a2aproject@eee75ec),
[97de334](a2aproject@97de334))
* **a2asrv:** getting a missing push config returns `TaskNotFound`
instead of an internal error, and a REST push config delete returns `{}`
([a2aproject#578](a2aproject#578),
[a2aproject#600](a2aproject#600))
([ff3fcf8](a2aproject@ff3fcf8),
[0d1ac2a](a2aproject@0d1ac2a))
* **a2aclient:** a JSON-RPC HTTP error without a JSON-RPC body is an
`*a2a.Error` (`ErrUnauthenticated` for 401, `ErrUnauthorized` for 403,
`ErrServerError` otherwise) instead of a plain error
([a2aproject#595](a2aproject#595))
([d6a1d26](a2aproject@d6a1d26))
* **a2aclient:** stream responses of an unknown type are skipped instead
of ending the stream with an error
([a2aproject#532](a2aproject#532))
([212512b](a2aproject@212512b))


### Bug Fixes

* **a2a:** accept pointer OAuth flow types when marshalling
([a2aproject#541](a2aproject#541))
([fe407e3](a2aproject@fe407e3))
* **a2aacp:** don't count exited agents in makeRoom
([a2aproject#563](a2aproject#563))
([6b0c5bd](a2aproject@6b0c5bd))
* **a2aacp:** drop empty parts instead of sending a block without
content ([a2aproject#594](a2aproject#594))
([d8323ce](a2aproject@d8323ce))
* **a2aacp:** fail turns of a stopped agent with `AgentStoppedError`
([a2aproject#573](a2aproject#573))
([4acb390](a2aproject@4acb390))
* **a2aacp:** release the context lock before reporting the end of a
turn, so `RejectBusyContext` accepts the next message
([a2aproject#601](a2aproject#601))
([964e814](a2aproject@964e814))
* **a2aacp:** reserve pool capacity during startup
([a2aproject#587](a2aproject#587))
([621d73b](a2aproject@621d73b))
* **a2av0:** keep unset ListTasks history length unset
([a2aproject#527](a2aproject#527))
([9b4435f](a2aproject@9b4435f))
* **pbconv:** leave an unset ListTasks page size unset
([a2aproject#576](a2aproject#576))
([5a3d99d](a2aproject@5a3d99d))
* **sse:** support carriage-return event line endings
([a2aproject#487](a2aproject#487))
([ecaea9c](a2aproject@ecaea9c))
* **taskexec:** don't end remote subscriptions at the caller's message
([a2aproject#575](a2aproject#575))
([d0710f5](a2aproject@d0710f5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Yaroslav Shevchuk <[email protected]>
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.

a2aacp: turns that share an agent stopped after CancelTimeout fail with a bare "acp agent exited"

2 participants