Skip to content
New in v0.1.3

A2A Protocol Reference

How wireai-rn integrates with Google's Agent-to-Agent (A2A) protocol: architecture, wire format, multi-turn state, and capability advertisement with buildAgentCard().

What is A2A?

Agent-to-Agent (A2A) is Google's open protocol for agent interoperability. It defines a standard transport using JSON-RPC 2.0 over HTTP, plus a task lifecycle model for async agent execution.

A2UI is the “Agent-to-UI” layer on top of A2A. Agents return structured DataPart payloads that tell the client what UI to render. wireai-rn implements A2UI natively: the A2AAdapter extracts DataPart content and passes it through the normal response validation pipeline.

Architecture

📱 Mobile App (wireai-rn)

A2AAdapter.chat(messages)

filters system msgs

Latest message → TextPart

A2A stateful: no full history

Persists contextId

server tracks history

Polls until COMPLETED

tasks/get every 1s (max 30)

extractContent(task)

DataPart → TextPart

validateLLMResponse()

Zod validation

<ComponentRenderer />

renders native UI

🤖 A2A Agent Server

Receives message/send

JSON-RPC 2.0 over HTTP

Creates / resumes context

contextId maps to session

Runs LLM with full history

history managed server-side

Returns A2ATask

status: WORKING → COMPLETED

DataPart: wireai-rn JSON

{"action":"render","component":"..."}

Why A2A is stateful

Standard adapters (Ollama, OpenAI)

Send the full message history on every turn. The LLM reconstructs context from the conversation.

A2A Adapter

Sends only the latest message. The server tracks history server-side via a contextId.

When reset() is called, the adapter is re-created and the contextId is cleared, so the next conversation starts fresh on both client and server.

Full wire format

First turn (no contextId)

Request
1POST https://your-agent.com/a2a
2{
3  "jsonrpc": "2.0",
4  "id": 1,
5  "method": "message/send",
6  "params": {
7    "message": {
8      "role": "user",
9      "parts": [{ "text": "Start my check-in" }]
10    },
11    "metadata": { "model": "mental-coach-agent" }
12  }
13}

Subsequent turns (with contextId)

Request
1{
2  "jsonrpc": "2.0",
3  "id": 2,
4  "method": "message/send",
5  "params": {
6    "message": {
7      "role": "user",
8      "parts": [{ "text": "I selected: Great" }]
9    },
10    "contextId": "ctx-abc123"
11  }
12}

Response with DataPart (recommended)

Response
1{
2  "jsonrpc": "2.0",
3  "id": 2,
4  "result": {
5    "id": "task-xyz",
6    "contextId": "ctx-abc123",
7    "status": { "state": "COMPLETED" },
8    "messages": [
9      {
10        "role": "agent",
11        "parts": [
12          {
13            "data": {
14              "action": "render",
15              "component": "ChipSelectCard",
16              "props": {
17                "title": "What areas do you want to focus on?",
18                "chips": ["Work", "Health", "Sleep", "Stress"],
19                "multiSelect": true
20              },
21              "message": "Glad you're feeling great! Let's set your focus areas."
22            }
23          }
24        ]
25      }
26    ]
27  }
28}

buildAgentCard(): capability advertisement

Use buildAgentCard() to serialize your component registry as an A2A client capability card. Send this to your agent server so it knows which components your mobile client can render, and make smarter component choices.

Ts
1import { buildAgentCard, createComponentRegistry } from "wireai-rn";
2import { defaultComponents } from "wireai-rn/components";
3import { MoodPicker } from "./components/MoodPicker";
4
5const registry = createComponentRegistry([...defaultComponents, MoodPicker]);
6
7const card = buildAgentCard(registry, {
8  name: "Mental Coach App",
9  url: "https://bff.myapp.com/a2a/client",
10  version: "1.0.0",
11  description: "WireAI-RN client (mental wellness app)",
12});
13
14// The card format:
15{
16  name: "Mental Coach App",
17  url: "https://bff.myapp.com/a2a/client",
18  version: "1.0.0",
19  capabilities: { streaming: false, pushNotifications: false },
20  supportedInputModes: ["text"],
21  supportedOutputModes: ["text", "data"],
22  extensions: [{
23    uri: "https://wireai.dev/extensions/components/v1",
24    required: false,
25    params: {
26      components: [
27        {
28          name: "ActionCard",
29          description: "Use after InfoList, StepList...",
30          propsSchema: {
31            type: "object",
32            properties: {
33              title: { type: "string", description: "Card heading" },
34              primaryLabel: { type: "string", description: "Primary button label" }
35            }
36          }
37        },
38        // ... all other components sorted alphabetically
39      ]
40    }
41  }]
42}

Protocol version compatibility

The A2AAdapter supports both the current A2A spec and v0.3 format:

FeatureCurrent specv0.3 compat
Task statesCOMPLETED, FAILED, WORKING...completed, failed, working...
Agent role"agent""assistant"
Part content field"text""content"