Skip to main content

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 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

a2a_protocol-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

a2a_protocol-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

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

Hashes for a2a_protocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8edbccd60c5a8c77063df5cec3568b0495d15e5e7de86190e0de19ab14c434e4
MD5 da221d2d52afaca88bb9ef5d33e2c2bc
BLAKE2b-256 2a13c240e134052193e37d0f52d6550aee7d9a335c9f9d66536a31d0bbd9430a

See more details on using hashes here.

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

Hashes for a2a_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2b5b3b57ce8f8fa19e2a94c90f301e283b797510d578d46411253cc41edcf05
MD5 3b804454a5e12582f8473f0888ede70c
BLAKE2b-256 cfd3c08900fbac76f416028cccf6734e0c3e23013fe5ded6d518031e86f19825

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page