Designing a Five-Layer Wire Protocol for AI Agent Communication

    This article presents a practical design for a five-layer wire protocol built for AI agent traffic. It explains why traditional HTTP/JSON becomes costly in agent scenarios, covering repeated schema fields, missing agent identity at the protocol layer, semantic context pushed into prompts, and fragmented observability. The core of the article walks through the five layers—bytes and framing, schema and dictionary, identity and authorization, semantics and capability declarations, and session and orchestration—along with key tradeoffs around compatibility, caching, and security. It closes with engineering rollout advice and open questions for further peer feedback.

    1. The Starting Point: What Actually Gets Wasted When Agents Talk Over HTTP

    When you put a large language model behind a traditional REST interface, the first problem you hit is not “can we make the call work,” but “why is the cost so high once it does work.” Take a typical paginated product query response. It repeats the same field names in every single record: identifier, name, price, description, category, stock. The model already understood this structure on the first page, but traditional HTTP/JSON has no notion of “you already know this.” The field names still ship with every record, the tokenizer still has to process them in full, and the caller still pays for it.

    We ran rough measurements across several internal workloads: in schema-dense interfaces (product catalogs, account transaction logs, information feeds), the overhead from repeated field names accounts for roughly 30% to 60% of response tokens. This range depends heavily on the shape of the workload, so we are not treating it as a conclusion. Instead, we plan to publish a reproducible benchmark report in a later stage so the numbers can be recomputed by third parties.

    What really pushed us to redesign the protocol was the steadily growing list of problems that followed.

    2. Four Underlying Problems: Why HTTP Falls Short for Agents

    2.1 Schema Repeated on Every Record

    Field-level redundancy is a wire-format problem, not something the application layer can fully solve. Query-projection approaches can fetch only the fields you need, but the field names still appear record by record. For high-frequency, wide-table, deep-pagination interfaces, this cost scales linearly.

    2.2 No Place for Agent Identity at the Protocol Layer

    Traditional authentication is designed for humans or for “services pretending to be humans.” When an agent makes a call on behalf of a user, the server cannot answer three key questions at the protocol layer: who issued this agent, what permission scopes it was granted, and whether its credentials have been revoked. The common approach today is to carry a token header and rely on a gateway to parse it. It works, but every team reinvents the wheel, and the implementations are inconsistent with one another.

    2.3 Semantic Context Pushed to Inference Time

    Interfaces return only structured data, and the meaning of fields has to be inferred by the model itself. As a result, engineering is forced to pile on large amounts of prompt text to explain timestamp formats, the meaning of status code enumerations, units, and precision. These explanations are consumed repeatedly on every inference, while the protocol layer is completely blind to semantics and cannot cache or reuse them.

    2.4 No Unified Observability Across the Call Chain

    Agent calls often span multiple hops: the orchestration layer, the tool layer, the data service layer. Without a unified trace identifier and error semantics, troubleshooting comes down to matching log text and cannot reliably attribute failures.

    3. Layered Design of a Five-Layer Wire Protocol

    We split the protocol into five layers, where each layer solves only one class of problem and layers are decoupled through explicit contracts.

    • Layer 1: Bytes and framing. Handles framing, compression, and checksums, keeping boundaries clear under streaming and half-streaming transmission.
    • Layer 2: Schema and dictionary. Negotiates a field dictionary on the first interaction; subsequent records carry only field indexes and values, eliminating repeated field names at the root.
    • Layer 3: Identity and authorization. Defines how agent credentials are expressed, how permission scopes are declared, and where revocation checks hook in, decoupled from the transport layer.
    • Layer 4: Semantics and capability declarations. Uses cacheable capability descriptions to carry field meanings, enumerations, units, and constraints, avoiding repeated explanation at inference time.
    • Layer 5: Session and orchestration. Maintains multi-turn context, idempotency keys, trace identifiers, and error classification to support observability and retries.

    A schematic wire structure can be abstracted as:

    1. [Frame Header][Dict Id][Identity Ref][Semantic Ref][Payload: idx+value...]

    Here, the dictionary identifier, identity reference, and semantic reference are all cacheable handles. The actual long text appears only during the first negotiation.

    4. Key Design Tradeoffs

    First, the balance between compatibility and efficiency. A new protocol cannot demand that all existing services be reworked, so a gateway-style conversion is needed at the boundary to map traditional responses into a dictionary-based representation and enable gradual migration.

    Second, the balance between caching and consistency. Caching dictionaries and semantic descriptions can significantly cut costs, but versioning and invalidation mechanisms must be designed to avoid the model making wrong judgments based on stale semantics.

    Third, the balance between security and debuggability. Once identity and authorization move into the protocol layer, credential minimization, auditability, and revocability become hard requirements. At the same time, sensitive information must be kept out of trace data that may be retained long-term.

    5. Engineering Rollout Advice

    1. Pilot dictionary-based transmission on schema-dense, high-volume interfaces first, and quantify the gains with a reproducible benchmark.
    2. Move field semantics out of prompts and into versionable capability descriptions to reduce repeated explanation at inference time.
    3. Introduce a unified identity reference and permission scope declaration for agent calls, and connect to unified logging services and monitoring/alerting capability categories.
    4. Define idempotency keys and error classification clearly to keep retries safe.
    5. Keep the reference SDK implementations consistent across languages to lower the integration cost.

    6. Open Questions

    We do not consider the design complete. The overhead of dictionary negotiation under high-concurrency cold starts, interoperability of cross-organization semantic dictionaries, the real-time boundary of identity revocation, and the comparability of benchmarks across different workloads all still need more peer feedback. We welcome developers who have thought seriously about agent traffic at the protocol layer to help fill in these gaps.