Designing a Communication Protocol Layer for AI Agents
When AI agents call business APIs, their traffic patterns differ from traditional browser or microservice requests. Models are highly sensitive to structured data: the same field names repeat across pagination, list responses, and polling. Identity is typically tied to human user accounts, and the protocol layer reveals almost nothing about what kind of agent is calling, what permissions it has, or whether it is still valid. Field semantics get buried in system prompts and must be re-aligned on every inference call. This article abstracts these pain points into protocol-layer problems and discusses how layered communication conventions—without tying into any specific framework or vendor product—can reduce costs and unify identity semantics, while flagging which choices still need community validation.
From a Concrete Observation
When you plug a large language model behind resource-oriented APIs, one thing becomes obvious: a large share of bytes in each response body is repeated key names. Schema-dense endpoints—product catalogs, ledgers, activity feeds—are especially affected. After the first successful parse, the model already knows the field set and approximate types. But conventional text-based payloads carry no notion of “the peer already knows this structure,” so every paginated response and every record still repeats the same identifiers. The result: predictable structural information travels over the wire, the tokenizer chews through it again, and inference costs rise.
This overhead is strongly workload-dependent and cannot be summarized with a single percentage across all scenarios. The rigorous approach is to define the interface type, pagination depth, and field width, then measure the ratio of structural overhead to business payload separately on reproducible benchmarks. Until such a framework matures, the safer claim is: on dense endpoints, structural repetition is often non-negligible—enough to earn a place on the protocol design checklist, but not sufficient on its own to justify rebuilding everything.
What really pushes you toward protocol-layer thinking is listing everything that makes agents awkward to use. The problem then extends beyond transport format into identity, semantic visibility, and cross-language implementation consistency.
Recurring Root Problems
First, structure is bound to instance data. Selecting only the fields you need reduces column count, but every record still carries field names. For a model, structure is cacheable knowledge while data is the new information. If the protocol cannot express “structure has been negotiated,” optimization stalls at compression and prompt engineering.
Second, agent identity has no home in the protocol. Traditional authentication targets human sessions or service accounts: tokens in headers, gateways parse them, and services define their own claim fields. When the caller is an agent acting on behalf of a user, the other side often wants to know more: who issued the agent, what capabilities it has, whether it has been revoked, and whether re-delegation is allowed. If each team invents its own claims, interoperability costs climb quickly, and gateways and audit systems cannot form a unified view.
Third, semantics are left entirely to inference time. Once an API returns untyped objects, the model must rely on prompts to understand timestamp formats, enum values, and state machines. The same explanation consumes context on every call. If the protocol layer exposes no semantics, gateways, SDKs, and observability tooling cannot validate or cache anything, and the burden falls entirely on the model.
Fourth, wire-level consistency across languages and runtimes is easily overlooked. Agent stacks typically mix scripting runtimes, systems-language services, and edge gateways. Without testable encoding rules and error codes—only documentation—you quickly end up with “everyone speaks JSON, but the semantics don’t align.”
A Layered Protocol Abstraction
Communication between agents, and between agents and web services, can be split into layers with clear responsibilities rather than stuffing compression, authentication, semantics, and sessions into a single envelope. A common, vendor-neutral breakdown looks like this:
Negotiation and session layer: Handles capability announcement, structure fingerprints, and session identifiers. The peer can declare “subsequent instances in this session are encoded against structure X,” eliminating repeated key names per record. Structure changes go through explicit renegotiation to avoid silent incompatibility.
Representation layer: Offers switchable payloads between text-friendly and compact encodings. Humans debugging can still use readable formats; high-frequency list calls can use a compact representation with structure references. The key is that encoding rules are public and unambiguous—not tied to a proprietary binary format.
Semantic annotation layer: Turns stable field meanings (time, currency, enums, units, state machines) into machine-verifiable descriptions that are versioned alongside the structure. Agents can cache them after the first fetch; gateways can perform lightweight validation, eliminating the waste of re-explaining “status=2” via prompts every call.
Identity and authorization layer: Carries the agent principal, user delegation relationship, scopes, validity period, and revocation hints in protocol-visible locations. You don’t need to invent new authentication math, but “an agent is not a human browser” should become a standard field rather than a claim format each team rebuilds.
Transport adaptation layer: Runs on existing reliable transports and common gateways to keep adoption costs low. The value of the new protocol family should show up in semantics and structure, not in forcing a replacement of the entire stack.
These layers emphasize “wire-level implementable, cross-language comparable” rather than a concept white paper. Reference implementations should cover multiple languages with the same test vectors, ensuring consistent error codes, version negotiation, and structure fingerprint algorithms. Open-source licensing and versioning strategy are engineering governance matters: changelogs and compatibility commitments should be public, avoiding “verbal compatibility, divergent implementations.”
Engineering Decisions You Must Make
Whether to keep a human-readable fallback. Full compactness saves tokens but makes debugging and packet inspection harder. A safer default: compact by default, with a debug switch back to readable, and the two representations semantically equivalent.
Which algorithm to use for structure fingerprints. Too weak invites collisions; too strong makes negotiation heavy. In practice, hash a normalized structure description, and specify how field ordering, optional fields, and default values enter the fingerprint—otherwise you get “looks the same, hashes differently.”
Where to place identity claims. Headers are convenient for gateway interception; payload-level claims are convenient for end-to-end signing. In hybrid setups, priority must be defined explicitly, or you get gateways trusting headers while services trust the body.
The granularity of semantic descriptions. Too fine and it becomes a second data dictionary that’s hard to maintain; too coarse and the model still has to guess. Fix only stable, cross-endpoint types and enums; leave business-specific cases to application documentation.
Coexistence with existing APIs. Most teams won’t cut traffic over overnight. Content negotiation or independent media types allow gradual adoption: legacy clients keep using traditional payloads while new agent clients declare support for structure references. Gateways route by Accept header, keeping dual-stack logic out of individual services.
Benchmarks and honest boundaries. Any structural overhead ratio must come with methodology: sample endpoints, pagination strategy, tokenizer version, and whether prompt-side schemas are counted. Until a reproducible report exists, internal numbers should not be presented as industry conclusions. Unresolved questions should also be documented—for example, revocation propagation across multi-hop delegation, whether semantic versions and structure versions decouple, and how partial updates reference old structures.
Suggested Adoption Path
Start with a pilot on a schema-dense, frequently called read-only list endpoint, measuring structural repetition ratio and latency changes. Then add structure registration and fingerprint caching at the gateway, with SDKs implementing “fetch the structure once, send only instances afterward.” Align identity fields with your existing token system first, adding only standard claims for agent principal and scope to minimize migration surface. For semantic annotations, begin with the three high-frequency types—timestamps, monetary amounts, and status enums—rather than building a full vocabulary at once.
Observability must keep pace: record structure cache hit rates, negotiation failure reasons, and missing-identity-claim rates. Otherwise protocol optimization becomes a black box. On security, structure registration must be authenticated to prevent malicious structures from exhausting caches, and compact encoding needs length and nesting limits so the parser doesn’t become an attack surface.
Conclusion
The core tension in agent traffic is not “pick yet another calling framework”—it’s that HTTP-style APIs treat structure, identity, and semantics as opaque bytes to the model. With layered, testable, cross-language-consistent wire-level conventions, you can remove repeated structure from the hot path, make agent identity a first-class protocol citizen, and push stable semantics forward into verifiable descriptions. Specific encodings and governance still have open questions, and they should be settled with reproducible benchmarks on real workloads—not replaced by a single vendor’s product narrative. For teams building agent integrations today, clearly defining negotiation, representation, semantics, and identity first will typically deliver more long-term cost savings and interoperability than stacking on more prompt engineering.
