Skip to main content

a2a-t-sdk-python

Python License

Python SDK used to generate task prompts and handle task negotiation flows based on the A2A-T protocol.

中文


Project Overview

A2A-T (Agent-to-Agent Telecom) is a telecom-domain multi-agent interconnection protocol extended from the A2A protocol. It enhances capabilities such as information models, task negotiation, and collaboration security for telecom business scenarios, supporting deterministic, highly reliable, efficient, and secure collaboration among multi-agents in the telecom domain.

a2a-t-sdk-python is the Python SDK of the A2A-T protocol. Its core responsibility is to generate, validate, and negotiate task prompts (structured protocol messages) in A2A-T interactions. The SDK primarily targets two kinds of users:

  • Client Agent: converts natural-language or structured input into task prompts conforming to the A2A-T format, and initiates, receives, and advances negotiation flows.
  • Server Agent: validates whether A2A-T messages submitted by clients satisfy scenario, template, and slot constraints, extracts parameters, and advances negotiation flows.

The A2A-T SDK is independent of the A2A SDK. Using the two SDKs together builds agents with full A2A-T protocol support (the A2A SDK to pair with in the Python ecosystem is a2a-sdk):

flowchart LR
    subgraph Server["Server Agent"]
        B2["A2A SDK (a2a-sdk)<br/>A2A transport"] --> B1["A2A-T Server SDK<br/>message validation / parameter extraction / negotiation"]
        B1 --> B0["Business code"]
    end
    subgraph Client["Client Agent"]
        A0["Business code"] --> A1["A2A-T Client SDK<br/>task prompt generation / negotiation messages"]
        A1 --> A2["A2A SDK (a2a-sdk)<br/>A2A transport"]
    end
    Client -- "HTTP A2A-T request" --> Server
    Server -- "HTTP A2A-T response" --> Client

Core Capabilities

Capability Description
Task prompt generation (client) Covers input normalization, scenario recognition, slot extraction, and template rendering, supporting both natural-language and structured-data input
Message validation and parameter extraction (server) Executes metadata parsing, slot extraction, and semantic validation on SDK-format task prompts, extracts parameters per a Schema, and returns details of missing/invalid slots
Negotiation content API Supports information / feasibility / target negotiation types plus abort termination messages, with template-driven negotiation message generation and validation; negotiation session state travels in the message metadata (negotiationContext) and the SDK itself is stateless
Resource organization Bundled prompt resources (prompts / scenarios / slots / templates / negotiation-vocabulary) ship with the package, supporting both packaged built-in resources and local_file local files
LLM adaptation Connects to external LLMs through OpenAI-compatible call chains, retrying retryable error codes up to the configured attempt limit
Bundled samples The repository ships runnable sample scenarios such as subscribe_incident (event subscription); without an API key they automatically degrade to scripted mock LLM responses, running end to end with zero external dependencies

Project Structure

The repository is organized with uv; the core code lives under src/a2a_t:

Module Description
client Client wrapper providing task prompt generation and negotiation entry points (A2ATClient)
server Server wrapper providing A2A-T message validation and negotiation entry points (A2ATServer)
core Template addressing, metadata models, the validation pipeline, and the structured bilingual error model
common/prompt_resources Bundled prompt resource packaging and loading (packaged / local_file)
config .env-based configuration loading and configuration models
llm LLM adaptation layer with a default OpenAI-compatible client; supports custom LLM integration
prompt Prompt resource analysis, slot extraction, template rendering, and validation
negotiation Negotiation content models, the generation pipeline, and the validation pipeline
a2a-t-sample Runnable client/server sample case collection
a2a-t-corpus Accuracy verification corpus (pure test assets): data-driven workflow cases

The tests/ directory mirrors the package structure, covering prompt generation, server validation, negotiation pipelines, prompt resources, and LLM adaptation test cases.

Quick Start

Environment Requirements

Item Requirement
Python >=3.12
Dependency manager uv (recommended)
LLM Optional. Without an API key the samples automatically degrade to scripted mock LLM responses, running with zero external dependencies

Run the First Demo in Three Steps

Take the subscribe_incident (event subscription) scenario as an example: the client generates a Notification-T task prompt from natural-language input and sends it to the server over a real HTTP A2A chain; the server validates the message, establishes the event subscription, and streams Incident notifications. All commands below run in the a2a-t-sample directory (where .env lives):

# 1. Install dependencies and prepare the environment configuration
#    (an empty A2AT_LLM_API_KEY automatically uses the mock LLM)
#    First run: execute uv sync --dev in the repository root (this creates .venv
#    and installs the SDK dependencies), then run the following in a2a-t-sample
cp env.example .env      # after copying, confirm A2AT_LLM_API_KEY is empty
uv pip install -r requirements.txt

# 2. Terminal 1: start the registry center (port 5001)
#    Set the module search path first (.env lives in a2a-t-sample):
#    PowerShell: $env:PYTHONPATH = "$pwd\subscribe-incident\src"
#    bash:       export PYTHONPATH="$(pwd)/subscribe-incident/src"
uv run python -m agentcard_example.registry_main

# 3. Terminal 2: start the server (port 8000);
#    Terminal 3: start the client (keeps receiving artifacts, Ctrl+C to stop)
#    Set PYTHONPATH in both terminals as in step 2
uv run python -m server_example.server_main
uv run python -m client_example.client_main

After startup you can observe the full-chain logs: client scenario recognition and slot extraction, the generated task prompt, the A2A request message, the server validation result, and the Incident notification push.

If the Windows console shows garbled Chinese characters, run chcp 65001 first.

Connect a Real LLM (Optional)

Edit a2a-t-sample/.env and fill in any OpenAI-compatible endpoint:

# LLM protocol type
A2AT_LLM_PROVIDER=openai
# Model name
A2AT_LLM_MODEL=<model name>
# Model endpoint
A2AT_LLM_BASE_URL=<OpenAI-compatible endpoint>
# LLM API key
A2AT_LLM_API_KEY=<your API key>

See the repository root env.example for the full configuration reference.

Development and Testing

cd {project path}/a2a-t-sdk-python
uv sync --dev
uv run pytest        # run all tests
uv run ruff check .  # static checks
uv run mypy src      # type checks

More runnable samples (event subscription end-to-end, negotiation closed loop, etc.) are described in a2a-t-sample/README.md.

More Documentation

Document Location Content
Developer Guide docs/en/developer_guide.md Feature introduction, installation and integration, parameter configuration, and minimal practices
API Reference docs/en/API_Reference.md Full API definitions and usage of A2ATClient / A2ATServer

Current Support Scope

Confirm the following limitations before use:

  • The built-in LLM call chain is uniformly exposed as an OpenAI adaptation layer.
  • The LLM prompt resources are built in and do not support custom extension (prompts and errors are always read from the built-in resources).
  • Negotiation session state travels in the message metadata (the SDK is stateless) and no negotiation state store is provided; the legacy state-machine negotiation APIs (start_negotiation / receive_negotiation / continue_negotiation) are deprecated since 1.1.0.
  • Bundled resources and language coverage are limited, and remote resource loading such as registry-center (the registry center) is not included.
  • This document mainly introduces the SDK itself and does not cover CLI tools, hosted services, deployment flows, or ready-to-use application solutions.

License

This project is licensed under the Apache-2.0 license.

Release files for a2a-t-sdk 1.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-t-sdk 1.1.0
File Size Uploaded
a2a_t_sdk-1.1.0.tar.gz 262.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2a-t-sdk 1.1.0
File Interpreter ABI Platform
a2a_t_sdk-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 650.0 kB

Release files / a2a_t_sdk-1.1.0.tar.gz

Download URL a2a_t_sdk-1.1.0.tar.gz
Size 262.9 kB
Tags Source
SHA-256 checksum
How to use checksums
81618efea2495f7b58cd4b73b8653c0cea1efed0472fd3744ad1dddad24daa8c
BLAKE2b-256 checksum
How to use checksums
b5cd7394fd5a1257d155ad7529956f59f685fa3cc6e3791c987b70655036c793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / a2a_t_sdk-1.1.0-py3-none-any.whl

Download URL a2a_t_sdk-1.1.0-py3-none-any.whl
Size 387.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
999e6b35cf9c4826fa86e34318b9ea66d7e8c53de0aebae60000307206d9e59b
BLAKE2b-256 checksum
How to use checksums
329c28700010b210cebf889fcb7529c16ad0718b907473ce597f1c88612e934b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.9

2 release files

1.0.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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