Overview
TheA2AVerificationInterceptor is the central component of QWED A2A. Every inter-agent message passes through it before reaching the recipient.
The
trace_id parameter is required and must be provided by the caller. This ensures all verdicts and JWT attestations are deterministic and auditable. The HTTP gateway (POST /a2a/intercept) generates this automatically.Verification pipeline
Schema Validation
The incoming
AgentMessage is validated by Pydantic:sender_agent_idandreceiver_agent_idmust be 1–256 chars, no control characterspayloadis required (dict)payload_typedefaults toGENERALif not specified- Timestamps are timezone-aware UTC
Trust Boundary
The trust boundary evaluates the sender→receiver pair:
- Global blocklist check
- Pair-level block check
- Allowlist check (in strict mode)
- Token-bucket rate limiting
Trusted Agent Bypass
If the sender is in
config.trusted_agents, the message is forwarded immediately with a bypass engine verdict.Verification engines
Finance Guard
Verifies financial claims using deterministic Decimal arithmetic. Recomputes totals from line items and compares against theclaimed_total.
Logic Guard
Detects logical contradictions — claims where the same proposition is both asserted and negated.Code Guard
Scans code payloads for dangerous patterns using case-insensitive compiled regex:| Pattern | Regex | Catches |
|---|---|---|
eval | \beval\s*\( | eval(, EVAL (, eval\n( |
exec | \bexec\s*\( | exec(, Exec ( |
subprocess | subprocess\.|import subprocess|from subprocess import | subprocess.run, import subprocess as sp, from subprocess import run |
os.system | \bos\.system\s*\( | os.system(, OS.SYSTEM ( |
os.popen | \bos\.popen\s*\( | All casing/spacing variants |
__import__ | __import__\s*\( | Dynamic imports |
compile | \bcompile\s*\( | Code compilation |
importlib | \bimportlib\s*\. | Runtime module loading |
Passthrough
Messages withpayload_type of GENERAL or DATA_QUERY are forwarded without verification.
Configuration reference
TheInterceptorConfig controls which engines are active:
| Field | Type | Default | Description |
|---|---|---|---|
enable_financial_verification | bool | True | Route financial payloads to math verification |
enable_logic_verification | bool | True | Route logic assertions to contradiction checks |
enable_code_verification | bool | True | Route code payloads to regex security scanning |
block_on_error | bool | True | Block forwarding if verification encounters an internal error |
max_payload_size_bytes | int | 1,048,576 | Maximum payload size (1 KB – 10 MB) |
trusted_agents | List[str]? | None | Allowlist of agent IDs that bypass verification |
Error handling
Whenblock_on_error=True (default), any exception in a verification engine results in a BLOCKED verdict. When False, the message is FORWARDED despite the error — useful for observability-only deployments.
block_on_error=True (default)
block_on_error=True (default)
Engine exception →
BLOCKED verdict with error reason. Safe default for production.block_on_error=False (observability mode)
block_on_error=False (observability mode)
Engine exception →
FORWARDED verdict. The error is logged but doesn’t block communication. Use for shadow deployments.