Designing an Agent Communication Protocol Layer: Combining Multiple AI Agent Frameworks
Combining conversational AI agent frameworks with automation-focused ones sounds simple, but direct integration often fails—not because either framework is incomplete, but because they make different assumptions about communication, state, and identity. This article examines four structural mismatches that arise when connecting LLMs to REST APIs—redundant schema transmission, missing protocol-level agent identity, semantics pushed to inference time, and costly error recovery—and proposes a dedicated protocol layer with schema references, first-class agent identity, semantic metadata, and structured error semantics. It also outlines an adapter-based implementation and open questions around standardization, caching, and security boundaries.
1. Starting from a Common Integration Need
In the AI agent community, a recurring question comes up: one conversational agent framework excels at multi-turn interaction and task planning, while another automation framework excels at browser operations and workflow orchestration—can you combine them, letting the “thinker” and the “doer” each play to their strengths?
The idea is fundamentally sound. Conversational frameworks are good at understanding user intent, decomposing tasks, and maintaining context; automation frameworks are good at interfacing with external environments and executing concrete operations. Their capabilities are naturally complementary. In practice, however, bolting two frameworks together rarely goes smoothly. The problem is not that either framework is “incomplete,” but that each carries different assumptions about communication, state, and identity—and there is no unified protocol layer to bridge them.
In other words, the question isn’t “which framework is better,” but “how do they talk to each other?” This is a direction that deserves more investment than framework selection itself when engineering agents for production.
2. Four Problems We Keep Hitting When Putting an LLM Behind an API
If you’ve worked on connecting large language models to REST APIs, these patterns will feel familiar. They aren’t bugs in any particular framework—they are structural mismatches between the HTTP/JSON communication paradigm (designed for the human browser era) and the agent use case.
2.1 Schema repeated on every transfer—tokens paying for redundancy
Take a typical paginated API, such as a product listing query. Every page and every record repeats the same field names: id, name, price, description… The model already understands this structure the first time it sees a response, but HTTP/JSON has no concept of “you already know this”—the bytes go out, and the tokens burn.
On schema-heavy APIs (catalogs, ledgers, feeds), repeated field structures typically account for 30–50% of total response tokens. GraphQL lets you fetch only the fields you need, which helps somewhat, but field names still travel with every record—the structural redundancy remains.
A viable improvement is a “schema reference” mechanism at the protocol layer: send the full definition once, then replace it in subsequent responses with a lightweight reference identifier, resolved through a structure cache shared by the client and the model. This is conceptually similar to the schema registry idea in binary serialization schemes, with one extra consideration—cache friendliness for the LLM context. For example, placing schema definitions in a stable prefix region of the prompt so that prefix caching actually hits.
2.2 Agent identity has no protocol-level home
HTTP’s authentication model was designed for “human users or services acting on behalf of humans.” When an agent calls your API on a user’s behalf, the server can’t easily answer three key questions at the protocol level:
- Who issued this agent? What is the chain of trust?
- What scope of operations is it authorized for?
- Has its authorization been revoked by the user or the platform?
Today’s common practice is stuffing credentials into a Bearer header and hoping the gateway parses it. It works, but every team reinvents the wheel, with inconsistent granularity, revocation mechanisms, and audit logs. The better shape is to define first-class identity fields for “non-human callers” in the protocol itself: issuer, authorization chain, scope set, validity period, and a revocation endpoint—so servers can validate an agent session as standardly as they validate a user session.
2.3 Semantics pushed to inference time
REST APIs return structure, not meaning. Is status: 2 “shipped” or “pending review”? Is created_at in seconds or milliseconds? Today this information is typically supplied via the system prompt—feeding the same field semantics to the model on every inference call.
This wastes tokens and introduces correctness risk: if the prompt misses a field, the model may misinterpret it. Moving semantic descriptions from “prompt engineering at inference time” down into “metadata within the protocol”—giving every field its type, unit, enum meanings, and constraints—is a one-time structural investment that buys determinism on every call.
A simple illustration:
{"field": "status","type": "enum","values": { "1": "ordered", "2": "shipped", "3": "delivered" },"required": true}
2.4 Error recovery is too expensive
When a human developer sees a 500 error, they check logs, read the stack trace, and decide whether to retry. An agent sees only a blob of text with very low information density for it. Which errors are idempotent and retryable? Which are parameter errors requiring a corrected request? Which need escalation to a human? Without structured error classification and recovery guidance, the agent can only guess—and retry storms and pointless calls follow.
3. When Combining Frameworks, the Protocol Layer Matters More Than the Framework Layer
Back to the opening question: can two frameworks be combined? Yes—but the right approach is not writing hard-coded adapters between them. Instead, introduce an explicit communication protocol layer between them that addresses the four problems above:
- Unified message envelope: the two frameworks no longer exchange private-format strings, but structured messages carrying schema references and semantic metadata, sparing the model from repeatedly parsing redundant structures.
- Unified identity propagation: as user intent flows between frameworks, the issuer and authorization scope travel with the message, so downstream executors can verify “is this agent authorized to perform this action?”
- Unified error semantics: one framework’s failure is passed to the other as a structured error code with recovery guidance, letting the upper-level agent make rational decisions instead of blind retries.
In implementation terms, an adapter pattern works well: build a thin protocol adapter for each framework, convert protocol messages in between, and leave each framework’s internal logic untouched. This keeps the combination pluggable—if you swap out either framework later, the protocol layer doesn’t need to be rewritten.
4. Open Questions
To be candid, several open questions remain:
- Who drives standardization: Agent communication protocols are currently in a “let a hundred flowers bloom” phase with no de facto standard. Unifying too early may lock in a bad design; unifying too late fragments the ecosystem.
- Coupling between structure caching and model context management: the schema reference mechanism depends on the model maintaining stable memory of prefix content, and different models may behave differently—more real-world testing data is needed.
- Security boundaries: once an agent identity system lands, who operates the issuance and revocation infrastructure, and how it is audited, involves more than just technical questions.
Conclusion
“Glue two frameworks together” is a good instinct, but it’s worth abstracting into a more general engineering proposition: agents—whether talking to each other or to services—need a communication protocol designed for non-human callers. Pushing schema, identity, semantics, and errors from the application layer down to the protocol layer means that whatever framework combination you ultimately choose, your system will consume fewer tokens, be more controllable, and evolve more easily. If you’ve thought deeply about protocol layers, I’d welcome the exchange—the best designs in this space will come from being tested against real traffic.
