Skip to content

feat(protocol): negotiate protocol version 2 with a base-protocol fallback - #2

Merged
twlite merged 2 commits into
mainfrom
feat/protocol-version-negotiation
Oct 17, 2026
Merged

twlite merged 2 commits into
mainfrom
feat/protocol-version-negotiation

Conversation

@twlite

@twlite twlite commented Oct 17, 2026

Copy link
Copy Markdown
Member

Summary

Protocol version 1 is unchanged. Version 2 adds PDF print jobs and printer document capabilities. The two are negotiated during the hello exchange, so agents and servers upgrade independently.

  • Handshake: agent.hello always uses envelope version "1". A current agent offers ["2", "1"]. server.hello lists only the selected version, so a base agent receives the reply it expects.
  • Envelopes: every other message uses the lowest version its content needs. Receipts, reports, and base inventory stay on "1". Decoders reject extended content under a "1" envelope, and a session rejects "2" unless it negotiated version 2.
  • Fallback: an agent whose extended hello is closed before server.hello retries once with the base offer. It remembers a base-only server for 24 hours, then tries the extended offer again. Timeouts never trigger the fallback.
  • Projection: base-only sessions receive inventory without document capability fields.
  • Server: a protocolVersions option (default ["2", "1"], must include "1"). sendJob returns protocol-version-unsupported for PDF jobs in sessions without version 2.

Compatibility coverage

  • Old agent + new server: TypeScript session tests and a Rust scenario test. Receipts and inventory are byte-compatible.
  • New agent + new server: session tests and a Rust scenario test that exchanges document capabilities.
  • New agent + base-only server: a Rust scenario test shows the single fallback and the remembered record. A TypeScript test shows the base-only server closing the extended hello without a reply.
  • Shared fixtures for the extended handshake, plus invalid cases where extended content is labelled "1", are checked by both the TypeScript and Rust suites.

Known limitations

  • The host connection loop wires the planner, but that glue is not unit-tested. The planner and the protocol rules are.
  • A network failure during the extended handshake, before server.hello, is indistinguishable from a refusal. It causes one base-protocol fallback and up to 24 hours of base-only operation for that server.

Verification

  • cargo clippy --workspace --all-targets --all-features -- -D warnings (Rust 1.99.1)
  • cargo test --workspace: 207 tests passing
  • pnpm test: protocol 70, server 29, sdk 6, example 1
  • pnpm lint, pnpm typecheck, pnpm format:check, pnpm protocol:generate and schema check

🤖 Generated with Claude Code

…lback

Protocol version 1 is unchanged. Version 2 adds PDF print jobs and printer
document capabilities, and peers negotiate it independently of each other:

- Handshake frames always use envelope version "1". agent.hello offers
  ["2", "1"] and server.hello lists only the selected version, so a base
  agent receives the reply it expects.
- Other envelopes use the lowest version their content needs. Receipts,
  reports, and base inventory stay on "1". Decoders reject extended content
  under a "1" envelope, and a session rejects "2" unless negotiated.
- An agent whose extended hello is closed before server.hello retries once
  with the base offer and remembers a base-only server for 24 hours. Timeouts
  never trigger the fallback.
- Base-only sessions receive inventory projected without extended fields.
- Servers accept a protocolVersions option; sendJob refuses PDF jobs to
  sessions without version 2 with protocol-version-unsupported.

Compatibility is covered by TypeScript session tests, protocol unit tests,
Rust negotiation scenarios for all three agent/server combinations, and
shared fixtures for extended handshakes and invalid mislabelled content.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
oppa Ready Ready Preview Oct 17, 2026 12:46pm UTC

The generated docs index depends on filesystem ordering. A local regeneration
reordered its imports, which fails the CI check that verifies generated
artifacts. No documentation pages were added, so the index matches main.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@twlite
twlite merged commit 21fa229 into main Oct 17, 2026
11 checks passed
@twlite
twlite deleted the feat/protocol-version-negotiation branch October 17, 2026 12:54

This branch was successfully deployed

1 active deployment
Preview — 42088021 Deployed Oct 17, 2026 by vercel[bot]
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