Repository navigation
AgentWire v0.2.0 — Cryptographic Auth, Two-Phase Budgets & TCP RPC
AgentWire v0.2.0 — Cryptographic Auth, Two-Phase Budgets & Networked TCP RPC
AgentWire is a compact, cryptographically verifiable binary wire protocol (AW01) and deterministic policy runtime for multi-agent AI systems built with Rust + PyO3.
Highlights
- HMAC-SHA256 Frame Authentication & Replay Protection (
agentwire-core,agentwire-validator):- Constant-time HMAC-SHA256 signing (
sign_ast/verify_frame) over canonical headers, replaynonce,timestamp_ms, and typed AST body. - Zero-trust receiver validation: sender
GUARD_VERIFIEDflags are advisory only and never trusted by receivers. - Replay nonce cache (
REPLAY_DETECTED) and clock-skew freshness window (EXPIRED_TIMESTAMP).
- Constant-time HMAC-SHA256 signing (
- Two-Phase Budget Accounting (
Reserve -> Settle / Release):PolicyEnginereserves declared max budgets on frame acceptance, settles actual downstream token/cost spend viasettle_usage(returning unused budget to the session pool), and refunds 100% viarelease_reservationon error or timeout.Mutex-backed thread safety verified under 8-thread concurrent sessions.
- Cross-Process TCP RPC Transport (
agentwire.transport):- Length-prefixed binary TCP
AgentWireRpcServer&AgentWireRpcClientwith(trace_id, span_id)correlation, timeouts, exponential-backoff retries, independent receiver-side HMAC + policy enforcement, andCrewAIWire.register_remote_role.
- Length-prefixed binary TCP
- Apples-to-Apples Benchmarks (1,000 hops,
tiktoken:cl100k_base):- Wire Bytes (exact same AST struct):
-68.3%vs. compact JSON and-60.7%vs. RFC 8949 CBOR (unsigned115.2 B);-57.4%vs. compact JSON even with 32-byte HMAC-SHA256 + nonce/timestamp (155.1 B). - LLM Context Tokens (separated from wire bytes):
-15.3%vs. minimal compact AST JSON (62.2 -> 52.8 tok/hop) and-83.1%vs. verbose framework envelopes (312.2 -> 52.8 tok/hop). - Full Authenticated Rust Pipeline:
24.55 µsmean (97.70 µsp99); forged rogueMUTATEblocked in4.00 µs, replay blocked in1.80 µs.
- Wire Bytes (exact same AST struct):
- Fuzzing & Robustness:
- Rust
proptestproperty-based roundtrip and arbitrary-byte fuzzing (13 Rust tests passing, 0 warnings) + 27 Python unit, adversarial, 500-case FFI fuzz, concurrency, and TCP RPC tests.
- Rust
Quick Install
- Pre-built wheel (Windows x64, Python 3.12):
pip install agentwire-0.2.0-cp312-cp312-win_amd64.whl
- Build from source (Linux / macOS / Windows, Python 3.10–3.13 + Rust):
git clone https://github.com/alok-108/agentwire.git cd agentwire uv venv .venv && uv pip install --python .venv/bin/python maturin pytest tiktoken .venv/bin/maturin develop --release