This page provides a high-level introduction to the a2a-python SDK, its purpose, architecture, and major subsystems. It is intended for developers who want to understand the SDK's structure before diving into implementation details.
For installation instructions, see Installation and Setup. For a detailed list of capabilities, see SDK Features and Capabilities. For protocol-level details, see A2A Protocol and Data Models.
The a2a-python SDK is a Python implementation of the Agent-to-Agent (A2A) Protocol, enabling developers to:
The SDK supports Python 3.10+ and provides optional integrations for HTTP servers (FastAPI/Starlette), databases (PostgreSQL, MySQL, SQLite), gRPC, OpenTelemetry, and cryptographic signing.
Sources: README.md1-103 pyproject.toml1-57
The SDK is distributed as the a2a-sdk package on PyPI with a modular dependency structure:
| Component | Dependencies | Purpose |
|---|---|---|
| Core | httpx, httpx-sse, pydantic, protobuf, google-api-core | Client functionality, type system, Protocol Buffer support |
http-server | fastapi, starlette, sse-starlette | JSON-RPC and REST server implementations |
grpc | grpcio, grpcio-tools, grpcio-reflection | gRPC transport support |
telemetry | opentelemetry-api, opentelemetry-sdk | OpenTelemetry tracing integration |
sql | sqlalchemy[asyncio,postgresql-asyncpg,aiomysql,aiosqlite] | Database persistence for tasks and push notification configs |
encryption | cryptography | Cryptographic utilities |
signing | PyJWT | Agent card signature verification |
Users install only the components they need. For example, a client-only application needs just the core package, while a server application typically needs http-server and optionally sql.
Sources: pyproject.toml10-50 README.md44-60
The SDK is designed as two complementary subsystems that can be used independently or together:
Entry Point: ClientFactory class
Purpose: Discover and communicate with remote A2A agents
Key Classes: JsonRpcTransport, RestTransport, GrpcTransport, A2ACardResolver
The client subsystem enables applications to:
/.well-known/agent-card.json endpointSources: src/a2a/client/client_factory.py src/a2a/client/json_rpc_transport.py src/a2a/client/rest_transport.py src/a2a/client/agent_card.py
Entry Point: JSONRPCApplication or RestAdapter classes
Purpose: Expose agent functionality as an A2A-compliant server
Key Classes: DefaultRequestHandler, AgentExecutor, TaskManager, EventQueue
The server subsystem enables applications to:
Sources: src/a2a/jsonrpc/jsonrpc_app.py src/a2a/rest/rest_adapter.py src/a2a/server/request_handler.py src/a2a/server/agent_executor.py src/a2a/server/task_manager.py src/a2a/server/event_queue.py
The SDK defines its type system using two complementary approaches:
src/a2a/types.py)Purpose: JSON serialization, validation, and Python-native type checking
Generated From: A2A specification JSON schemas via datamodel-code-generator
Key types include:
Message: User or agent messages with parts (text, files, data)Task: Execution state with status, artifacts, and historyAgentCard: Agent metadata, capabilities, and security schemesTaskStatusUpdateEvent / TaskArtifactUpdateEvent: Real-time updatesInvalidRequestError, TaskNotFoundError, etc.src/a2a/grpc/*.proto)Purpose: Binary serialization for gRPC transport
Generated From: A2A specification .proto files via buf generate
The proto_utils module (src/a2a/proto_utils.py) provides bidirectional conversion between Pydantic models and Protocol Buffer messages using ToProto and FromProto classes.
Sources: src/a2a/types.py src/a2a/grpc/ src/a2a/proto_utils.py .github/workflows/update-a2a-types.yml
The repository is organized into distinct directories by functionality:
Key Directories:
| Directory | Purpose |
|---|---|
src/a2a/ | Main SDK source code |
src/a2a/client/ | Client transport implementations and agent discovery |
src/a2a/server/ | Server-side request processing, task management, event streaming |
src/a2a/jsonrpc/ | FastAPI-based JSON-RPC 2.0 server implementation |
src/a2a/rest/ | Starlette-based REST API server implementation |
src/a2a/grpc/ | Generated Protocol Buffer code and gRPC servicer |
src/a2a/utils/ | Helper functions, validators, error handlers |
tests/ | Unit tests and end-to-end integration tests |
.github/workflows/ | CI/CD automation for testing, linting, type generation, and releases |
Sources: [Repository structure visible in file paths]
The following diagram illustrates how a client message becomes a persisted task with real-time updates:
Process Breakdown:
send_message() on a transport clientDefaultRequestHandler.on_message_send()TaskStoreAgentExecutor.execute() processes the message asynchronouslyEventQueueSources: src/a2a/client/json_rpc_transport.py src/a2a/jsonrpc/jsonrpc_app.py src/a2a/server/request_handler.py src/a2a/server/agent_executor.py src/a2a/server/event_queue.py src/a2a/server/task_store/
The SDK implements multiple protocol layers for maximum interoperability:
| Protocol | Client Support | Server Support | Streaming | Binary |
|---|---|---|---|---|
| JSON-RPC 2.0 over HTTP | ✓ JsonRpcTransport | ✓ JSONRPCApplication | SSE | JSON |
| REST API | ✓ RestTransport | ✓ RestAdapter | SSE | JSON or Protobuf |
| gRPC | ✓ GrpcTransport | ✓ A2AServicer | gRPC Streaming | Protobuf |
All protocols support:
Sources: src/a2a/client/ src/a2a/jsonrpc/ src/a2a/rest/ src/a2a/grpc/
The SDK uses an automated CI/CD pipeline to maintain code quality and synchronization with the A2A specification:
Automated Workflows:
types.py and Protocol Buffer codeSources: .github/workflows/ pyproject.toml118-144
This overview provides a foundation for understanding the SDK's architecture. For detailed information on specific topics:
Sources: [Table of contents in JSON format provided]
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.