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.3.0.tar.gz (13.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_firewall_sdk-0.3.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: a2a_firewall_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 13.3 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.3.0.tar.gz
Algorithm Hash digest
SHA256 bfd791997cf90b5012fe80d27a704edce847d33ef70d81a10235b7c9c086c471
MD5 b266bd7c9c90193d87fa5f74b0e181ce
BLAKE2b-256 b2f9e7acc9901719b5fd4f4407757a91c0d36c63301e838e4152e3a23377a243

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2a_firewall_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31aef9868908a41f63e690a4f7837057963070989006de8d51ac6ac23a5c76fb
MD5 d3228b458796369c4f554a773ed03dad
BLAKE2b-256 b9a498aae03091c238ad6aaf8b665818b29dcff048f6b03c6948791ec737295e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.1

2 files

0.4.0

2 files

This release

0.3.0 This release

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