A Five-Layer Protocol Design for AI Agent Communication
This article examines why traditional API communication models fall short for AI agents and proposes a five-layer protocol design covering transport, encoding, structure negotiation, identity and authorization, and semantics. It details the core mechanisms of each layer, outlines a three-phase adoption path, and highlights the engineering risks and open questions that practitioners still need to address.
1. Where the Problem Starts: How Agent Traffic Differs from Human Traffic
For more than a decade, the core assumption behind interface communication has been that one end is a human or a stable service, and the other end is a resource. That assumption starts to break down once agents connect at scale. The most visible symptom is that a significant portion of the context window consumed by a model is spent repeatedly parsing highly similar data.
Take a common paginated list API. Every row carries the full set of field names, and the same field names appear again on the next page. Humans automatically skip the repeated parts, but a model has to receive every byte and re-encode it. On field-heavy interfaces such as directories, transaction records, and feeds, repeated structural descriptions can account for roughly half of the response content. The exact ratio depends heavily on the business context, so any conclusion should rest on reproducible benchmarks rather than a single number.
Repeated transmission is only the surface issue. Listing everything that feels awkward for agents reveals that the problems cluster at four levels.
2. Four Underlying Problems
2.1 Structure Description Is Mixed with Data
Field names, types, and enum meanings share the same channel as the actual data. As a result, structural information cannot be cached or reused and has to be shipped again with every record.
2.2 No Standard Place for Agent Identity
Existing authentication mechanisms were designed for human users or human-like services. When an agent makes a call on behalf of a user, the protocol layer makes it hard for the server to determine directly who issued it, what permission scopes it holds, whether it has been revoked, and which end principal it represents. The common engineering practice is to carry a token and parse it at the gateway, but implementations vary across teams, making mutual recognition costly.
2.3 Semantic Interpretation Is Pushed to Runtime
APIs return structured data but not the meaning of fields. Developers have to write large amounts of domain conventions into prompts, for example that a field is a timestamp or that a status code means shipped. This interpretation work is redone on every inference, remains completely invisible at the protocol layer, and cannot be cached.
2.4 Limited Expressiveness for Errors and Partial Failures
Agent call chains are usually longer, and a single business action may span multiple calls. Traditional status codes are good at expressing single-point success or failure but struggle to describe which step was degraded, which segment is retryable, or whether a missing field affects the conclusion.
3. Trade-offs in a Layered Design
One workable approach to these problems is to split communication capabilities into five layers, from bottom to top: transport, data encoding, structure negotiation, identity and authorization, and semantics and intent.
The key constraint of layering is that each layer solves only one class of problem, and upper layers must not depend on private implementation details of lower layers. The illustrative call logic is as follows:
[L5 Semantic] Field meanings, units, enum dictionaries, intent declarations[L4 Identity] Issuer, permission scopes, revocation status, delegation chain[L3 Structure] Structure fingerprints, field trimming, incremental patches[L2 Encoding] Compact serialization, binary or text optional[L1 Transport] Long-lived connections, streaming, resumable transfer
The core mechanism of the structure negotiation layer is “full payload first, incremental afterward”: the first interaction delivers a structure fingerprint and a field dictionary, and subsequent responses carry only the fingerprint and the diff data. Field names are then shipped only once and can be reused by the model within the session. Note that fingerprints must carry version semantics and be explicitly invalidated when the structure changes; otherwise they introduce silent errors that are hard to troubleshoot.
The identity layer should separate credentials from business parameters. A credential carries the issuer, scopes, validity period, and delegation relationships, so the server can validate it directly at the protocol layer instead of relying on private gateway parsing logic.
The semantic layer delivers dictionaries, units, enums, and state machine descriptions as cacheable metadata. At runtime, only a version number is referenced, which shifts the repeated interpretation cost from inference time to a one-time negotiation phase.
4. Evolution Path and Engineering Recommendations
Replacing all interfaces at once is not advisable. A safer path has three stages:
- Stage one: pilot incremental encoding on read-heavy, structurally stable interfaces, and build reproducible benchmarks to quantify changes in context usage and latency.
- Stage two: introduce a unified agent credential format and validation flow, starting with mutual recognition among internal services and then opening up gradually.
- Stage three: bring semantic dictionaries into the interface governance process, bind them to version management, and deliver them as contracts.
Three types of risk also deserve attention in practice: consistency between caches and fingerprints, the timeliness of credential revocation, and the observability of degraded paths. It is recommended to configure logs, metrics, and alerts for each of these three items to prevent problems from accumulating deep in the call chain.
5. What Remains Unresolved
To be honest, several questions remain open: how to isolate incremental encoding when multiple agents concurrently share a session; how the version compatibility strategy for semantic dictionaries can coexist with long-lived interfaces; and who maintains the trust anchor for credential mutual recognition in cross-organization scenarios. These require feedback from practitioners working at the protocol layer rather than a unilateral definition.
Overall, optimizing communication for agents is not about replacing an existing solution but about filling three gaps: structure reuse, verifiable identity, and negotiable semantics. Advancing incrementally through layering, together with a reproducible measurement system, is the controllable engineering path.
