Files
claude-agent-acp/docs
Ben Brandt 253cd84ed8 fix: answer -32602 on v1 for a request that names a subagent's session (#1656)
On v1, a client's request that names a subagent's child session now
fails with `-32602` (Invalid params), as it already does on v2.

## Why

The subagents RFD changed on 2026-11-17: an Agent SHOULD reject a
client's request that is not permitted for a child session with
`-32602`, in both protocol versions. `session/close` and
`session/delete` are included, and do not report success for a child. A
child that the Agent announced is not an unknown session.
`session/cancel` is the one message that can name a child.

The v1 core treated a child's id as an unknown session:

| Request | Before | Now |
| --- | --- | --- |
| `session/prompt`, `session/load`, `session/resume`, `session/fork`,
`session/set_mode`, `session/set_config_option` | `-32002` | `-32602` |
| `session/close`, `session/delete` | success | `-32602` |
| `session/set_title`, `session/status`, `session/options` | handled as
a session without a transcript | `-32602` |

`session/cancel` of a child still stops the child.

## How

- `NativeSubagentRuntime.hasChild` tells whether a session id is a child
that the runtime announced in the RFD form. `cancelChild` now uses the
same lookup. AIR's earlier draft of the RFD keeps its own rules, so the
check is false there.
- `ClaudeAcpAgent.assertNoChildSession` asks the runtime of each session
of the connection.
- `v1AgentApp` wraps each request that names a session in
`ofRootSession`, so all of them get the same check before their handler
runs. The wrapper is not `async`. It returns the handler's promise as it
is, so a setup response keeps its place before the timer of
`afterSetupResponse`.
- `restrictedChild`, the error that the v2 core already threw, moves
from `src/v2/tasks.ts` to `src/acp-subagents.ts`, which both cores
share.

## Not covered

- A child that only a `session/load` replay announced, and whose agent
did not run again on this connection, is still an unknown session
(`-32002`). The check covers the children of a running session. The v2
core has the same limit.
- The adapter's own extension requests (steer, async task stop, goal)
are unchanged.

## Tests

- `acp-agent.test.ts`: each of the eleven requests, sent through the
protocol router with a child's id, fails with `-32602` and names the
child in `data.sessionId`.
- `native-subagents.test.ts`: `hasChild` is true for an announced child,
and false for the root, for an unknown id and in AIR's draft.

`npm run build`, `npm run check` and `npm run test:run` pass (4335
tests). This branch and #1655 merge without conflicts.
2026-11-18 16:47:24 +01:00
..