Design Trade-offs and Implementation of Agent Communication Protocols

    This article examines why standard HTTP semantics fall short for AI agent communication and presents a practical five-layer reference protocol. It covers four core gaps—repeated schema information, missing agent identity, semantics pushed into prompts, and inconsistent streaming and error handling—along with key mechanisms such as structural description caching, semantic metadata, delegation chains, and unified cancellation models. Readers will also find guidance on compatibility, migration, reproducible evaluation, observability, and open questions for community feedback.

    1. Where the Tokens Go When You Put an LLM Behind an API

    Once you connect a large language model to a conventional HTTP API, an easily overlooked cost appears: responses carry a large amount of repeated field names and structural descriptions that are fed back into the model context over and over.

    Take a typical paginated list endpoint. Every record repeats the same set of keys. By the first page, the model has effectively “learned” this structure, yet traditional HTTP and JSON have no semantics for “you already know this.” The bytes are still sent, the tokenizer still splits them, and you still pay for them.

    In schema-heavy scenarios such as product catalogs, financial transaction records, and content feeds, this structural duplication can account for a significant share of response tokens. The exact proportion depends heavily on the workload, so any absolute number detached from a workload profile is not universally applicable. A more reliable approach is to establish a reproducible evaluation methodology rather than cite a single conclusion.

    Repeated transmission alone was not enough to justify designing a protocol from scratch. What actually pushed us to abstract the problem into a general protocol question was the growing list of issues below.

    2. Four Fundamental Gaps: Why Generic HTTP Semantics Are Not Enough

    2.1 Structural Information Is Repeated with Every Record

    Traditional pagination and batch queries bind field names to each record. Projection-based approaches can reduce unused fields, but field names still appear record by record. For endpoints with many columns and large row counts, this overhead scales linearly.

    2.2 No Standard Place for Agent Identity

    Existing transport-layer authentication is designed mainly for humans or for services “disguised as humans.” When an agent makes a call on behalf of a user, the server has no standardized way at the protocol layer to determine who issued it, what permission scopes it was granted, whether it has been revoked, and what its validity period and delegation depth are. The common practice is to carry a token and parse it at the gateway, but implementations vary across teams, creating problems for interoperability and auditing.

    2.3 Semantics Are Pushed Down to the Prompt

    After an API returns structured data, the meaning of fields, enum values, time formats, units, and null-value conventions often have to be guessed by the model. Teams end up stacking long system prompts to “explain the fields,” which is both unstable and hard to reuse.

    2.4 Inconsistent Streaming, Cancellation, and Error Semantics

    Agent interactions are long-lived, interruptible, and multi-turn. When to emit intermediate states, how to express “partial success,” how to reclaim resources after cancellation, and how to distinguish retryable from non-retryable errors all lack consistent conventions in generic API semantics. As a result, clients have to write a large amount of special-case handling.

    3. A Layered Design: A Pragmatic Five-Layer Reference Model

    To avoid “cramming everything into one layer,” we split the capabilities into five layers, each with a single responsibility and the ability to evolve independently.

    • Transport layer: Reuses mature connection and streaming capabilities. It handles framing, heartbeats, and reconnection, and carries no business semantics.
    • Session layer: Defines session establishment, multi-turn context references, cancellation and timeouts, backpressure, and priority.
    • Description layer: Delivers structural descriptions and semantic metadata in a “negotiate once, reference many times” manner, with support for per-session caching.
    • Invocation layer: Defines request intent, idempotency keys, pagination cursors, and the expression of batch operations and partial success.
    • Identity and policy layer: Carries the agent’s issuance information, permission scopes, delegation chain, and revocation status for unified server-side decisions.

    The key benefit of this layering is that structural descriptions and semantic metadata can be cached and reused, identity decisions can be centralized in the policy layer, and the transport layer stays generic. This avoids rebuilding a new set of conventions every time a new business is onboarded.

    4. Key Mechanisms: Making “Say It Once” Actually Work

    Structural Descriptions and Incremental Updates

    On the first interaction, the structure description is sent and assigned an identifier. Subsequent responses carry only the identifier and the data. When the structure changes, an incremental patch is sent instead of a full retransmission. A sketch (pseudocode, illustrating the idea only):

    1. session.open()
    2. desc_id = session.describe(schema, semantics) # first turn only
    3. resp1 = call.invoke(desc_id, page=1) # data carries no field names
    4. resp2 = call.invoke(desc_id, page=2)
    5. session.patch(desc_id, add=["shipped_at"]) # incremental change

    Semantic Metadata and Enum Conventions

    Putting field meanings, units, time formats, and enum mappings in the description layer gives the model and clients a shared “dictionary.” This reduces reliance on long prompts and makes reuse across teams easier.

    Identity, Scope, and Delegation Chain

    The identity and policy layer uses a unified structure to express the issuer, audience, permission scopes, validity period, and delegation depth. The server performs centralized verification and auditing based on it. Example structure:

    1. {
    2. "issuer": "idp",
    3. "subject": "agent:planner-01",
    4. "audience": "catalog-svc",
    5. "scope": ["catalog.read", "order.create"],
    6. "delegation_depth": 1,
    7. "revocation": "https://.../status"
    8. }

    Streaming, Cancellation, and Error Model

    Streaming responses have well-defined frame types (data, progress, error, end). Errors distinguish retryable from non-retryable cases, and resource reclamation after cancellation is specified. Clients therefore no longer need special-case handling for every endpoint.

    5. Compatibility and Migration: Do Not Replace Existing APIs All at Once

    The main adoption risk of a custom protocol lies in ecosystem compatibility. We recommend three parallel paths: first, adapt at the existing gateway by mapping the new semantics to generic API calls; second, provide reference implementations in multiple languages along with conformance test cases to lower the integration cost; third, keep a fallback channel that automatically reverts to the generic mode when the peer does not support the new semantics. During migration, follow the principles of “observable, rollback-capable, and gradually rollable” to avoid a big-bang switch.

    6. Evaluation and Observability: Replace Verbal Conclusions with Reproducible Metrics

    Evaluation should cover four categories of metrics: the share of structural overhead, time to first byte, correctness of resource reclamation on cancellation and retry, and the false-rejection rate of identity verification. For methodology, fix the workload profile and dataset version, and publish the measurement scripts and statistical definitions. On the engineering side, connect call traces, token usage, and protocol-layer events to logging services and monitoring alerts to form a closed loop.

    7. Running It in the Cloud: Filling Engineering Gaps with Generic Capabilities

    Beyond the protocol itself, engineering execution also determines success or failure. You can use a combination of generic cloud products from Baidu AI Cloud to implement the design: use a container platform to host multi-language reference implementations and canary releases; use object storage to store structural descriptions and evaluation datasets; use a message queue for asynchronous tasks and peak shaving; use logging services and monitoring alerts for full-chain observability; and use key management capabilities to host the credentials needed for issuance and revocation. These are all generic capability categories; refer to the official documentation for specific integration details.

    8. Open Questions and a Call for Feedback

    We acknowledge that open questions remain: how to define the invalidation and consistency boundaries of structural description caches; how to converge least privilege for delegation chains in multi-hop scenarios; and who owns the governance of semantic dictionaries during cross-organization interoperability. We welcome feedback from peers who have thought carefully at the protocol layer, especially reproducible evaluation methods and failure cases.