Skip to main content

a2a-firewall-sdk

Python SDK for the A2A Firewall — an inter-agent governance mesh that inspects, signs, and attenuates every message between AI agents.

PyPI version License: MIT Python 3.10+

What It Does

The A2A Firewall sits between agents in any multi-agent system and enforces security policies on every inter-agent message:

  • 6-layer detection pipeline — schema validation, permission checks, rule engine, CVE risk scoring, LLM semantic analysis, and policy decisions
  • Ed25519 message signing — every message is cryptographically signed, creating a tamper-evident hash chain
  • Macaroon-style delegation — capabilities attenuate (narrow) at each delegation hop, never widen
  • < 20ms p99 deterministic latency — crypto and rule layers run without LLM calls

This SDK handles all of that automatically: signing, chain hashing, delegation token management, and OpenTelemetry tracing.

Installation

pip install a2a-firewall-sdk

With Ed25519 signing support:

pip install "a2a-firewall-sdk[crypto]"

With OpenTelemetry tracing:

pip install "a2a-firewall-sdk[all]"

Quick Start

from a2a_firewall import A2AFirewall, FirewallConfig

# Configure the SDK
firewall = A2AFirewall(FirewallConfig(
    firewall_url="https://a2a-firewall-backend.onrender.com",
    agent_api_key="your_workspace_api_key",
    agent_id="your-agent-uuid",
    workspace_id="your-workspace-uuid",
    agent_private_key="ed25519-private-key-hex",  # optional: enables message signing
    fail_mode="closed",  # "closed" = block on error, "open" = allow on error
))

# Send a message through the firewall
response = firewall.send(
    receiver_agent_id="target-agent-uuid",
    task_type="research",
    payload={"query": "What are the latest fraud trends?"},
)

print(f"Decision: {response.decision}")  # "allow" | "block" | "review"
print(f"Risk score: {response.risk_score}")
print(f"Task ID: {response.task_id}")

Delegation Tokens

Create attenuable delegation tokens when forwarding tasks between agents:

# Agent A delegates to Agent B with narrowed permissions
delegation_token = firewall.create_delegation_token(
    root_key_hex="workspace-root-key-hex",
    receiver_agent_id="agent-b-uuid",
    task_type="research",    # restrict to research tasks only
    max_risk=0.5,            # cap risk threshold
)

# The token carries caveats that can only narrow, never widen
response = firewall.send(
    receiver_agent_id="agent-b-uuid",
    task_type="research",
    payload={"query": "Summarize findings"},
)

Verify Incoming Messages

# Verify a message received from another agent
result = firewall.verify_message(
    sender_public_key="sender-ed25519-public-key-hex",
    message_hash="sha256-message-hash",
    signature="ed25519-signature-hex",
    expected_parent_chain_hash="previous-chain-hash",  # optional
)
assert result["signature_valid"]
assert result["chain_valid"]

Fail Modes

Mode Behavior
closed (default) Raises FirewallBlockedError if the firewall is unreachable
open Allows the message through if the firewall is unreachable

OpenTelemetry

When opentelemetry-api is installed, the SDK automatically creates spans for every firewall.inspect call with task_type, decision, and risk_score attributes. No configuration needed.

pip install "a2a-firewall-sdk[otel]"

Transparent Proxy & Sidecar Auto-Detection (Tier A)

When running inside a containerized agent mesh (Docker Compose, Kubernetes) alongside an a2a-proxy sidecar, the SDK automatically detects the proxy and custom CA certificate from standard environment variables:

# No proxy config needed in code!
# The SDK automatically detects HTTPS_PROXY and SSL_CERT_FILE from env:
firewall = A2AFirewall(FirewallConfig(
    firewall_url="http://a2a-backend:8000",
    agent_api_key="your_api_key",
))

if firewall.proxy_detected:
    print("Running in governed sidecar container")
Variable Purpose Priority
A2A_PROXY_URL / HTTPS_PROXY Proxy endpoint (e.g. http://a2a-proxy:8080) Auto-routed
A2A_CA_CERT / SSL_CERT_FILE Path to Root CA certificate Auto-trusted

API Reference

FirewallConfig

Parameter Type Default Description
firewall_url str required Base URL of the A2A Firewall backend
agent_api_key str required Workspace API key for authentication
workspace_id str "" Workspace identifier
agent_id str "" This agent's identifier
agent_private_key str "" Ed25519 private key (hex) for message signing
timeout_seconds float 5.0 HTTP request timeout
fail_mode str "closed" "closed" or "open"

FirewallResponse

Field Type Description
task_id str Unique task identifier
decision str "allow", "block", or "review"
allowed bool Whether the message is allowed to proceed
risk_score float Risk score (0.0 to 1.0)
violations list[dict] List of detected violations
latency_ms int Inspection latency in milliseconds

FirewallBlockedError

Raised when raise_on_block=True (default) and the message is blocked.

try:
    firewall.send(...)
except FirewallBlockedError as e:
    print(f"Blocked: {e.reason}, risk: {e.risk_score}")
    print(f"Violations: {e.violations}")

Links

License

MIT

Download files

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

Source Distribution

a2a_firewall_sdk-0.4.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

a2a_firewall_sdk-0.4.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file a2a_firewall_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: a2a_firewall_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for a2a_firewall_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 87fb0e5e3cf04e5fd2c2c4d69bcaf6792e5fb02cd8cff4fd370e1c089f0045be
MD5 4b191dbca639c872ddc2d84b7e2b939f
BLAKE2b-256 4da4ea40c28e6d5689535b2ecfcc2516d06f8da10a27b5020271abe6b7fe8643

See more details on using hashes here.

File details

Details for the file a2a_firewall_sdk-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for a2a_firewall_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb0ec0278976d0e8513376f23e215914244f6e665895e3cc9d4f782a72c467f3
MD5 57faf0308c3598a8de5250a049f61381
BLAKE2b-256 1a3abe1569b394c2529139a1b8986435d1ff9ace7090f9dfb86038b808b4b057

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 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