Documentation Index
Fetch the complete documentation index at: https://docs.emergence.ai/llms.txt
Use this file to discover all available pages before exploring further.
A2A Protocol Primer
Google’s A2A protocol (now under the Linux Foundation) is the communication standard that connects all agents on CRAFT. Understanding A2A is prerequisite knowledge for every agent author, regardless of which framework you choose — it defines the contract your agent must honour at its network boundary.What A2A Is
A2A is an open, vendor-neutral protocol for agent-to-agent communication. Key properties:- Transport: JSON-RPC 2.0 over HTTP, with Server-Sent Events (SSE) for streaming responses
- Discovery: Agent Cards served at a well-known URL describe capabilities
- Framework-agnostic: works with Google ADK, Pydantic AI, LangGraph, or any custom implementation
- Task-centric: every interaction creates a Task with a defined lifecycle
The current production protocol version on CRAFT is 0.2.6 / 0.3. The
a2a Python library (pip install a2a-sdk) provides the canonical types and server utilities (A2AStarletteApplication, DefaultRequestHandler, AgentCard, etc.).Agent Cards — Identity and Discovery
An Agent Card is a JSON document that describes what an agent does, what it can accept, and how to reach it. Every CRAFT agent publishes its card at:Agent Card Structure
Capabilities
| Capability | Effect when true |
|---|---|
streaming | Agent supports message/stream (SSE); callers may use real-time streaming |
pushNotifications | Agent supports webhook push for task completion |
stateTransitionHistory | Agent returns full task state transition history in responses |
message/stream against an agent with streaming: false returns UnsupportedOperationError.
Skills
Skills are discrete capability declarations within an Agent Card. They help orchestrators understand what tasks the agent can handle and inform LLM routing decisions.AgentSkill objects to your AgentCard regardless of framework:
to_a2a(): ADK’s to_a2a() constructs a minimal Agent Card from the agent’s name, description, and instruction — but does not populate AgentSkill definitions. For production CRAFT registrations, author explicit AgentSkill objects even when using ADK, to give orchestrators rich capability descriptions for routing decisions.
Claude Agent SDK — Wrapping as an A2A Agent:
The Claude Anthropic SDK does not natively produce A2A AgentSkill definitions. Wrap a Claude call inside a standard A2A server:
JSON-RPC Methods
The A2A protocol exposes these JSON-RPC methods on your agent’s root endpoint (POST /):
| Method | Use Case | Response |
|---|---|---|
message/send | Fire-and-forget, await a single complete response | JSON-RPC response with Task |
message/stream | Real-time SSE stream of status and artifact events | SSE event stream |
tasks/get | Poll for current task state | Task object |
tasks/cancel | Cancel an in-progress task | Acknowledgment |
tasks/resubscribe | Reconnect to a dropped SSE stream | SSE event stream from current state |
message/stream exclusively — it is the preferred method for all production interactions because it delivers progressive status updates to the user.
Message Structure
Every request to a CRAFT agent is a Message containing one or more Parts:Part Types
| Part Type | kind value | Use Case |
|---|---|---|
TextPart | "text" | Natural language input or agent response |
DataPart | "data" | Structured JSON — datasource context, artifact references, selection context |
FilePart | "file" | Binary content referenced by URI (asset://artifacts/chart.png) |
The
context_id groups messages into a conversation session. CRAFT agents use this to retrieve conversation history from the task store and maintain coherent multi-turn dialogue.Task Lifecycle
Everymessage/send or message/stream call creates or resumes a Task. Tasks follow a strict state machine:
completed, failed, canceled, rejected) are final — a task in a terminal state cannot be restarted. To continue a conversation, the client sends a new message with the same context_id.
SSE Streaming — Event Sequence
When a client callsmessage/stream, the server responds with Content-Type: text/event-stream and pushes events as the agent works. Each data: line is a complete JSON-RPC 2.0 response object.
Event Types
| Result Type | When Used |
|---|---|
Task | First event — the created task (state = submitted) |
TaskStatusUpdateEvent | Lifecycle state changes and intermediate messages |
TaskArtifactUpdateEvent | Completed artifacts (results, charts, files) |
Protocol Rules
- The first event MUST be a
Taskor aMessage - Intermediate events are
TaskStatusUpdateEvent(state=working) andTaskArtifactUpdateEvent - The final event MUST be
TaskStatusUpdateEventwithfinal: trueand a terminal state - The SSE connection closes after the final event
Wire Example — Text2SQL Stream
The following is a real-world event sequence from the CRAFT text2sql agent:Chunked Artifact Streaming
Large artifacts can be delivered in chunks using theappend and lastChunk flags:
Agent-to-Agent Communication Flow
The following sequence diagram shows how an orchestrator delegates a task to a sub-agent using the A2A protocol.Authentication
Agent Cards declare supported authentication schemes insecuritySchemes. CRAFT agents use JWT bearer tokens — the orchestrator injects them when calling sub-agents.
user_id and org_id, and use them to scope all database queries and audit logs. A small UserContextBuilder that reads the Authorization header and exposes a typed context object to your dependencies is the canonical pattern for Pydantic AI + a2a server integrations.
Reconnection
If an SSE connection drops mid-stream, the client can reconnect usingtasks/resubscribe:
A2AStarletteApplication and DefaultRequestHandler manage reconnection automatically.
Next Steps
Your First Agent
Build your first agent using Google ADK, Pydantic AI, or another supported framework.
Multi-Agent Patterns
Orchestration, delegation, and fan-out across multiple A2A agents.

