Skip to main content

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 messages
  • FilePart: For file attachments
  • DataPart: For structured data

Task Management

  • Task: Represents a task with its status, history, and artifacts
  • TaskStatus: Current state of a task (working, completed, failed, etc.)
  • TaskState: Enum of possible task states

JSON-RPC Communication

  • JSONRPCRequest: Standard request format
  • JSONRPCResponse: Standard response format
  • SendTaskRequest, 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:

  1. Create and manage tasks
  2. Send and receive messages
  3. Share structured data and files
  4. Monitor task status and progress
  5. Handle errors and notifications

License

MIT

Metadata

Release files for a2a-protocol 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a2a-protocol 0.1.0
File Size Uploaded
a2a_protocol-0.1.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2a-protocol 0.1.0
File Interpreter ABI Platform
a2a_protocol-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / a2a_protocol-0.1.0.tar.gz

Download URL a2a_protocol-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8edbccd60c5a8c77063df5cec3568b0495d15e5e7de86190e0de19ab14c434e4
BLAKE2b-256 checksum
How to use checksums
2a13c240e134052193e37d0f52d6550aee7d9a335c9f9d66536a31d0bbd9430a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release files / a2a_protocol-0.1.0-py3-none-any.whl

Download URL a2a_protocol-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2b5b3b57ce8f8fa19e2a94c90f301e283b797510d578d46411253cc41edcf05
BLAKE2b-256 checksum
How to use checksums
cfd3c08900fbac76f416028cccf6734e0c3e23013fe5ded6d518031e86f19825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page