|
| 1 | +--- |
| 2 | +title: Backward Compatibility |
| 3 | +description: Serve v1.0 and v0.3 A2A protocol versions simultaneously — multi-version modules, version routing, and v0.3 client support. |
| 4 | +layout: page |
| 5 | +--- |
| 6 | + |
| 7 | +# Backward Compatibility with v0.3 |
| 8 | + |
| 9 | +Add compat modules alongside v1.0 modules to serve both protocol versions simultaneously. No changes to your `AgentExecutor` are needed. |
| 10 | + |
| 11 | +## Server: Multi-Version Module (recommended) |
| 12 | + |
| 13 | +```xml |
| 14 | +<!-- JSON-RPC with automatic v1.0 + v0.3 routing --> |
| 15 | +<dependency> |
| 16 | + <groupId>org.a2aproject.sdk</groupId> |
| 17 | + <artifactId>a2a-java-sdk-reference-multiversion-jsonrpc</artifactId> |
| 18 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 19 | +</dependency> |
| 20 | + |
| 21 | +<!-- REST with automatic v1.0 + v0.3 routing --> |
| 22 | +<dependency> |
| 23 | + <groupId>org.a2aproject.sdk</groupId> |
| 24 | + <artifactId>a2a-java-sdk-reference-multiversion-rest</artifactId> |
| 25 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 26 | +</dependency> |
| 27 | +``` |
| 28 | + |
| 29 | +## Server: Individual Compat Modules |
| 30 | + |
| 31 | +```xml |
| 32 | +<!-- v0.3 JSON-RPC support --> |
| 33 | +<dependency> |
| 34 | + <groupId>org.a2aproject.sdk</groupId> |
| 35 | + <artifactId>a2a-java-sdk-compat-0.3-reference-jsonrpc</artifactId> |
| 36 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 37 | +</dependency> |
| 38 | + |
| 39 | +<!-- v0.3 REST support --> |
| 40 | +<dependency> |
| 41 | + <groupId>org.a2aproject.sdk</groupId> |
| 42 | + <artifactId>a2a-java-sdk-compat-0.3-reference-rest</artifactId> |
| 43 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 44 | +</dependency> |
| 45 | + |
| 46 | +<!-- v0.3 gRPC support --> |
| 47 | +<dependency> |
| 48 | + <groupId>org.a2aproject.sdk</groupId> |
| 49 | + <artifactId>a2a-java-sdk-compat-0.3-reference-grpc</artifactId> |
| 50 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 51 | +</dependency> |
| 52 | +``` |
| 53 | + |
| 54 | +## How Version Routing Works |
| 55 | + |
| 56 | +- **JSON-RPC and REST**: When serving multiple protocol versions, version routing inspects the `A2A-Version` HTTP header on each request. If the header is `"1.0"`, the request is routed to the v1.0 handler. If it is `"0.3"` or absent, the request is routed to the v0.3 handler. |
| 57 | +- **gRPC**: Version dispatch is implicit — v0.3 clients use the `a2a.v1` protobuf package and v1.0 clients use `lf.a2a.v1`, so requests are routed to the correct service automatically. |
| 58 | +- **Agent card**: When both v1.0 and v0.3 are enabled, the v1.0 `AgentCard` takes precedence and is served at `/.well-known/agent-card.json`. The v0.3 `AgentCard_v0_3` is ignored. If only v0.3 is enabled, the v0.3 agent card is used. If only v1.0 is enabled, the v1.0 agent card is used as-is. |
| 59 | + |
| 60 | +## Making the v1.0 Agent Card Compatible with v0.3 Clients |
| 61 | + |
| 62 | +When serving both protocol versions, you need to ensure the v1.0 agent card contains fields that v0.3 clients expect. Existing v0.3 client implementations (in any language) look for `url`, `preferredTransport`, and `additionalInterfaces` with `transport`/`url` entries — fields that don't exist in the v1.0 format by default. |
| 63 | + |
| 64 | +To make your v1.0 `AgentCard` parsable by v0.3 clients, set these fields on the builder: |
| 65 | + |
| 66 | +```java |
| 67 | +AgentCard card = AgentCard.builder() |
| 68 | + .name("My Agent") |
| 69 | + // ... other v1.0 fields ... |
| 70 | + .supportedInterfaces(List.of( |
| 71 | + new AgentInterface("jsonrpc", "http://localhost:9999"))) |
| 72 | + // v0.3 backward-compatibility fields: |
| 73 | + .url("http://localhost:9999") |
| 74 | + .preferredTransport("jsonrpc") |
| 75 | + .additionalInterfaces(List.of( |
| 76 | + new Legacy_0_3_AgentInterface("jsonrpc", "http://localhost:9999"))) |
| 77 | + .build(); |
| 78 | +``` |
| 79 | + |
| 80 | +The two interface lists serve different clients: |
| 81 | + |
| 82 | +- `supportedInterfaces` — used by **v1.0 clients** to discover endpoints (uses `AgentInterface` with `protocolBinding`/`url`/`tenant` fields) |
| 83 | +- `additionalInterfaces` — used by **v0.3 clients** to discover endpoints (uses `Legacy_0_3_AgentInterface` with v0.3 field names: `transport`/`url`) |
| 84 | +- `url` and `preferredTransport` — top-level fields that v0.3 clients use to discover the primary endpoint |
| 85 | + |
| 86 | +## Push Notification Behavior |
| 87 | + |
| 88 | +Push notification payloads are automatically formatted to match the protocol version used when the push notification configuration was registered. When a v0.3 client registers a push notification configuration (via any transport), the server records the protocol version alongside the configuration. When a notification is later sent to that webhook, the payload is formatted as a v0.3 Task object. Configurations registered by v1.0 clients receive v1.0 `StreamResponse` payloads as usual. This happens transparently — no additional configuration is needed beyond adding the compat reference module. |
| 89 | + |
| 90 | +## Client: Communicating with v0.3 Agents |
| 91 | + |
| 92 | +Use `Client_v0_3` to communicate with agents that only support protocol v0.3: |
| 93 | + |
| 94 | +```xml |
| 95 | +<dependency> |
| 96 | + <groupId>org.a2aproject.sdk</groupId> |
| 97 | + <artifactId>a2a-java-sdk-compat-0.3-client</artifactId> |
| 98 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 99 | +</dependency> |
| 100 | +<dependency> |
| 101 | + <groupId>org.a2aproject.sdk</groupId> |
| 102 | + <artifactId>a2a-java-sdk-compat-0.3-client-transport-jsonrpc</artifactId> |
| 103 | + <version>$\{org.a2aproject.sdk.version}</version> |
| 104 | +</dependency> |
| 105 | +``` |
| 106 | + |
| 107 | +gRPC and REST transports are also available: |
| 108 | +- `a2a-java-sdk-compat-0.3-client-transport-grpc` |
| 109 | +- `a2a-java-sdk-compat-0.3-client-transport-rest` |
| 110 | + |
| 111 | +```java |
| 112 | +AgentCard card = A2ACardResolver.builder().baseUrl("http://localhost:1234") |
| 113 | + .build().getAgentCard(); |
| 114 | + |
| 115 | +AgentInterface v03Interface = card.supportedInterfaces().stream() |
| 116 | + .filter(i -> A2AProtocol_v0_3.PROTOCOL_VERSION.equals(i.protocolVersion())) |
| 117 | + .findFirst().orElseThrow(); |
| 118 | + |
| 119 | +Client_v0_3 client = ClientBuilder_v0_3.forUrl(v03Interface.url()) |
| 120 | + .withTransport(JSONRPCTransport_v0_3.class, new JSONRPCTransportConfigBuilder_v0_3()) |
| 121 | + .build(); |
| 122 | +``` |
| 123 | + |
| 124 | +**Note:** `Client_v0_3` exposes only operations available in protocol v0.3. For example, `listTasks()` is not available (it was added in v1.0). Return types use v0.3 domain objects from the `org.a2aproject.sdk.compat03.spec` package. |
0 commit comments