A Five-Layer Protocol for AI Agent Communication: Design and Trade-offs
This article presents a practical five-layer protocol design for AI agent communication, built around four recurring problems in existing transport layers: repeated structural descriptions that inflate token costs, the lack of a place for agent identity, semantics pushed entirely onto the model, and untraceable task state. It explains how transport and framing, schema negotiation, identity and authorization, semantic contracts, and task orchestration each own one of these concerns, along with key design trade-offs, implementation and adoption advice, and open questions that remain unresolved.
1. Where It Started: A Concrete Observation
If you have recently put a large language model behind a REST-style API, you have probably noticed something: a significant share of the tokens the model consumes is not spent “thinking” but re-digesting the same structural description over and over.
A typical paginated list response repeats the same field names in every record and on every page: identifier, name, price, description, category, stock, and so on. The model has already “learned” this set of fields by the first page, but the underlying HTTP/JSON transport has no concept of “you already know this.” The bytes still go out, the tokenizer still processes them, and the bill still comes due.
From rough measurements across several internal workloads, we found that in structure-heavy API scenarios (product catalogs, account transaction records, feeds), the overhead from repeated structural descriptions accounts for roughly 30% to 60% of response-side tokens. This number is strongly workload-dependent: the more fields, the shorter the records, and the finer the pagination, the higher the share. To be clear, this is an engineering observation, not a reproducible formal benchmark. The responsible approach is to publish an evaluation report with a reproducible method in a later stage, rather than throwing out a single number.
That alone was not enough to justify designing a protocol from scratch. What actually made up our minds was that the list of “places where current transport makes agents awkward to work with” kept getting longer.
2. Four Recurring Problems at the Transport Layer
2.1 Structural descriptions are transmitted with every record
This is the most direct cost problem. Projection-based approaches help to some degree (fetch only the fields you need), but field names still travel with every record. For APIs with small records and many fields, structural overhead can even exceed the size of the data itself.
2.2 Agent identity has no place in the protocol layer
Existing transport-layer authentication was designed for “humans” or “services pretending to be humans.” When an agent calls an API on behalf of a user, the server has difficulty asking directly at the protocol level: who issued this agent? What is its permission scope? Has it been revoked? The common practice today is to stuff a token into a request header and hope the gateway can parse it. It works, but every team reinvents the wheel, each looks a little different from the others, and auditing and accountability become difficult as a result.
2.3 The semantic layer is pushed entirely onto the agent
APIs return structured data, but the meaning of the fields is left for the model to figure out. In practice, this forces teams to pile up prompts telling the model that a certain time field is a timestamp or that a certain status code means “shipped.” This work happens at inference time and must be redone on every call, which is neither stable nor economical. Semantics should be part of the API contract, not temporary memory on the caller side.
2.4 Task state is hard to track across a single workflow
In real business scenarios, one user request often maps to multiple rounds of tool calls, retries, and parallel branches. The current request-response model is stateless and single-turn, lacking task identifiers, causal chains, idempotency keys, and progress semantics. Troubleshooting therefore relies on stitching together logs, making链路 reconstruction costly.
3. How the Five Layers Are Divided
Our approach is to split the communication problem by responsibility, with each layer solving one class of problem and allowed to evolve independently. The point of layering is not to look nice, but to give cost, identity, semantics, and state each a clear home.
- Layer 1, transport and framing: handles connection reuse, message boundaries, compression, and flow control, and hides differences in the underlying link.
- Layer 2, schema negotiation: exchanges structural descriptions once within a session, then sends only data and schema references, avoiding repetition.
- Layer 3, identity and authorization: makes the issuer, permission scope, revocation status, and representation relationship first-class citizens.
- Layer 4, semantic contract: delivers field meanings, units, enumerations, and constraints with the contract, so they can be cached and validated.
- Layer 5, task and orchestration: provides task identifiers, causal chains, idempotency, progress, and compensation to support multi-turn and parallel execution.
One natural benefit of layering is that schema negotiation and semantic contracts can be cached, identity verification can happen at the edge, and the task layer can handle retries and compensation on its own, without the layers interfering with one another.
4. Key Design Trade-offs
Schema negotiation: replace repetition with references
The idea is similar to “state it once, then just say which item.” A structural description is exchanged once when the session is established and assigned a short identifier; subsequent messages carry only the identifier and the data. A sketch (pseudocode, conceptual only):
# First exchange in a session: negotiate the schema-> { "op": "schema.declare", "id": 7,"fields": ["id","name","price","status"] }<- { "op": "schema.ok", "id": 7, "ttl": 3600 }# Subsequent messages: only data and a reference<- { "op": "data", "schema": 7,"rows": [[1,"A",9.9,2],[2,"B",19.9,2]] }
The key points: schema identifiers need a lifecycle and an invalidation policy; negotiation results should be cacheable but must support active invalidation; when compression and schema reuse are combined, the order must be defined clearly so the gains do not cancel each other out.
Identity: write the representation relationship into the protocol
When an agent acts on behalf of a user, identity is not a single subject but a chain: issuer, agent, and the user being represented. The protocol layer needs to express this chain and support permission scopes and revocation lookups. In engineering terms, mature token and key systems are usually reused, but the representation relationship and queryable revocation are made standard fields rather than team-specific customizations.
Semantics: contracts travel with the data and can be validated
Writing units, enumerations, and constraints into the contract means callers can cache them instead of patching things up with prompts every time. There is an additional benefit: the server can validate against the contract at the entry point and surface errors early at the protocol layer, rather than waiting for the model to fail during inference.
Tasks: give every business action an identity
Assign a task identifier and an idempotency key to a business action, and record the causal chain and progress. Failed retries will not cause duplicate side effects, and troubleshooting can reconstruct the entire chain by identifier. Parallel branches are expressed through parent-child relationships, and compensation logic lives in the task layer rather than being scattered across business code.
5. Reference Implementation and Adoption Advice
The value of a multi-language reference implementation is not “completeness” but semantic consistency: the same contract behaves identically across languages, with shared test vectors, so each language does not interpret things on its own. A few plain principles are recommended for adoption:
- Start with a pilot on non-critical paths, use real traffic to validate the gains from schema reuse, then expand gradually.
- Declare protocol versions explicitly and keep a graceful degradation path, so old and new implementations do not deadlock each other.
- Build observability in: task identifiers, schema hit rate, and contract validation failure rate should be first-class metrics.
- Put security and compliance first: the identity chain, permission scopes, and revocation mechanism must be in place in the first version, not added later.
- Work with general cloud capabilities: configuration and contracts can be distributed through configuration management services, tracing can connect to logging services and monitoring alerts, and load testing and canary releases can leverage the orchestration capabilities of container platforms, rather than building everything in-house.
6. Open Questions We Have Not Figured Out
To be honest, a few things remain unsettled:
- Whether schema negotiation still pays off in extremely short sessions (a single question and answer) needs conclusions broken down by session length.
- Where the “authoritative source” of semantic contracts should sit: defined by the server, generated by a middle layer, or maintained jointly by the ecosystem, each with its own trade-offs.
- The boundary between the task layer and business orchestration engines, which is prone to duplicated effort.
- The upper limit on identity chain length and the rules for trust propagation when multiple agents call one another, where consensus is still lacking.
- Interoperability with the existing ecosystem: how to gain partial benefits through an adapter layer without shipping a new protocol.
7. Summary
Starting from the small entry point of “repeated structures eating tokens,” we arrived at a communication protocol layered by responsibility: transport and framing, schema negotiation, identity and authorization, semantic contracts, and task orchestration. It is not mysterious, nor does it claim to have done everything right, but it puts the cost, identity, and semantics problems in agent communication that are most easily overlooked at the protocol layer, giving them a clear home and an evolution path. If you have also thought seriously about agent traffic at the protocol layer, welcome to join the discussion with reproducible data, especially on the parts we have not figured out yet.
