A2A SDK - Agent to Agent Protocol Python SDK
Project description
A2A SDK
Agent to Agent Protocol Python SDK - Supporting Python 3.8-3.13
Installation
Install using pip:
pip install pya2a
Features
- Implements Agent to Agent Protocol client and server
- Supports sending, retrieving, and canceling tasks
- Supports notification configuration
- Supports streaming responses
- Compatible with Python 3.8-3.13
Usage Examples
Client Example
import asyncio
from a2a.client import A2AClient
from a2a.types import Message, TextPart
async def main():
client = A2AClient(url="http://example.com/agent")
# Create task
task_response = await client.send_task({
"id": "task-123",
"message": Message(
role="user",
parts=[TextPart(text="Hello, this is a test")]
)
})
print(f"Task created successfully: {task_response.result.id}")
# Get task
task = await client.get_task({"id": "task-123"})
print(f"Task status: {task.result.status.state}")
if __name__ == "__main__":
asyncio.run(main())
Streaming Response Example
import asyncio
from a2a.client import A2AClient
from a2a.types import Message, TextPart
async def main():
client = A2AClient(url="http://example.com/agent")
# Send streaming task request
async for response in client.send_task_streaming({
"id": "task-123",
"message": Message(
role="user",
parts=[TextPart(text="Please generate a long text")]
)
}):
if response.result:
print(response.result)
if __name__ == "__main__":
asyncio.run(main())
Development Setup
- Clone the repository:
git clone https://github.com/your-username/a2a.git
cd a2a
- Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -
- Install dependencies:
poetry install
- Activate the virtual environment:
poetry shell
Testing
Run tests using pytest:
poetry run pytest
Contribution Guidelines
Pull Requests are welcome! Please ensure before submitting:
- Update tests to reflect your changes
- Update documentation
- Your code passes all tests
- Format code with Black
- Lint code with Ruff
Origin
The initial code for this SDK was derived from the common parts of the Google A2A project samples.
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
pya2a-0.1.1.tar.gz
(12.7 kB
view details)
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
pya2a-0.1.1-py3-none-any.whl
(14.6 kB
view details)
File details
Details for the file pya2a-0.1.1.tar.gz.
File metadata
- Download URL: pya2a-0.1.1.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.9 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d747a364c359959be2edd70c7da3850163941005d743e63e4302c31e1a48fd79
|
|
| MD5 |
9214b3acd7f25f9aa658352121fc1ea4
|
|
| BLAKE2b-256 |
2c8e7f72df589545e821cc824764783cbb1f57487cd9bfe033a0faefd0e07526
|
File details
Details for the file pya2a-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pya2a-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.9 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ded77c84c4dd203062e3e6743b65b1a92b77c13a8ef8f6f21e1f331a2a41d131
|
|
| MD5 |
3e7655dd2d369cfe189e48eaeed144a8
|
|
| BLAKE2b-256 |
fccdc4bb41eae6e0418fa6c2d358cd2e80eb4712568543c0d55ab012c705af21
|