AI Agent Collaboration Architecture: Protocol Layer Optimization Practices

    This article examines the hidden token waste in LLM-to-API integrations and the four recurring protocol-level problems behind it: repeated schema definitions, missing agent identity, semantics pushed into prompts, and inconsistent error handling. It proposes a three-layer agent collaboration architecture (planning, execution, protocol) and details four protocol optimizations, followed by a practical deployment checklist and open questions. Readers will learn how to measure structural redundancy in their own workloads and design a more efficient, auditable protocol layer.

    1. Where the Problem Starts: Hidden Waste in the Token Bill

    After connecting a large language model to a set of backend APIs, most teams observe the same thing: only a portion of tokens go toward actual reasoning, while a significant share of the budget is consumed by repeatedly parsing the same structural definitions.

    Take a typical paginated list response. Every row repeats the same field names: ID, name, price, description, category, stock, and so on. The model has already “learned” this structure from the first record, but the transport layer has no concept of “you already know this.” The bytes still go over the wire, the tokenizer still chews through them, and you still get billed.

    In our sampling of several internal workloads, the overhead from structural repetition accounted for 30% to 60% of total response tokens on structure-heavy APIs (product catalogs, transaction records, feeds). This number is strongly dependent on workload shape and should not be treated as a general conclusion. The right approach is to run a reproducible measurement on your own data rather than quoting someone else’s numbers.

    This alone is not enough to justify building a new protocol. What really made the decision was this: when we listed all the ways a general-purpose request protocol makes agents awkward to work with, the list kept growing.

    2. Four Recurring Low-Level Problems

    2.1 Structural definitions are transmitted with every record

    Even with query schemes that fetch fields on demand, field names still travel with every record. What you save is the fields you don’t want; what you can’t save is the names of the fields you do want.

    2.2 Nowhere to put agent identity

    General-purpose request authentication was originally designed for human users, or for “services pretending to be human.” When a model makes a call on behalf of an end user, the server side cannot naturally ask four questions at the protocol level: Who issued this executor? What is its permission scope? Has it been revoked? Which real principal does this call represent?

    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 is reinventing the same wheel, each in a different shape, making unified audit and rate-limiting policies hard to enforce.

    2.3 The semantic layer is entirely left for the model to guess

    APIs return structured data, but the meaning of fields must be inferred by the model on the spot. As a result, the system prompt keeps growing: this field is a timestamp, this enum value means “shipped,” this amount is in minor currency units. This explanatory work happens at inference time and is redone on every call, which is both unstable and expensive.

    2.4 Error semantics and retry semantics are not unified

    Different services express “retryable,” “needs human intervention,” and “parameter expired” in vastly different ways. The model can only learn by trial and error, causing the same class of failure to behave completely differently across tools.

    3. From “Gluing Two Tools Together” to “Designing a Collaboration Layer”

    A common naive idea in the community is to directly bolt together an agent good at conversation and task planning with a runtime good at execution and tool orchestration. The direction is right, but direct assembly usually yields only demo-grade results, for three reasons:

    • Their context budgets squeeze each other; long tool results push conversation history out of the window.
    • Their failure-handling strategies conflict: one tends to retry, the other tends to give up immediately.
    • Their permission models don’t compose; where permissions are amplified becomes an attack surface.

    A more robust approach is to abstract the problem into three responsibilities of an “agent collaboration layer”:

    1. Planning layer: responsible for task decomposition, tool selection, and termination decisions; handles only summaries and decisions.
    2. Execution layer: responsible for actual calls, timeout control, idempotency keys, retries, and circuit breaking.
    3. Protocol layer: responsible for structure description, identity declaration, semantic annotation, and error classification.

    The three layers communicate through stable contracts, so replacing the implementation of any one layer does not affect the other two.

    4. Four Optimization Directions for the Protocol Layer

    Direction 1: Send the structural definition only once

    Negotiate the structure once within a session or task lifecycle; subsequent responses carry only data and a structure reference ID. Illustration:

    1. Interaction 1
    2. { "schema_id": "s_17", "schema": {...}, "rows": [...] }
    3. Interactions 2..N
    4. { "schema_id": "s_17", "rows": [[...], [...]] }

    Three engineering points to note: the schema ID needs versioning and an invalidation policy; the cache key must include the permission context to avoid unauthorized reads of fields visible to others; once the field set changes, you must explicitly switch to a new ID rather than letting it drift in place.

    Direction 2: Write executor identity into the protocol

    Requests should carry a verifiable executor declaration covering at least: issuer, permission scope, the actual principal represented, validity period, and revocation lookup method. The server side performs unified validation based on this, rather than each team parsing request headers on its own. In implementation, you can reuse general-purpose token and signature mechanisms and write validation results into unified log fields for easier auditing and rate limiting.

    Direction 3: Deliver semantics along with the structure

    Field descriptions, units, enum meanings, and nullability should all be provided once during the structure negotiation phase, rather than stuffed into a prompt that must be replayed every time. This saves tokens and keeps different models’ understanding of the same API consistent.

    Direction 4: Standardize error classification

    It is recommended to converge errors into four categories: retryable (with suggested backoff), needs parameter correction, insufficient permissions, and service unavailable. The execution layer decides its strategy based on this, and the planning layer decides whether to switch paths.

    1. {
    2. "code": "retryable",
    3. "retry_after_ms": 800,
    4. "hint": "Upstream rate limited; exponential backoff recommended",
    5. "trace_id": "..."
    6. }

    5. Deployment Checklist

    • Have you measured the proportion of structural repetition in your own workloads, with a reproducible measurement script?
    • Are tool results summarized and truncated to avoid crowding out the conversation window?
    • Do all write operations carry an idempotency key so retries don’t cause duplicate side effects?
    • Is executor identity verifiable, revocable, and auditable?
    • Have semantic descriptions been moved out of the prompt and into structure negotiation?
    • Have you set a per-task cost ceiling and timeout circuit breaker?
    • Do you validate tool return values as input, to guard against injected instructions in external content?

    6. What’s Not Yet Figured Out

    Honestly, a few things have no consensus yet: how to define the synchronization delay between schema caching and permission changes; how to align semantic dictionaries in cross-organization scenarios; how to express responsibility attribution in logs when multiple agents call each other. These all need continued validation under real traffic.

    If you have also thought seriously about the shape of agent traffic at the protocol layer, let’s start the discussion from “reproducible measurement methods” — that is more valuable than arguing over a particular number. If you are already using general capabilities from a cloud provider, such as container platforms, message queues, logging services, and monitoring/alerting, to carry the three layers above, you can also connect protocol-layer observability metrics directly into your existing alerting system to form a closed loop.