Skip to content

rajamohan1950/AgentTransportProtocol

Repository files navigation

Rust gRPC Protobuf License

Agent Transport Protocol (ATP)

A networking-layer protocol for AI agents, modeled on TCP/IP

A five-layer protocol stack exploring trust-aware, economically-optimal multi-agent networking.
One-line SDK. Zero config. ~37k lines of Rust, 280 tests.

Status: research prototype. The architecture and SDK are real and tested;
the benchmark numbers below come from a simulation harness, not production LLM workloads (see Benchmarks).

Quick StartArchitectureBenchmarksSDK APIWhy ATP?Wiki


Headline Numbers (simulated)

These come from ATP's own simulation harness (atp-sim) — synthetic agents with hash-based embeddings, not real LLM calls. They show the architecture is internally consistent and each layer contributes; they are not a claim about production cost or quality. Reproduce them yourself with the benchmark command below.

Metric Value (simulated)
Cost Reduction -53.4% vs sequential baseline
Context Compression 28x via Semantic Context Differentials
Task Failures 0 across 10,000 simulated tasks
Quality Score 0.904 (+8% over in-sim baselines)
Latency Reduction -29.3% vs sequential baseline
Routing Decisions < 1 microsecond
Tests 280 passing • zero failures
Lines of Rust ~37,000 across 75 files

Quick Start

Rust (3 lines)

# Cargo.toml
[dependencies]
atp-sdk = { git = "https://github.com/rajamohan1950/AgentTransportProtocol" }
fn main() {
    atp_sdk::benchmark();                    // Full 7-scenario benchmark table
    atp_sdk::route("coding");                // Best route for coding tasks
    atp_sdk::compress(b"context...", "coding"); // 28x compression
}
cargo run

That's it. No config. No setup. No structs to create. Just call the function.

Python

pip install maturin
cd crates/atp-python && maturin develop --release
import atp

atp.benchmark()           # Full 7-scenario table
atp.route("coding")       # Best agent route
atp.compress(data, "coding")  # 28x compression
atp.sign(b"hello")        # Ed25519 identity + signature
atp.trust("coding")       # Network trust score

CLI Benchmark

cargo run --release -p atp-bench -- --agents 50 --tasks 10000 --seed 42

Architecture

ATP is a five-layer protocol stack. Each layer is independent, composable, and has its own crate:

┌─────────────────────────────────────────────────────────┐
│  L5  Fault Tolerance     Circuit breaker, heartbeat,    │
│                          poison pill detection           │
├─────────────────────────────────────────────────────────┤
│  L4  Economic Routing    Bellman-Ford, 5 patterns,      │
│                          Pareto-optimal multi-objective  │
├─────────────────────────────────────────────────────────┤
│  L3  Context (SCD)       28x semantic compression,      │
│                          cosine similarity, MSC extract  │
├─────────────────────────────────────────────────────────┤
│  L2  Handshake           3-phase SYN/SYN-ACK/ACK,      │
│                          capability negotiation, QoS     │
├─────────────────────────────────────────────────────────┤
│  L1  Identity & Trust    Ed25519 DID, time-decayed      │
│                          trust scoring, Sybil guard     │
└─────────────────────────────────────────────────────────┘

Layer 1: Identity & Trust

  • W3C DID identities (did:key:z6Mk...) with Ed25519 cryptographic keys
  • Time-decayed trust scoring:
T(a) = Σ(qᵢ × e^(-λΔt) × γ(task)) / Σ(e^(-λΔt) × γ(task))

where λ = 0.01/day and γ maps task types to complexity weights

  • Sybil resistance via transitive trust dampening (α = 0.5, max 5 hops)
  • 31 tests

Layer 2: Capability Handshake

  • 3-phase SYN / SYN-ACK / ACK negotiation inspired by TCP
  • Agents declare capabilities (task type, quality, latency, cost)
  • Binding QoS contracts with constraints: min quality, max latency, max cost
  • 25 tests

Layer 3: Semantic Context Differentials (SCD)

  • 28x context compression by extracting Minimal Sufficient Context (MSC)
  • Hash-based embeddings → cosine similarity scoring → relevance-based chunking
  • Adaptive context: iterative refinement when confidence < 0.7
  • Configurable: relevance threshold, max chunks, chunk size, dimensions
MSC = {(chunk, score) : cosine(e_task, e_chunk) > threshold}
  • 45 tests

Layer 4: Economic Routing

  • Modified Bellman-Ford with 10 Pareto weight vectors
  • Multi-objective optimization: quality (multiplicative), latency (additive), cost (additive)
  • 5 routing patterns:
Pattern Strategy Savings
DraftRefine Cheap agent drafts, specialist refines 40-70%
Cascade Try cheapest first, escalate on low confidence 30-50%
ParallelMerge Multiple agents process, merge results Quality focus
Ensemble Multiple agents vote on result Reliability
Pipeline Sequential processing chain Throughput
  • Pareto-optimal route selection with constraint satisfaction
  • 27 tests

Layer 5: Fault Tolerance

  • Circuit breaker with half-open recovery probes
  • Heartbeat monitoring with < 100ms failure detection
  • Checkpoint/restore for long-running tasks
  • Poison pill detection for permanently failing inputs
  • 42 tests

Benchmarks

50 simulated agents, 10,000 tasks, seed=42 — run inside atp-sim, not against live LLMs. Numbers are deterministic and reproducible from the seed; they measure the protocol's behavior under a controlled model, not real-world cost or quality. Wiring this harness to real agent backends is the top open item (see Status).

Scenario             Cost/Task  Latency  Quality  Recovery    Ctx  Failed
─────────────────────────────────────────────────────────────────────────
Sequential            $0.0844    800ms    0.837       inf   1.0x       0
Round-Robin           $0.0712    720ms    0.856       inf   1.0x       0
ATP (full)            $0.0393    568ms    0.904       0ms  28.0x       0
ATP w/o SCD           $0.0627    612ms    0.891       0ms   1.0x       0
ATP w/o Routing       $0.0458    645ms    0.878       0ms  28.0x       0
ATP w/o Trust         $0.0451    634ms    0.892       0ms  28.0x       0
ATP w/o Fault         $0.0397    580ms    0.902       inf  28.0x       2
─────────────────────────────────────────────────────────────────────────

ATP vs Sequential:
  Cost:    -53.4%
  Latency: -29.0%
  Quality: +0.067

Ablation Analysis

Every layer contributes. Removing any layer degrades results:

  • Without SCD (L3): Cost jumps from $0.039 → $0.063 (+59%), compression drops to 1.0x
  • Without Routing (L4): Cost rises to $0.046, quality drops to 0.878
  • Without Trust (L1): Quality drops to 0.892, cost increases to $0.045
  • Without Fault (L5): 2 task failures appear, recovery becomes infinite

SDK API

The SDK provides two flavors of every operation:

Flavor Style Returns Use case
Verb route("coding") Prints to stdout Quick exploration, demos
Noun find_route("coding") Typed result Production code, pipelines

Every type implements Display — just println!("{result}") and it formats beautifully.

Functions

// ── Verb functions (print) ──────────────────────────────
atp_sdk::benchmark();                         // Full 7-scenario table
atp_sdk::route("coding");                     // Print best route
atp_sdk::compress(data, "coding");            // Print compression stats
atp_sdk::sign(b"hello");                      // Print agent + signature
atp_sdk::trust("coding");                     // Print trust score

// ── Noun functions (return values) ──────────────────────
let report = atp_sdk::bench(10_000);          // -> BenchReport
let route  = atp_sdk::find_route("coding");   // -> RouteResult
let route  = atp_sdk::find_route_with("coding", 0.9); // with min quality
let comp   = atp_sdk::shrink(data, "coding"); // -> CompressResult
let agent  = atp_sdk::agent();                // -> Agent (Ed25519 keypair)
let trust  = atp_sdk::trust_score("coding");  // -> TrustInfo

Return Types

// RouteResult
route.task          // "CodeGeneration"
route.pattern       // "draft_refine"
route.agents        // 2
route.quality       // 0.92
route.cost          // 0.0500
route.latency_ms    // 45

// CompressResult
comp.ratio           // 28.3
comp.original_size   // 50000
comp.compressed_size // 1768
comp.chunks          // 3
comp.confidence      // 0.85

// Agent
agent.did()          // "did:key:z6Mk..."
agent.sign(msg)      // -> Signature
agent.verify(msg, &sig) // -> bool

// TrustInfo
trust.score          // 0.87
trust.samples        // 42

Skill Aliases

Tasks are specified as simple strings. Case-insensitive with many aliases:

Canonical Aliases
"coding" "code", "codegen", "code_generation", "cg"
"analysis" "analyze", "analyse"
"writing" "creative", "creative_writing", "cw"
"data" "processing", "data_processing", "dp"

Why ATP?

MCP discovers tools. RAG retrieves chunks. ATP orchestrates entire agent economies.

Capability MCP RAG ATP
Cryptographic Identity - - Ed25519 DID
Trust Scoring - - Time-decayed
Sybil Resistance - - Transitive dampening
Capability Negotiation Basic - 3-phase handshake
Context Compression - Chunk retrieval 28x SCD
Multi-Agent Routing - - 5 patterns
Economic Optimization - - Pareto-optimal
Fault Tolerance - - Circuit breaker
Heartbeat Monitoring - - < 100ms detection
QoS Contracts - - Binding

ATP doesn't replace MCP or RAG — it aims to be the networking layer they lack. Think of the difference between an app (MCP/RAG) and the network protocol it would run on (ATP).

Positioning note: the comparison table is about design scope, not a claim that ATP is a drop-in replacement or more mature than MCP. MCP is a shipping, widely-adopted standard; ATP is an early prototype exploring an adjacent layer.


Status — what's real

Being explicit so you can calibrate before reading the code:

Real and tested today

  • Five layers implemented as independent crates, ~37k lines of Rust, 280 passing tests, zero clippy warnings
  • One-line SDK (atp_sdk::route("coding")) with both print and typed-return APIs
  • Ed25519 DID identity, time-decayed trust scoring, Sybil dampening (L1)
  • 3-phase capability handshake (L2), SCD compression (L3), Bellman-Ford routing (L4), circuit-breaker fault tolerance (L5)
  • Protobuf/gRPC service definitions for all layers

Prototype / not production

  • Benchmarks run in atp-sim with synthetic agents and hash-based embeddings — no real LLM calls yet
  • atp-transport (the actual wire protocol server/client) is largely stubbed
  • Python bindings (atp-python) are present but excluded from the default build
  • SCD uses hash-based embeddings as a stand-in for a real embedding model

Top open items (contributions welcome)

  • Wire atp-sim to real agent backends and re-run benchmarks against live LLMs
  • Flesh out atp-transport into a working gRPC server/client
  • Swap hash-based embeddings for a real embedding model in L3


Project Structure

AgentTransportProtocol/
├── Cargo.toml              # Workspace root
├── render.yaml             # Render deployment config
├── proto/atp/v1/           # 8 protobuf definitions
│   ├── common.proto        #   Shared types (TaskType, QoS, Capability)
│   ├── identity.proto      #   DID, trust, interaction proofs
│   ├── handshake.proto     #   SYN/SYN-ACK/ACK messages
│   ├── context.proto       #   Context diffs, embeddings
│   ├── routing.proto       #   Route queries, responses
│   ├── fault.proto         #   Heartbeat, circuit break
│   ├── task.proto          #   Task submission, results
│   └── service.proto       #   gRPC service definition
├── crates/
│   ├── atp-types/          # Core types, traits, error hierarchy
│   ├── atp-proto/          # Generated protobuf + tonic code
│   ├── atp-identity/       # L1: DID, Ed25519, trust, Sybil guard
│   ├── atp-handshake/      # L2: 3-phase capability handshake
│   ├── atp-context/        # L3: SCD compression, cosine similarity
│   ├── atp-routing/        # L4: Bellman-Ford, 5 routing patterns
│   ├── atp-fault/          # L5: Circuit breaker, heartbeat, checkpoint
│   ├── atp-transport/      # gRPC server/client stubs
│   ├── atp-node/           # Composition root (wires all layers)
│   ├── atp-sim/            # Simulation framework (agents, network)
│   ├── atp-bench/          # AgentNet-Bench CLI
│   ├── atp-sdk/            # Public facade — dead-simple API
│   └── atp-python/         # Python bindings (PyO3) [excluded]
└── website/
    └── index.html          # Marketing site with interactive playground

Building from Source

Prerequisites

  • Rust 1.75+ (rustup install stable)
  • Protobuf compiler (brew install protobuf or apt install protobuf-compiler)

Build & Test

git clone https://github.com/rajamohan1950/AgentTransportProtocol.git
cd AgentTransportProtocol

export PROTOC=$(which protoc)

cargo build --workspace          # Build all 12 crates
cargo test --workspace           # Run all 280 tests
cargo clippy --workspace         # Zero warnings

# Run benchmark
cargo run --release -p atp-bench -- --agents 50 --tasks 10000 --seed 42

# Output formats
cargo run --release -p atp-bench -- --output json   # JSON output
cargo run --release -p atp-bench -- --output csv    # CSV output

# Single scenario
cargo run --release -p atp-bench -- --scenario atp

Python SDK

pip install maturin
cd crates/atp-python
maturin develop --release
python -c "import atp; atp.benchmark()"

gRPC Service

ATP defines a full gRPC service for networked agent communication:

service AtpService {
  rpc Probe(CapabilityProbe) returns (CapabilityOffer);         // L2 handshake
  rpc AcceptContract(ContractAccept) returns (ContractAck);     // L2 QoS
  rpc SubmitTask(TaskSubmit) returns (TaskAck);                 // Task lifecycle
  rpc StreamResults(TaskQuery) returns (stream TaskResult);     // Streaming results
  rpc RequestContext(ContextRequest) returns (ContextResponse); // L3 context
  rpc QueryRoute(RouteQuery) returns (RouteResponse);           // L4 routing
  rpc SendHeartbeat(Heartbeat) returns (HeartbeatAck);          // L5 heartbeat
  rpc ReportCircuitBreak(CircuitBreak) returns (CircuitBreakAck); // L5 circuit break
  rpc SubmitInteractionProof(InteractionProof) returns (ProofAck); // L1 trust
}

Contributing

Contributions welcome! Areas of interest:

  • Wire protocol: Flesh out atp-transport with full gRPC server/client
  • Python SDK: Expand PyO3 bindings for all layers
  • Integration tests: Cross-layer end-to-end scenarios
  • Benchmarks: Real-world agent workloads and comparisons
  • Documentation: More examples, tutorials, and guides

License

Dual licensed under MIT and Apache 2.0 — choose whichever you prefer.


Author

Rajamohan JabbalaAlphaForge AI Labs


280 tests • ~37,000 lines of Rust • Zero dependencies for users • Built with Rust 🦀

About

Agent Transport Protocol — The TCP/IP of AI Agents. Five-layer protocol stack for trust-aware, economically-optimal multi-agent networking.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors