Skip to main content

ADR 0010: A2A inbound adapter

Status​

Accepted (2026-10-29).

Context​

Agents of the fleet delegate goals to the agent that owns the data. The Agent2Agent (A2A) protocol is the fleet's channel for that delegation: one agent sends a goal-shaped request to another and gets an answer back. delivery-promise already has two driving adapters over its use cases, REST (checkout and the operator, ADR 0006) and a read-only MCP server (an agent's tools, ADR 0007). A third adapter makes this context reachable by other agents as an agent.

The three transports do not overlap. Kafka and CloudEvents carry facts (ADR 0004); MCP carries an agent's tools; A2A carries the delegation of a goal, never data sync. An A2A skill that changed state would do it through the same use case and the same transactional outbox as REST (ADR 0005), and the fact would still leave as a CloudEvent.

Decision​

  • A third driving adapter, a separate binary. internal/adapters/inbound/a2a is built on the A2A Go SDK (github.com/a2aproject/a2a-go/v2 v2.7.0) and served as JSON-RPC 2.0 over HTTP by cmd/a2a, mounted at / and /a2a, with the Agent Card at /.well-known/agent-card.json and an open /healthz. It is a third deployable beside cmd/api and cmd/mcp; cmd/a2a is composed like cmd/mcp (same migrations on boot, same Postgres repositories, same usecases.Service, same observability middleware order of ADR 0009). The Helm chart gets an a2a Deployment and Service (default OFF) and an optional Kong HTTPRoute rewriting /api/a2a/delivery-promise to /.

  • Read-only, because MCP is. The write gate of the A2A rollout lets a skill change state only if the context's MCP surface already offers that write. ADR 0007 made MCP read-only on purpose (quote, make, confirm, cancel and publish stay on REST and on the event consumers, driven by checkout and the operator), so this agent is read-only too and does not widen what the context exposes. The adapter's Deps holds one Reads interface with three query methods and nothing that can write. It imports no usecases package, no outbound adapter and no event machinery (TestA2AAdapterIsReadOnly), and nothing may depend on it (TestA2AAdapterDependencyRule). cmd/a2a starts no outbox relay, consumer or sweeper and never dials Kafka: no KAFKA_BROKERS, no consumer group, no EVENT_PUBLISHER. The integration test proves that serving the skills against a real Postgres adds no outbox row.

  • Two curated, goal-shaped skills, derived from the MCP tools (not one per endpoint; both are reads):

    • promise_status -- "is the promise for this order intact?" Exactly one of orderId (every promise of the order, one per shipment group, the list_promises_by_order query) or promiseId (one promise, the get_promise query). Each promise carries its state, terms, witness path, revisions and judgement, the very views.Promise the REST adapter returns.
    • book_capacity -- "how full is this node's pickup capacity on that day?" nodeId and date (YYYY-MM-DD, the node's time zone): the node's promise books with their share, provisional and confirmed holds (the list_promise_books query).

    get_delivery_offer (offers are short-lived scratch state) and get_current_policy (static configuration, already on REST and MCP) are deliberately not skills; adding one is an amendment of this ADR.

  • Message-only, answered in-band. Both skills are request/response reads, so the agent answers every message with one agent Message (a Data part with the envelope {skill, data | problem} and a Text part with a one-line summary) and has no Task lifecycle. The reply keeps the caller's contextId.

  • Strict input. The first message part is {"skill": "<id>", "arguments": {...}}, as a Data part or a Text part holding that JSON. Unknown fields at either level are refused (DisallowUnknownFields) and so is trailing data, so a misspelled argument cannot silently become an empty one.

  • Rejections are problems in the message, never JSON-RPC errors. A malformed request, an unknown skill or a bad argument is a 400 problem; a domain rejection has the same status classification as the REST adapter for the errors a read can raise (internal/adapters/inbound/http/errors.go): not-found is 404, validation-failed is 422 (an id that is not a valid id, a date that is not YYYY-MM-DD); anything else is a 500 internal-error whose cause is logged and never returned (no DSN or SQL reaches the caller). Problem type URIs share the REST namespace (https://retailnetwork.example/problems/<slug>); the adapter adds malformed-request, unknown-skill and invalid-argument for request-shape failures. A 409 or 503 cannot come out of the three queries, so the adapter has no branch for them; if a read ever grows one, the REST catalogue is the source to copy.

  • One OTel span per skill run, a2a.skill <id> with the a2a.skill attribute, like the mcp.tool spans.

  • No auth, no sibling calls. The Agent Card declares no security scheme, by the fleet-wide revert of 2026-09-11 (TestNoAuthMiddlewareReintroduced also scans this adapter); access control is the in-cluster ClusterIP boundary. The agent reads this context's own tables only and calls no other context over REST, MCP or A2A: no code outside tests may import the SDK's client (TestNoOutboundA2AClient).

  • Boot. DATABASE_URL and A2A_AGENT_URL are mandatory and checked before telemetry, the database or the listener open anything. A2A_AGENT_URL is the absolute http(s) URL the Agent Card advertises (in-cluster http://<release>-a2a.<namespace>.svc.cluster.local:8093/; the chart renders it, a2a.agentUrl overrides it); A2A_ADDR (default :8093; :8080 is the api and :8090 the mcp server), MIGRATIONS_DATABASE_URL, LOG_LEVEL, SERVICE_VERSION (also the card version), ENVIRONMENT and the OTEL_* variables complete the contract.

Consequences​

  • Another agent can ask "what became of the promise for order ord-1001, is it at risk, was it kept" and "how full is N-AUS3 on the 22nd" over a single goal-shaped call and get the REST views plus a one-line summary, without a bespoke REST client or an MCP session.
  • The three surfaces cannot drift apart on what they may do: the A2A and MCP adapters share the read-only charter, and the REST adapter stays the only write path. A future write skill needs an MCP write first, an amendment of ADR 0007 and of this ADR, and would go through the use case and outbox like REST.
  • A fourth Deployment per release (default OFF) on the cluster; the chart refuses a2a.extraEnv that brings back a *_MODE, the write side's Kafka/relay env or a variable the chart already renders.
  • CLAUDE.md (the agent guide) must list cmd/a2a, the internal/adapters/inbound/a2a package and the chart's a2a component; that edit is made by a human or a non-subagent session.