Skip to main content

Test, validate, and certify A2A protocol implementations

Project description

A2Apex 🔬

Test, validate, and certify A2A protocol implementations.

A2Apex is the testing toolkit for the A2A (Agent-to-Agent) protocol — the open standard for AI agent interoperability. Think "Postman for AI Agents."

PyPI version Python 3.10+ License: Apache 2.0

Installation

pip install a2apex

For rich terminal output:

pip install a2apex[rich]

Quick Start

Validate an Agent Card

from a2apex import A2ApexClient

client = A2ApexClient()

# Validate from URL (fetches /.well-known/agent-card.json)
report = client.validate_card("https://agent.example.com")

print(f"Score: {report.score}/100")
print(f"Valid: {report.is_valid}")
print(f"Errors: {report.error_count}")
print(f"Warnings: {report.warning_count}")

# Show errors
for error in report.errors:
    print(f"  ✗ {error.field}: {error.message}")
    if error.suggestion:
        print(f"    💡 {error.suggestion}")

Run Full Test Suite

from a2apex import A2ApexClient

client = A2ApexClient()
results = client.test_agent("https://agent.example.com")

print(f"Score: {results.score}/100")
print(f"Passed: {results.passed}/{results.total_tests}")

for test in results:
    status = "✅" if test.passed else "❌"
    print(f"{status} {test.name}: {test.message}")

Validate a Dict (No HTTP)

from a2apex import validate_agent_card

card = {
    "name": "My Agent",
    "url": "https://api.example.com/a2a",
    "version": "1.0.0",
    "capabilities": {"streaming": True},
    "skills": [
        {"id": "chat", "name": "Chat", "description": "General conversation"}
    ]
}

report = validate_agent_card(card)
print(report)  # ✓ Valid (Score: 75/100) — 0 errors, 5 warnings

Validate State Transitions

from a2apex import validate_transitions, is_terminal_state

# Check if a sequence of state transitions is valid
result = validate_transitions(["submitted", "working", "completed"])
print(f"Valid: {result.is_valid}")  # True

# Invalid transition (can't go from completed to working)
result = validate_transitions(["submitted", "working", "completed", "working"])
print(f"Valid: {result.is_valid}")  # False
for v in result.violations:
    print(f"  ✗ {v.from_state}{v.to_state}: {v.reason}")

# Check terminal states
print(is_terminal_state("completed"))  # True
print(is_terminal_state("working"))    # False

Async Support

All methods have async versions:

import asyncio
from a2apex import A2ApexClient

async def main():
    client = A2ApexClient()
    
    # Async validation
    report = await client.avalidate_card("https://agent.example.com")
    
    # Async testing
    results = await client.atest_agent("https://agent.example.com")
    
    print(f"Score: {results.score}/100")

asyncio.run(main())

CI/CD Integration

Perfect for automated testing:

from a2apex import A2ApexClient

client = A2ApexClient()
results = client.test_agent("https://agent.example.com")

# Fail CI if compliance score too low
assert results.score >= 80, f"A2A compliance too low: {results.score}/100"

# Or check specific tests
for test in results:
    if test.name in ["agent_card_fetch", "message_send"]:
        assert test.passed, f"Critical test failed: {test.name}"

Export Reports

Generate JSON or HTML reports:

from a2apex import A2ApexClient, export_report

client = A2ApexClient()
results = client.test_agent("https://agent.example.com")

# Export to JSON
export_report(results, "report.json")

# Export to HTML
export_report(results, "report.html")

What Gets Tested

The test suite validates:

Test Description
agent_card_fetch Agent Card accessible at /.well-known/agent-card.json
message_send message/send JSON-RPC method works
task_get tasks/get returns valid task status
streaming SSE streaming works (if capability enabled)
invalid_method Agent returns proper error for unknown methods
task_cancel tasks/cancel processes correctly

Pydantic Models

A2Apex includes complete Pydantic v2 models for all A2A types:

from a2apex import (
    AgentCard,
    Task,
    Message,
    TextPart,
    create_text_message,
)

# Parse an Agent Card
card = AgentCard.model_validate(card_dict)
print(card.name, card.capabilities.streaming)

# Create messages
msg = create_text_message("Hello!", role="user")

API Reference

A2ApexClient

The main entry point:

client = A2ApexClient(
    timeout=30.0,        # Request timeout
    auth_header=None,    # Default Authorization header
)

# Sync methods
client.validate_card(url_or_dict)  ValidationReport
client.test_agent(url)  TestReport

# Async methods
await client.avalidate_card(url_or_dict)  ValidationReport
await client.atest_agent(url)  TestReport

ValidationReport

report.is_valid      # bool - No errors
report.score         # float - 0-100 compliance score
report.errors        # list[ValidationIssue] - Must fix
report.warnings      # list[ValidationIssue] - Should fix
report.info          # list[ValidationIssue] - Suggestions

TestReport

results.score           # float - 0-100
results.passed          # int - Passed tests
results.failed          # int - Failed tests
results.warnings        # int - Tests with warnings
results.total_tests     # int - Total tests run
results.results         # list[TestResult] - All results

# Iterate over results
for test in results:
    print(test.name, test.passed, test.message)

Requirements

  • Python 3.10+
  • httpx
  • pydantic >= 2.0

Links

License

Apache 2.0 - See LICENSE for details.


Built with 🦊 by Apex Ventures

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

a2apex-0.1.1.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

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

a2apex-0.1.1-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file a2apex-0.1.1.tar.gz.

File metadata

  • Download URL: a2apex-0.1.1.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for a2apex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5c4a5d315d51f459d0a4752ee6afbaa0e96a7260282f2a79d70541432ae689ea
MD5 bf282011edb0558be494f946df707c8e
BLAKE2b-256 b70bba1527d5fcf928620a491895f4656546307fdcbd8ee957640879627c9ced

See more details on using hashes here.

File details

Details for the file a2apex-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: a2apex-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for a2apex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5225a2c4d89bd671f739d723a741fe0da9fa120779e71a4eb22c3a5cd12053f
MD5 1d4f6533755640368670dc14fc6f1f4e
BLAKE2b-256 17d7ad14ed14af9dc53fd05476aeea9a629d4fb69875a158d0396394b4200a2c

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