Skip to content

Commit 5da1769

Browse files
authored
docs: update A2A hosting example for SDK v1 (#9521)
1 parent 8be57da commit 5da1769

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎python/packages/a2a/README.md‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,18 @@ in that combination must now close it explicitly.
3939

4040
The `A2AExecutor` class bridges local AI agents built with the `agent_framework` library to the A2A protocol, allowing them to be hosted and accessed by other A2A-compliant clients.
4141

42+
For this hosting example, install the A2A SDK HTTP server extra:
43+
44+
```bash
45+
pip install "a2a-sdk[http-server]>=1.0.0,<2"
46+
```
47+
4248
```python
4349
from agent_framework.a2a import A2AExecutor
44-
from a2a.server.apps import A2AStarletteApplication
4550
from a2a.server.request_handlers import DefaultRequestHandler
51+
from a2a.server.routes import create_agent_card_routes, create_jsonrpc_routes
4652
from a2a.server.tasks import InMemoryTaskStore
53+
from starlette.applications import Starlette
4754

4855
# Create an A2A executor for your agent
4956
executor = A2AExecutor(agent=my_agent)
@@ -52,12 +59,15 @@ executor = A2AExecutor(agent=my_agent)
5259
request_handler = DefaultRequestHandler(
5360
agent_executor=executor,
5461
task_store=InMemoryTaskStore(),
62+
agent_card=my_agent_card,
5563
)
5664

57-
app = A2AStarletteApplication(
58-
agent_card=my_agent_card,
59-
http_handler=request_handler,
60-
).build()
65+
app = Starlette(
66+
routes=[
67+
*create_agent_card_routes(my_agent_card),
68+
*create_jsonrpc_routes(request_handler, "/"),
69+
]
70+
)
6171
```
6272

6373
### Basic Usage Example

0 commit comments

Comments
 (0)