Designing Agent Communication Protocols: Trade-offs and Implementation Lessons
This article examines the structural overhead that appears when large language model agents interact with standard web APIs, and why repeated schema descriptions, missing agent identity standards, deferred semantics, and inconsistent error handling push teams to rethink their communication layer. It outlines a layered protocol approach, a practical strategy for backward compatibility and observability, and the open questions that remain unresolved.
1. Where the Problem Starts: A Structural Cost Paid Over and Over
Once you connect a large language model to a set of web APIs, most teams notice the same thing: a sizable share of the context window is consumed by structure descriptions that keep repeating. A typical paginated list response carries the same field names in every record and on every page — identifier, name, price, description, category, stock. The model has already “learned” the shape on page one, but the transport layer has no concept of “you already know this”: the bytes still go over the wire, the tokenizer still splits them, and the bill is still calculated.
This overhead is especially visible on structure-dense endpoints such as product catalogs, transaction ledgers, and content feeds. The exact ratio depends heavily on the workload, and any single number quoted without a workload profile is not generalizable. The safer approach is to build a reproducible measurement method on your own traffic first: fix a sampling window, record input and output token counts, separate first requests from subsequent ones, and only then judge whether the optimization is worth the investment.
A single-point cost is not enough to justify rebuilding an entire communication layer. What actually pushes teams to reconsider is the moment they write down every way the current HTTP calling style makes agents uncomfortable — and watch that list keep growing.
2. Four Recurring Low-Level Problems
2.1 Structure descriptions travel with every record
Field-selection query syntax can trim unused fields, but the field names still ride along with each record. Structural information should be negotiated once per session or per task; in practice it degrades into record-level redundancy.
2.2 No standard place for agent identity
Existing web authentication mechanisms are built mainly for human users or for server-side callers impersonating humans. When an agent makes a call on behalf of a user, the server struggles to answer three questions at the protocol level: who issued the credential, which permission scopes were granted, and whether it has been revoked. The common workaround today is to carry a token and parse it at the gateway. It works, but every team reinvents the wheel, implementations differ in shape, and audit criteria are hard to unify.
2.3 The semantic layer is pushed entirely onto inference
Once an API returns structured data, the model has to infer what the fields mean on its own. So prompts accumulate explanations: the unit of a given timestamp field, the business stage a status code maps to, the currency and precision of an amount field. These explanations get “told again” on every call, which both consumes context and tends to drift between calls.
2.4 Error and retry semantics are inconsistent
Services express failure very differently: some use status codes, some use flags in the response body, and some mix retryable and non-retryable conditions together. Agents therefore struggle to make stable decisions — retrying errors that will never succeed, or giving up on transient blips that were worth retrying.
3. A Layered Protocol Design
The workable direction is not to replace the transport layer, but to add an agent-facing communication convention on top of it, organized by responsibility, with each layer doing one thing.
- Session layer: establish the call context, negotiate the structure description and semantic dictionary once, then reference their identifiers afterward.
- Identity layer: express agent identity, delegation relationships, permission scopes, and revocation status through verifiable credentials.
- Semantic layer: provide machine-readable meaning, units, enum mappings, and value constraints for fields.
- Representation layer: replace repeated structure with compact references after the first transmission to cut redundancy.
- Error layer: unify retryability, backoff guidance, and error classification so agents can decide directly.
Illustrative structure negotiation and referencing (pseudocode, conveying the layering idea only):
# 1) Session setup: structure is negotiated oncePOST /agent-session{"schema_id": "catalog.item.v1","fields": ["id", "name", "price", "currency", "status"],"semantics_ref": "dict.commerce.v1"}# 2) Subsequent requests: reference only, no repeated descriptionGET /catalog/items?page=2Headers: Authorization: <agent-credential>X-Schema-Ref: catalog.item.v1# 3) Response: compact representation + explicit error classification{"ref": "catalog.item.v1","rows": [["i-1", "A", 19.9, "CNY", 2]],"error": null}
The identity layer needs to make the delegation relationship explicit — which principal the agent acts for — and how permission scopes are verified by the server. This should follow the widely accepted principles of least privilege and revocability, and avoid handing long-lived, high-privilege credentials directly to the inference side.
4. Compatibility, Evolution, and Observability
The biggest risk with a new protocol is not a design flaw but adoption resistance. The pragmatic strategy is to run both in parallel: keep general HTTP semantics on the outside, carry compact representation and semantic references on the inside, and use content negotiation to decide which mode applies, so callers that have not upgraded behave exactly as before.
Observability has to be built at the same time, covering at least three categories of metrics: share of structural redundancy, identity verification failure rate, and the distribution of error classes along with retry amplification. Without a baseline you cannot prove an optimization works, and you cannot quickly localize a regression when one appears.
On governance, an explicit versioning policy is advisable: version structure and semantic dictionaries independently, allow fields to be appended but never allow meanings to change silently; mark deprecated fields first, observe call distribution, then retire them.
5. Open Questions
Labeling uncertainty honestly is more valuable than claiming everything is solved. At least three points still need validation: the isolation boundary of compact references under multi-tenant caching; the trusted source of semantic dictionaries and how conflicts get resolved; and viable paths for identity mutual recognition across organizations. If you have already dealt with agent traffic seriously at the protocol level, feedback from three angles would be welcome: measurement methods, failure modes, and governance experience.
