feat(acp): add v1 session/load and session/resume restore builders - #328
Open
changshenhan wants to merge 1 commit into
Open
feat(acp): add v1 session/load and session/resume restore builders#328changshenhan wants to merge 1 commit into
changshenhan wants to merge 1 commit into
Conversation
Adds ConnectionTo::load_session, ConnectionTo::resume_session, and ConnectionTo::restore_session_from for stable protocol v1 session restore (agentclientprotocol#323). Routing is installed before the request is published, so replay or early notifications for the restored session are captured, and the complete restore response is returned alongside the ActiveSession in a RestoredSession (mirroring the v2 OpenedV2Session shape). On failure or cancellation the routing is dropped, leaving no stale handler behind. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #323
What
Stable-v1 direct clients can now turn
session/loadandsession/resumeinto anActiveSession.ConnectionTo<Agent>gains three entry points:ConnectionTo::load_session(session_id, cwd)— sendssession/loadConnectionTo::resume_session(session_id, cwd)— sendssession/resumeConnectionTo::restore_session_from(request)— forwards an intercepted restore request (e.g. one decoded from a client) unchangedBoth blocking (
block_task().start_session()) and non-blocking (on_session_start(…)) forms are provided, mirroringSessionBuilder.Because v1 restore responses carry no session id, the response type is reduced to
modes()/meta()for theActiveSession, while the complete response stays available in the returnedRestoredSession { session, response }(mirroring the v2OpenedV2Sessionshape). The session id is taken from the request. This works with stable protocol v1 only — no proxy or unstable MCP features required.Two properties the tests pin
Routing is installed before the request is published.
prepare_session_routingregisters theActiveSessionHandlerbeforesend_ordered_request_to/send_request_to, so replay or early notifications for the restored session are captured even when they precede the restore response in dispatch order.load_session_routes_early_notification_and_returns_exact_responsesends the update before the response in the same batch and asserts it is routed.Failed restores drop routing. On an error response the
DynamicHandlerGuardis dropped, so a later update for the failed session id cannot reach a stale handler.failed_restore_returns_err_and_drops_routingerrors the first restore, sends a late update for the failed id, and then succeeds on a second restore over the same connection.restore_session_from_forwards_an_intercepted_requestverifies the interception path forwards the request verbatim, andresume_session_round_trips_exact_responsecovers the blocking path.Verification
session_restoresuite passes under--all-featuresand under default features (4/4 each) — confirming the operation needs no unstable/proxy features.cargo clippy -D warningsandcargo fmtare clean on native.cargo test --all --workspace --all-featurespasses every test binary exceptarrow_proxy_eliza, which fails only on a pre-existing Windows harness issue (see note).Note for Windows contributors
agent-client-protocol-test::test_binaries::require_binaryassertspath.exists()on the extensionless path (target/debug/examples/arrow_proxy). On Windows the built binary isarrow_proxy.exe, soPath::exists()is always false there andjust testcannot complete. Not touched by this change, but a#[cfg(windows)].exesuffix would unblock Windows contributors — happy to send that as a follow-up if useful.CHANGELOG
Addedentry insrc/agent-client-protocol/CHANGELOG.md.