Quick Start
How It Works
| Step | Description |
|---|---|
| Discovery | Fetch agent capabilities via Agent Card |
| Authentication | Optional Bearer token validation |
| Messaging | Send messages using JSON-RPC protocol |
| Task Management | Track, list, and cancel tasks |
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
base_url | str | — | Base URL of the A2A server |
auth_token | str | None | Bearer token for authentication |
timeout | float | 30.0 | HTTP request timeout in seconds |
Discovery Methods
Get Agent Card
Fetch basic agent information from/.well-known/agent.json:
Get Extended Card
Fetch detailed agent information (requires authentication):Message Methods
Send Message
Send a text message and get the complete task result:Streaming Messages
Send a message and receive real-time Server-Sent Events:Task Management
Get Task Details
List Tasks
Cancel Task
Context Manager Pattern
Recommended approach with automatic session cleanup:Agent-to-Agent Communication
Complete example showing agent-to-agent delegation:Error Handling
Handle common HTTP and connection errors:Common Patterns
Agent Discovery
Agent Discovery
Always fetch the agent card first to understand capabilities before sending messages.
Context Preservation
Context Preservation
Maintain conversation context across multiple message exchanges.
Task Monitoring
Task Monitoring
Monitor long-running tasks with periodic status checks.
Batch Operations
Batch Operations
Process multiple tasks concurrently using asyncio.
Best Practices
Session Management
Session Management
Always use the context manager pattern to ensure proper session cleanup and avoid connection leaks.
Error Recovery
Error Recovery
Implement retry logic for transient network errors and timeouts.
Authentication
Authentication
Store auth tokens securely and never expose them in logs or error messages.
Streaming Best Practices
Streaming Best Practices
Handle streaming events gracefully with proper error handling and backpressure.
Related
A2A Protocol
Setup A2A servers and protocol basics
Multi-Agent Patterns
Agent orchestration and communication patterns

