Repository navigation
feat(a2a): negotiate A2A-Version and serve the v1.0 wire dialect beside 0.3 - #18
Open
brainsparker wants to merge 1 commit into
Open
brainsparker wants to merge 1 commit into
brainsparker wants to merge 1 commit into
Conversation
…de 0.3 The JSON-RPC binding now honors the A2A-Version service parameter (spec 3.6): empty means 0.3, 1.0 gets TASK_STATE_* and ROLE_* enums, oneof parts, wrapped SendMessage results and typed error details, anything else gets VersionNotSupportedError (-32009). Ingest accepts v1.0 oneof parts and enums. A2AClient sends the header and can speak 1.0 outbound. Cards advertise both dialects at the same URL. Verified against a stock @a2a-js/sdk 1.3.0 client.
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.
What this does
Stock A2A v1.0 clients can now talk to a youagent server. The JSON-RPC binding negotiates the wire dialect from the
A2A-Versionservice parameter (spec section 3.6) and serves both 0.3 and 1.0 at the same URL.Before this change, a default
@a2a-js/sdk1.3.0 client failed on its very first call:because the server ignored
A2A-Version: 1.0, rejected v1.0 oneof parts ({ "text": "ping" }has nokind), and would have answered in 0.3 shapes (kinddiscriminators, lowercase states,user/agentroles) that a 1.0 client decodes asUNRECOGNIZED.After this change, the same client (no
legacyCompat, no flags) completesSendMessage,GetTask,ListTasks, and gets properly typed errors (JsonRpcTaskNotFoundError,JsonRpcTaskNotCancelableError). I ran that smoke against bothmainand this branch locally; the transcript is in the test notes below.How to use it
Nothing to configure on the server.
youagent startand anyA2AServerembed get it:A2A-VersionheaderA2A-Version: 0.1,0.2.x,0.30.2.1, so those peers keep working)A2A-Version: 1.0(or?A2A-Version=1.0)TASK_STATE_*,ROLE_*, oneof parts,SendMessagewrapped as{ task }/{ message },error.dataas typed details led bygoogle.rpc.ErrorInfoVersionNotSupportedError(-32009) listing the supported versionsResponses echo
A2A-Versionand setVary: A2A-Version. Push-config shapes follow the negotiated version (method-name aliases still work without a header, as before). Webhooks registered under 1.0 receive aStreamResponse({ task }) asapplication/a2a+json; 0.3 webhooks keep the bare Task.On the client side,
A2AClientnow sendsA2A-Version: 0.3on every request (spec 3.6.1 says clients MUST). To call a server that only implements v1.0:Agent cards now advertise two JSON-RPC interfaces at the same URL (
protocolVersion: "1.0"then"0.3"), and the legacy top-levelprotocolVersionis"0.3"instead of"0.2.1", which is the dialect a pre-1.0 reader is actually served.Why this, why today
The gap was already on the README's known-gaps list. The entry read: "the JSON-RPC binding still speaks the pre-1.0 message shape ... Migrating the binding to v1.0 (single Part with a oneof content field, TASK_STATE_* enums, wrapped stream events) is the next step." 0.2.0 shipped yesterday with A2A serving on by default from
youagent start, so the server is now reachable by whatever clients exist, and the clients that exist are 1.0.The ecosystem has moved to 1.0 as the default.
A2A-Versionhandling a MUST for servers and 5.5 fixing enums asTASK_STATE_*/ROLE_*ProtoJSON names: https://a2a-protocol.org/latest/specification/@a2a-js/sdkwent GA on 1.0 on 2026-07-22 with v0.3 support opt-in only (legacyCompat: { enabled: true }): https://github.com/a2aproject/a2a-js/releases@a2a-js/sdk1.2.1 (2026-09-24) made the JSON-RPC server "dispatch on A2A-Version" (#747), so version negotiation is now the reference behavior on both sides: https://github.com/a2aproject/a2a-js/releases/tag/v1.2.1Why this beat the other candidates today. The two runners-up were (1) idempotent
SendMessageonmessageIdplus ordered, retried push delivery (A2A discussion #1857, matched by a2a-java 1.4.0), and (2) declaring the youagent social extension incapabilities.extensions[]withA2A-Extensionsheader handling. Both are real, but neither unblocks anyone: today no 1.0 client can complete a single request against youagent, and every later feature (extensions, idempotency, streaming) would otherwise be built on a dialect those clients cannot read. This also stays clear of the open PRs (#10, #17 streaming; #11 auth; #12 signed cards; #14 REST binding; #15 MCP; #16 validate).Implementation notes
src/a2a/version.ts(exported from the package root):resolveProtocolVersion, outbound projections (toV1Task,toV1Message,toV1Part,toV1Result,toV1Error), inbound helpers (fromV1Part,fromV1SendMessageResult, push-config shape helpers), and the constants. The file header has a dialect comparison table.onMethodget a third argument{ protocolVersion }; existing two-argument handlers need no change.normalizePart,normalizeMessage,normalizeTask) now accepts v1.0 oneof parts andROLE_*/TASK_STATE_*values alongside the 0.3 and pre-0.2 shapes. One intentional behavior change:{ "text": "hi" }with no discriminator used to be rejected and is now a text part. A part with no content field at all is still rejected.A2AClient.listTaskswas returning raw results withoutnormalizeTask; fixed, since 1.0 servers returnTASK_STATE_*there.A2A_ERROR_CODESgains -32007 to -32009 to complete the spec table.0.3instead of0.2.1. The For You registry still stamps0.2.0on its hosted cards; left alone, noted in the README.statusUpdate,artifactUpdate) beyond push payloads, since streaming is not implemented yet; theA2A-Extensionsheader;tenant.Test status
npm test: 180 passed (was 148). New suites:src/a2a/version.test.ts(projections, version parsing, error shaping, push-config shapes) andsrc/a2a/a2a-server.version.test.ts(end-to-end negotiation, 0.3 and 1.0 reads of the same task, -32009 details, query-param form, push payload dialects, client 0.3 default and 1.0 mode including the exact request shape sent).{ text }rejection,0.2.1defaults, single-interface cards).npm run typecheckandnpm run buildclean.@a2a-js/sdk1.3.0,ClientFactoryOptions.default:The smoke script is not committed because it would add
@a2a-js/sdkas a dev dependency; happy to add it underexamples/or as an opt-in test if you want it in CI.