Skip to content

feat(protocol)!: order handler starts by arrival and add response hooks - #180

Merged
EugeneTheDev merged 1 commit into
masterfrom
eugenethedev/subagents-stack/05-protocol
Dec 4, 2026
Merged

EugeneTheDev merged 1 commit into
masterfrom
eugenethedev/subagents-stack/05-protocol

Conversation

@EugeneTheDev

@EugeneTheDev EugeneTheDev commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

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

Contents

  • Protocol starts incoming notification and request handlers in arrival order on one thread. It runs each until
    its first suspension before the next one starts. ReadLoopOrderingTest covers this.
  • New internal typed Protocol.sendRequest, with a response hook that runs in the read loop for a success
    response.
  • New Protocol.newConnectionScope, for work that outlives a request.
  • RequestOutcome gains onResponseQueued, which runs once the transport has accepted the success response. It
    is no longer a data class and is now @UnstableApi, so copy, componentN, equals and hashCode leave the
    acp API dump.
  • ClientNegotiator: when a negotiation is cancelled, later callers fail with IllegalStateException instead
    of a rethrown CancellationException. SequenceToPaginatedResponseAdapter's CAS lambda is now pure.
  • AGENTS.md: the RequestOutcome bullet and a new "Read-loop ordering and hooks" section.

Breaking changes

  • RequestOutcome is no longer a data class: copy, componentN, equals, hashCode and toString are gone, and its constructor takes the new onResponseQueued parameter (with a default), so compiled callers must be recompiled. It is now @UnstableApi, which asks for an opt-in with a warning.

Caveats

  • Unused for now:
    • newConnectionScope and onResponseQueued are first used in 08;
    • the typed Protocol.sendRequest and its response hook are first used in 09.
  • AGENTS.md ahead of the layer: the read-loop section's examples name later behavior: the client's
    session/update sorting (09), "an opening undoes it, a close completes it" (09), and subagent collections and
    openings (08 and 09).
  • Master runtimes on the final Protocol: master's v1 and v2 runtimes now run on it. check passes.

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 ← this PR
  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
  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

@EugeneTheDev
EugeneTheDev added this pull request to stack #189 December 2, 2026 13:21
@EugeneTheDev EugeneTheDev changed the title feat(protocol): order handler starts by arrival and add response hooks feat(protocol)!: order handler starts by arrival and add response hooks Dec 2, 2026
@EugeneTheDev
EugeneTheDev force-pushed the eugenethedev/subagents-stack/05-protocol branch 3 times, most recently from 34e2121 to b572bfc Compare December 4, 2026 11:30
Base automatically changed from eugenethedev/subagents-stack/04-moves to master December 4, 2026 11:32
@EugeneTheDev
EugeneTheDev force-pushed the eugenethedev/subagents-stack/05-protocol branch from b572bfc to 152924f Compare December 4, 2026 11:32
- `Protocol` starts incoming handlers in arrival order and runs each until
  its first suspension before the next one starts. It adds the typed
  `sendRequest` with a response hook that runs in the read loop, and
  `newConnectionScope` for connection-scoped work.
- `RequestOutcome` gains `onResponseQueued`, which runs once the transport
  has accepted the success response. It is no longer a data class and is
  `@UnstableApi`; the `acp` API dump changes accordingly.
- `ClientNegotiator`: a cancelled negotiation makes later callers fail with
  an `IllegalStateException` instead of a rethrown `CancellationException`.
- `SequenceToPaginatedResponseAdapter`: make its CAS lambda pure.
- Tests: `ReadLoopOrderingTest` with its `ProtocolTestSupport` helper, and
  updates to `BatchProtocolTest`, `StdioTransportFlowTest` and
  `ClientNegotiatorTest`.
- AGENTS.md: the `RequestOutcome` bullet and "Read-loop ordering and hooks".
@EugeneTheDev
EugeneTheDev force-pushed the eugenethedev/subagents-stack/05-protocol branch from 152924f to d6b3b74 Compare December 4, 2026 15:33
EugeneTheDev added a commit that referenced this pull request Dec 4, 2026
EugeneTheDev added a commit that referenced this pull request Dec 4, 2026
@EugeneTheDev
EugeneTheDev merged commit 6aeb006 into master Dec 4, 2026
4 of 5 checks passed
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.

2 participants