Skip to content

Commit 6955305

Browse files
authored
docs: add experimental a2a docs (#96)
1 parent 2627af6 commit 6955305

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Agent-to-Agent (A2A) Protocol
2+
3+
Strands Agents provides experimental support for the [Agent-to-Agent (A2A) protocol](https://a2aproject.github.io/A2A/latest/), enabling seamless communication between AI agents across different platforms and implementations.
4+
5+
!!! warning "Experimental Feature"
6+
A2A support in Strands is currently **EXPERIMENTAL**. APIs may change, and additional functionality will be added in future releases. If you encounter bugs or have feature requests, please [report them on GitHub](https://github.com/strands-agents/sdk-python/issues/new/choose).
7+
8+
## What is Agent-to-Agent (A2A)?
9+
10+
The Agent-to-Agent protocol is an open standard that defines how AI agents can discover, communicate, and collaborate with each other.
11+
12+
13+
### Use Cases
14+
15+
A2A protocol support enables several powerful use cases:
16+
17+
- **Multi-Agent Workflows**: Chain multiple specialized agents together
18+
- **Agent Marketplaces**: Discover and use agents from different providers
19+
- **Cross-Platform Integration**: Connect Strands agents with other A2A-compatible systems
20+
- **Distributed AI Systems**: Build scalable, distributed agent architectures
21+
22+
Learn more about the A2A protocol:
23+
24+
- [A2A GitHub Organization](https://github.com/a2aproject/A2A)
25+
- [A2A Python SDK](https://github.com/a2aproject/a2a-python)
26+
- [A2A Documentation](https://a2aproject.github.io/A2A/latest/)
27+
28+
## Installation
29+
30+
To use A2A functionality with Strands, install the package with the A2A extra:
31+
32+
```bash
33+
pip install strands-agents[a2a]
34+
```
35+
36+
This installs the core Strands SDK along with the necessary A2A protocol dependencies.
37+
38+
## Basic Example
39+
40+
Here's a simple example to get started with A2A communication:
41+
42+
### Step 1: Install Dependencies
43+
44+
```bash
45+
pip install strands-agents[a2a]
46+
```
47+
48+
### Step 2: Create and Run the Server
49+
50+
Create `server.py`:
51+
52+
```python
53+
from strands import Agent
54+
from strands.multiagent.a2a import A2AAgent
55+
56+
# Create a basic agent
57+
agent = Agent(name="AI assistant", description="A helpful AI assistant")
58+
59+
# Wrap it with A2A capabilities
60+
a2a_agent = A2AAgent(agent=agent)
61+
62+
# Start the A2A server
63+
print("Starting A2A server on http://localhost:9000")
64+
a2a_agent.serve()
65+
```
66+
67+
Run the server:
68+
69+
```bash
70+
python server.py
71+
```
72+
73+
### Step 3: Create and Run the Client
74+
75+
Create `client.py`:
76+
77+
```python
78+
import asyncio
79+
from uuid import uuid4
80+
81+
import httpx
82+
from a2a.client import A2ACardResolver, A2AClient
83+
from a2a.types import MessageSendParams, SendMessageRequest
84+
85+
86+
async def ask_agent(message: str):
87+
async with httpx.AsyncClient() as httpx_client:
88+
# Connect to the agent
89+
resolver = A2ACardResolver(httpx_client=httpx_client, base_url="http://localhost:9000")
90+
91+
agent_card = await resolver.get_agent_card()
92+
print(agent_card)
93+
client = A2AClient(httpx_client=httpx_client, agent_card=agent_card)
94+
95+
# Send the message
96+
request = SendMessageRequest(
97+
id=str(uuid4()),
98+
params=MessageSendParams(
99+
message={
100+
"role": "user",
101+
"parts": [{"kind": "text", "text": message}],
102+
"messageId": uuid4().hex,
103+
}
104+
),
105+
)
106+
107+
return await client.send_message(request)
108+
109+
110+
# Example usage
111+
async def main():
112+
message = "Tell me about agentic AI"
113+
response = await ask_agent(message)
114+
print(response.model_dump(mode="json", exclude_none=True))
115+
116+
117+
if __name__ == "__main__":
118+
asyncio.run(main())
119+
120+
```
121+
122+
Run the client (make sure your server is running first):
123+
124+
```bash
125+
python client.py
126+
```
127+
128+
## Troubleshooting
129+
130+
If you encounter bugs or need to request features for A2A support:
131+
132+
1. Check the [A2A documentation](https://a2aproject.github.io/A2A/latest/) for protocol-specific issues
133+
2. Report Strands-specific issues on [GitHub](https://github.com/strands-agents/sdk-python/issues/new/choose)
134+
3. Include relevant error messages and code samples in your reports

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ nav:
9393
- Async Iterators: user-guide/concepts/streaming/async-iterators.md
9494
- Callback Handlers: user-guide/concepts/streaming/callback-handlers.md
9595
- Multi-agent:
96+
- Agent2Agent (A2A): user-guide/concepts/multi-agent/agent-to-agent.md
9697
- Agents as Tools: user-guide/concepts/multi-agent/agents-as-tools.md
9798
- Swarm: user-guide/concepts/multi-agent/swarm.md
9899
- Graph: user-guide/concepts/multi-agent/graph.md

0 commit comments

Comments
 (0)