Skip to content

feat(client)!: add v1 subagent sessions and the Opened marker to the client runtime - #184

Open
EugeneTheDev wants to merge 1 commit into
eugenethedev/subagents-stack/08-agentfrom
eugenethedev/subagents-stack/09-client
Open

EugeneTheDev wants to merge 1 commit into
eugenethedev/subagents-stack/08-agentfrom
eugenethedev/subagents-stack/09-client

Conversation

@EugeneTheDev

@EugeneTheDev EugeneTheDev commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Part 9 of 11 of the stacked split of #158 (v1 subagents).

Contents

  • The v1 client's session tracking is rewritten around ClientSessionRegistry. One atomic snapshot holds:
    • every root and subagent holder;
    • each root's opening state;
    • the opening calls that are running.
  • A session's operations get SessionEvent.Opened once its opening call has answered, so replayed updates can be
    told apart from live ones.
  • New public API:
    • BaseClientSession, ClientSubagentSession and SubagentOperations, for the subagents that the agent
      announces, with cancel and close;
    • ClientSession now extends BaseClientSession;
    • three ClientSession members are deprecated.
  • Behavior:
    • permission requests race through PendingPermissions, per root and per subagent;
    • ClientSession.close() acts on its own holder;
    • an agent request for an unknown session fails at once with -32002.
  • Layout: the runtime moves into client.internal, and the clientSession facade keeps its JVM name through
    @file:JvmName. The acp API dump gets the client blocks.
  • AGENTS.md:
    • the internal-packages paragraph;
    • the "Pass dependencies explicitly" rules;
    • the PendingPermissions bullet;
    • "v1 client";
    • the last "File layout" bullet.
  • Tests: registry, holder and ClientSubagentSession unit tests, the final ElicitationSessionMapTest, and the
    STDIO and WebSocket ClientUnknownSessionRequestTest.

Breaking changes

  • Opening a session that is already open or being opened in the same Client fails with IllegalStateException ("Session … is already open or being opened"), now also for the ClientOperationsFactory overloads of loadSession and resumeSession. Close the session before loading it again.
  • The client now delivers SessionEvent.Opened (the notify(SessionEvent) migration is in feat!: add v1 subagents to the agent runtime and deliver session events through ClientSessionOperations.notify #183). A successful opening delivers exactly one Opened, carrying the opening call's answer. An opening that fails before its answer delivers none. After the answer, the call still fails if its caller is cancelled, or notify throws, while it delivers Opened and the updates queued before the session took over; treat a failed opening call as a failed opening (later updates go to GlobalSessionUpdateHandler, and the session can be opened again).
  • An agent request for a session id that no opening has claimed fails at once with -32002 instead of waiting.
  • Deprecated: ClientSession.client, ClientSession.currentMode, ClientSession.configOptions and ClientSession.setConfigOption.

Caveats

  • The wire-level client tests and the cross-transport subagent tests come in 10. This layer has only the unit tests
    of the new state machine.
  • 09 removes the 08 hybrid imports. After this layer, acp/src/commonMain is identical to d41c266.

Stack

  1. chore: add the multi-agent orchestration tooling #176 — chore: add the multi-agent orchestration tooling
  2. build: move buildSrc to build-logic and check that internal packages hold no public API #177 — build: move buildSrc to build-logic and check that internal packages hold no public API
  3. docs(samples): give each sample its own package, run task and README #178 — docs(samples): give each sample its own package, run task and README
  4. refactor: move MaybeUndefined to the model package and runtime internals to internal packages #179 — refactor: move MaybeUndefined to the model package and runtime internals to internal packages
  5. feat(protocol)!: order handler starts by arrival and add response hooks #180 — feat(protocol)!: order handler starts by arrival and add response hooks
  6. feat(model): add the v1 subagent models and promote session/close to stable #181 — feat(model): add the v1 subagent models and promote session/close to stable
  7. fix(client): make v2 close and delete idempotent and add PendingPermissions #182 — fix(client): make v2 close and delete idempotent and add PendingPermissions
  8. feat!: add v1 subagents to the agent runtime and deliver session events through ClientSessionOperations.notify #183 — feat!: add v1 subagents to the agent runtime and deliver session events through ClientSessionOperations.notify
  9. feat(client)!: add v1 subagent sessions and the Opened marker to the client runtime #184 — feat(client)!: add v1 subagent sessions and the Opened marker to the client runtime ← this PR
  10. test(client): cover v1 client openings and subagents over the wire and across transports #185 — test(client): cover v1 client openings and subagents over the wire and across transports
  11. docs(samples): add a subagents sample #186 — docs(samples): add a subagents sample

Next steps

…lient runtime

- Rewrite the v1 client's session tracking around `ClientSessionRegistry`:
  one snapshot holds every root and subagent holder, its opening state and
  the running opening calls.
- A session's operations receive `SessionEvent.Opened` once its opening
  call has answered, so they can tell replayed updates from live ones.
- Add `BaseClientSession`, `ClientSubagentSession` and `SubagentOperations`
  for subagents that the agent announces, with cancel and close.
- Permission requests race through `PendingPermissions`, per root and per
  subagent. `session/close` acts on its own holder, and an agent request for
  an unknown session fails at once with `-32002`.
- Move the session runtime into `client.internal`, deprecate three
  `ClientSession` members, and update the `acp` API dump.
- Tests: registry, holder and `ClientSubagentSession` unit tests, the
  final `ElicitationSessionMapTest`, and the cross-transport
  `ClientUnknownSessionRequestTest`. AGENTS.md: the v1 client rules.
@EugeneTheDev
EugeneTheDev force-pushed the eugenethedev/subagents-stack/09-client branch from 68490ed to 1b631da Compare December 4, 2026 16:29
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