Agent to Agent Protocol Specification Python models
Project description
A2A Protocol
Python models for Google's Agent-to-Agent (A2A) Protocol specification. This package provides both Pydantic and dataclass model implementations, enabling type-safe communication between agents.
Maintained by the team at Legion AI.
Installation
pip install a2a-protocol
Usage
Pydantic v2 Implementation
from a2a_protocol.pydantic_v2 import Message, Part, TextPart, Role
# Create a simple message
message = Message(
role=Role.user,
parts=[
Part(root=TextPart(
type="text",
text="Hello, agent!",
metadata={"source": "user_interface"}
))
],
metadata={"session_id": "12345"}
)
Dataclass Implementation
from a2a_protocol.dataclass import Message, TextPart, Role
# Create a simple message using dataclasses
message = Message(
role=Role.user,
parts=[
TextPart(
type="text",
text="Hello, agent!",
metadata={"source": "user_interface"}
)
],
metadata={"session_id": "12345"}
)
Core Components
Message Types
TextPart: For text-based messagesFilePart: For file attachmentsDataPart: For structured data
Task Management
Task: Represents a task with its status, history, and artifactsTaskStatus: Current state of a task (working, completed, failed, etc.)TaskState: Enum of possible task states
JSON-RPC Communication
JSONRPCRequest: Standard request formatJSONRPCResponse: Standard response formatSendTaskRequest,GetTaskRequest,CancelTaskRequest: Specific request types
Protocol Workflow
┌──────────────┐ ┌──────────────┐
│ │ │ │
│ Agent A │◄──────────►│ Agent B │
│ │ A2A │ │
└──────────────┘ Protocol └──────────────┘
│ ▲
│ │
│ ┌──────────┐ │
└────────►│ Tasks │◄──────┘
│ │
└──────────┘
Features
- Full type-checked implementation of the A2A protocol
- Both Pydantic v2 and dataclass implementations
- Complete support for:
- Task creation and management
- Messaging between agents
- File and data transfer
- Status updates and notifications
- Error handling
Protocol Structure
The A2A protocol enables agents to:
- Create and manage tasks
- Send and receive messages
- Share structured data and files
- Monitor task status and progress
- Handle errors and notifications
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file a2a_protocol-0.1.0.tar.gz.
File metadata
- Download URL: a2a_protocol-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8edbccd60c5a8c77063df5cec3568b0495d15e5e7de86190e0de19ab14c434e4
|
|
| MD5 |
da221d2d52afaca88bb9ef5d33e2c2bc
|
|
| BLAKE2b-256 |
2a13c240e134052193e37d0f52d6550aee7d9a335c9f9d66536a31d0bbd9430a
|
File details
Details for the file a2a_protocol-0.1.0-py3-none-any.whl.
File metadata
- Download URL: a2a_protocol-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2b5b3b57ce8f8fa19e2a94c90f301e283b797510d578d46411253cc41edcf05
|
|
| MD5 |
3b804454a5e12582f8473f0888ede70c
|
|
| BLAKE2b-256 |
cfd3c08900fbac76f416028cccf6734e0c3e23013fe5ded6d518031e86f19825
|