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

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.2.0.tar.gz (10.1 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.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: a2a_firewall_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 10.1 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.2.0.tar.gz
Algorithm Hash digest
SHA256 2dc2d65585aa1aa12d74312e73b92f63c96804e8a70ef1a591f0093e093bd236
MD5 c252c6e2b5ce9e8c4e0ab0782e1fe081
BLAKE2b-256 ceb836d25b80b1e117493b97a24862d55a5f5be9d454c706058982c8f27f3126

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2a_firewall_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e26c3a670c1ba676a436b80225cf2501853949970495f2cbad45ff3ce7e8c439
MD5 56c4dcd106595c387e6a0f82faa4d8cf
BLAKE2b-256 928d85598b0859e4a98884e136713f9929f517c709cef01d5f22a4b11588ddf9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

This release

0.2.0 This release

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