ADR-0026: A2A Protocol Integration (Agent-to-Agent)
**Status:** Proposed **Date:** 2026-09-08 **Deciders:** Platform team, agent runtime maintainers
6 min read
This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.
Original path: docs/adr/0026-a2a-protocol-integration.md
Status: Proposed
Date: 2026-09-08
Deciders: Platform team, agent runtime maintainers
Context
Anvio has MCP for agent-to-tool communication (packages/integrations) and a proprietary ACP server (packages/acp) for editor integration (Cursor, etc.). Neither addresses agent-to-agent interoperability with external ecosystems.
A2A (Agent-to-Agent Protocol) is an open standard (v1.0, Google-led) for cross-framework agent communication. It provides:
- Agent Cards — discovery metadata (capabilities, skills, auth, endpoints)
- Tasks — lifecycle-managed work units with 9 states (submitted → working → completed/failed/canceled/input_required/auth_required/rejected)
- Messages — multi-part (text/file/data) payloads with roles (user/agent)
- Artifacts — structured outputs produced by tasks
- Streaming — SSE for real-time status/artifact updates
- Push notifications — webhook delivery for async task updates
- Three bindings — JSON-RPC 2.0, HTTP+JSON/REST, gRPC
A2A complements MCP: MCP connects agents to tools; A2A connects agents to agents. Adding A2A lets Anvio agents both serve external callers and delegate to external A2A agents.
Forces
- Anvio agents already run multi-turn tool loops — A2A's Task model maps naturally onto
packages/agents' session/run lifecycle. packages/channelshandles 14+ inbound transports — A2A is effectively another inbound channel.packages/toolsis the outbound tool gateway — an A2A client tool fits here as a new tool type.- The existing
packages/acpis narrow (prompt/response, no task lifecycle, no discovery). A2A subsumes it for agent-to-agent use; ACP remains for editor-specific integration. - Anvio's progressive tiers mean A2A must work at Level 1 (filesystem, no DB).
Decision
Create a new packages/a2a package implementing the A2A v1.0 specification with two surfaces:
- A2A Server — exposes Anvio agents as A2A-compliant endpoints
- A2A Client — lets Anvio agents invoke external A2A agents as tools
Package Structure
packages/a2a/
├── src/
│ ├── index.ts
│ ├── types/
│ │ ├── agent-card.ts # AgentCard, AgentSkill, AgentCapabilities
│ │ ├── task.ts # Task, TaskStatus, TaskState
│ │ ├── message.ts # Message, Part, Role
│ │ ├── artifact.ts # Artifact
│ │ ├── push-notification.ts # TaskPushNotificationConfig
│ │ ├── errors.ts # A2A error codes
│ │ └── index.ts
│ ├── server/
│ │ ├── a2a-server.ts # HTTP server (JSON-RPC + REST bindings)
│ │ ├── agent-card-builder.ts # Build AgentCard from AgentDefinition
│ │ ├── task-manager.ts # Task lifecycle, state machine
│ │ ├── sse-stream.ts # SSE streaming for subscribeToTask
│ │ └── push-notifier.ts # Webhook delivery
│ ├── client/
│ │ ├── a2a-client.ts # HTTP client for external A2A agents
│ │ ├── agent-discovery.ts # Fetch + cache AgentCards
│ │ └── a2a-tool.ts # Tool wrapper for packages/tools registry
│ └── mapping/
│ ├── session-to-task.ts # Map Anvio Session ↔ A2A Task
│ └── message-adapter.ts # Map UserInput/AgentStreamEvent ↔ A2A Message/PartDependency Graph
packages/a2a → packages/core (types, ports)
packages/agents (session orchestration, for server)
packages/tools (tool registry, for client tool)
apps/gateway → packages/a2a (mount A2A server alongside existing HTTP)No dependency on packages/db — tasks stored in-memory or filesystem at Level 1, PostgreSQL at Level 3+.
Options Considered
Option A: New packages/a2a (chosen)
| Dimension | Assessment |
|---|---|
| Complexity | Medium — new package, but maps cleanly onto existing session/tool abstractions |
| Scope | Full A2A v1.0 — JSON-RPC + REST bindings, streaming, push notifications |
| Reuse | Server reuses packages/agents orchestration; client reuses packages/tools registry |
| Tier compat | Level 1 compatible (in-memory task store, filesystem fallback) |
Pros:
- Clean separation from ACP (editor integration stays untouched)
- Full spec compliance enables ecosystem interop (Google ADK, LangGraph, CrewAI, etc.)
- Agent Card auto-generated from existing
AgentDefinitionfrontmatter + skills - Task lifecycle maps 1:1 onto Anvio session states
Cons:
- New package to maintain
- A2A spec is young (v1.0) — may evolve
Option B: Extend packages/acp to support A2A
| Dimension | Assessment |
|---|---|
| Complexity | High — ACP's simple prompt/response model diverges significantly from A2A's Task lifecycle |
| Scope | Would require rewriting ACP internals |
| Reuse | Breaks existing editor integration contracts |
| Tier compat | Same |
Pros:
- One fewer package
- Reuses existing HTTP server code
Cons:
- ACP and A2A serve different purposes (editor vs. agent interop)
- Coupling risks breaking Cursor/editor integration
- ACP's simple types don't accommodate A2A's rich model
Option C: A2A as a Channel adapter in packages/channels
| Dimension | Assessment |
|---|---|
| Complexity | Low for inbound, but client side doesn't fit the channel model |
| Scope | Server only — no client/tool surface |
| Reuse | Channel adapter pattern handles inbound well |
| Tier compat | Same |
Pros:
- Fast for server side — channel adapters are well-understood
- Reuses channel hub routing
Cons:
- A2A client (outbound agent delegation) doesn't fit channels
- Agent Card serving needs its own endpoint, not channel-shaped
- Task lifecycle management exceeds channel adapter scope
Trade-off Analysis
Option A wins because A2A is both inbound (server) and outbound (client). Channels only solve inbound. ACP serves a different purpose. A dedicated package keeps boundaries clean and allows full spec compliance without contaminating existing abstractions.
The key design decisions within Option A:
-
Task ↔ Session mapping: A2A
Task.idmaps to AnvioSession.id. A2AcontextIdmaps to Anvio thread/conversation scope. Task state machine wraps session status. -
Agent Card generation: Auto-build from
AgentDefinitionfrontmatter —persona→description,skillsarray →AgentSkill[], model capabilities →AgentCapabilities. -
Client as tool: Register external A2A agents as tools via
anvio.yaml:a2a: remotes: - url: https://partner.example.com/.well-known/agent.json alias: partner-researcherEach remote becomes an
a2a_delegatetool available to agents. -
Streaming: A2A SSE maps directly onto Anvio's
AgentStreamEventpattern. Server translatesAgentStreamEvent→TaskStatusUpdateEvent/TaskArtifactUpdateEvent. -
Auth: Support
apiKeyandbearerschemes initially. OAuth2 flows deferred to Level 3+ (requires persistent token storage).
Consequences
What becomes easier
- Anvio agents discoverable and invocable by any A2A-compliant system
- Multi-agent orchestration across frameworks (Google ADK agents calling Anvio agents and vice versa)
- Agent marketplace/registry participation via standard Agent Cards
What becomes harder
- Two agent-communication protocols to maintain (ACP for editors, A2A for agents)
- Task state synchronization between A2A task model and Anvio session model adds mapping complexity
What we'll need to revisit
- ACP deprecation path — once A2A matures, evaluate whether ACP can be retired or adapted
- gRPC binding — defer to post-MVP; JSON-RPC + REST cover most clients
- Multi-tenant task isolation at Level 3+
- Agent Card signing (RS256/ES256) — requires key management, defer to post-MVP
Action Items
- Create
packages/a2awith types from A2A v1.0 spec (Zod schemas inpackages/core) - Implement A2A Server with JSON-RPC + REST bindings, task lifecycle, SSE streaming
- Build Agent Card auto-generator from
AgentDefinition - Implement A2A Client +
a2a_delegatetool type inpackages/tools - Mount A2A server in
apps/gatewayon configurable path (default:/a2a) - Add
a2asection toanvio.yamlworkspace schema - Serve
/.well-known/agent.jsonfor Agent Card discovery - Write integration tests against a mock A2A peer
- Document in
docs/— architecture, configuration, usage examples
Reconciliation note (2026-10-25)
Still Proposed. The decision is implemented: packages/a2a (server, Agent Card, client, a2a_delegate tool), and ADR-0027..0031 build on it as Accepted. Acceptance is left to the owners. Known gaps from audit phase 3, re-checked 2026-10-25: the client does not send the configured apiKey/bearerToken; cancelTask marks the task canceled without stopping the run; server auth is off by default. See docs/ROADMAP.md. Original decision text above is unchanged.
Last updated on
ADR-0025: Mutation surface (`/new`, `/edit`, `/rm`), session forking, batch/worktree/connections/setup-token
- **Status:** Accepted — v2.3.0 tracks 1 + 2 shipped: session forking (`/branch`, `/resume`, `/history --branch`), the `_trash/` foundation (`anvio trash list|rm|restore|prune`), the uniform mutation
ADR-0027: A2A End-to-End Integration Testing
**Status:** Accepted **Date:** 2026-09-12 **Deciders:** Platform team, QA **Supersedes:** — **Related:** ADR-0026 (A2A Protocol Integration)