How AI Agent Frameworks Work Together: From Integration to Communication Protocol Design
Combining an agent framework that excels at reasoning and planning with one that excels at tool execution and task orchestration is a natural engineering direction—but making them "call each other" is not the same as making them cooperate reliably. This article examines the real problems that emerge when two agent frameworks are integrated, including duplicated context, ambiguous delegation, uninterpretable responses, and inconsistent task state. It covers how to define responsibility boundaries between the reasoning and execution sides, when structure negotiation is worth the cost, how to express delegation beyond simple authentication, and how to organize communication design into five logical layers. It concludes with a practical evaluation methodology and an incremental integration path that prioritizes security, observability, and correctness before optimization gains.
1. What Problem Does Combining Two Agent Frameworks Actually Solve?
Pairing an agent framework that is good at reasoning, planning, and conversation with another that is good at tool invocation, task scheduling, and environment interaction is a natural engineering direction. The former understands goals, decomposes tasks, and chooses the next action; the latter connects to business systems, executes operations, and manages runtime state.
But “the two frameworks can call each other” does not mean “the two frameworks can collaborate stably.”
The simplest integration approach is to wrap the execution framework’s capabilities as a set of interfaces that the reasoning framework calls. This works well for validating a concept, but tends to expose problems at scale:
- The same data structures appear repeatedly across calls, consuming model context.
- Requests carry access credentials but do not clearly express who the agent acts for or what it is allowed to do.
- Return values have syntactic structure, but their business meaning still depends on prompt-based interpretation.
- After a network timeout, the caller cannot tell whether the operation was not executed at all, or was executed but the response was lost.
- Both frameworks maintain task state, leading to inconsistencies between plans, execution results, and recovery records.
Therefore, the core of integration work is not gluing two runtimes together, but clarifying responsibility boundaries and establishing a communication contract both sides understand.
2. Define Responsibilities First, Avoid Two Competing “Brains”
1. The Reasoning Side Decides, the Execution Side Acts Under Control
A manageable division of labor is:
The reasoning side maintains the user’s goal, the current plan, and the necessary decision context; the execution side manages tool connections, permission checks, operation execution, and execution state.
The reasoning side can propose action intents such as “check inventory” or “submit an order,” but cannot bypass the execution side’s authorization checks through natural language. The execution side should return facts, status, and errors, and should not change the user’s goal on its own without an explicit agreement.
This division does not mean the execution side cannot reason at all—it means every category of decision has a clear owner. Otherwise, the same task may be decomposed repeatedly by both sides, causing duplicate calls, state conflicts, and unpredictable behavior.
2. State Must Have a Clear Authoritative Source
Different states can be owned by different components, but the same piece of critical state should not have multiple independent authoritative sources.
For example:
- Task goals and plan versions are managed by the task coordination component.
- Whether an external operation succeeded is determined by execution records and business system state.
- Permissions and revocation status are maintained by the authorization system.
- Data structure versions are managed by the interface contract mechanism.
The reasoning framework may cache this information, but the cache should not automatically become the source of truth. Especially during retries, recovery, or human intervention, authoritative state must be re-verified rather than relying on the model’s memory of past conversation.
3. The Cost of Repeated Structure: Identify Which Layer It Occurs At
Business interfaces often return data as lists of objects. Every record—products, orders, or ledger entries—carries the same set of field names. For a generic client, this representation is intuitive, self-contained, and easy to debug. For an agent that needs to feed large volumes of results into model context, however, it can create extra overhead.
That said, not all repeated fields should be treated as wasted cost.
Field names carry explanatory value and reduce model misinterpretation. The more compact the structure, the more it depends on additional structural descriptions. What should actually be optimized is “information that is repeated but adds no understanding value,” not simply the shortest possible text.
Three layers need to be distinguished:
- Network transport layer: compression reduces transmitted bytes.
- Application decoding layer: the client reconstructs data into internal objects.
- Model input layer: what is ultimately submitted to the model determines context consumption.
If the network uses a compact format but the application expands it back into a full object list before feeding the model, network traffic may drop while model input stays the same length. When evaluating optimization, you must observe the final model input, not just the response body size.
4. Structure Negotiation: Share Interpretation Rules Between Both Sides
1. Moderately Separate Structure Definitions from Data Instances
For stable, repetitive, high-volume data, consider providing a structure description first, then returning data organized according to that structure.
Below is an illustrative message structure—it does not represent any existing protocol or formal interface:
Structure description:Structure ID: product-summaryStructure version: 1Field order:product_idproduct_nameunit_priceavailable_stockUnit price unit: CNYData:[101, "Sample Product A", 29.50, 12][102, "Sample Product B", 45.00, 8]
This representation avoids repeating field names in every row, but increases dependence on field order and structure versions.
It is therefore better suited to batch queries with stable structures, and not necessarily suitable for heterogeneous results with widely varying fields. For small responses, the full-object form may actually be easier to understand and lower in overall cost.
2. Structure Caches Must Be Verifiable, Not “The Model Should Remember”
The fact that a model has seen a structure definition does not mean it can still accurately access that information in later calls. Context trimming, task switching, and session recovery can all cause structure descriptions to be lost.
Structure caches should be managed by the application and record:
- Structure ID and version.
- Applicable interfaces and scope of validity.
- Integrity check information for the structure content.
- Whether the current model input contains the necessary explanation.
- A renegotiation strategy for structure inconsistencies.
Only when the application confirms the interpretation information is available should compact data be sent. If a version mismatch or missing cache is detected, the structure definition should be re-provided, falling back to a more self-describing format when necessary.
3. Handle Structure Changes Conservatively
Field additions, deletions, reordering, and type changes can all affect the correctness of compact representations.
For positionally encoded data in particular, if field order changes and the receiver is not updated in sync, the result may be syntactically valid but semantically wrong. This kind of error is more dangerous than an outright parsing failure.
Therefore, structure changes should be brought under version management with explicit compatibility rules. Do not sacrifice the reliability of data interpretation for a small context saving.
5. Beyond Authentication: Express Delegation Relationships
When an agent calls a business service, at least three distinct questions are involved:
- Who is the current caller?
- Which user or organization does it act for?
- Which actions is it allowed to perform?
Common request authentication mechanisms are not unusable for agents. The real gap is usually that systems express proxy identity, user delegation, authorization scope, and revocation conditions inconsistently.
1. Distinguish Runtime Identity from Business Authorization
Runtime identity proves that a request comes from a recognized agent instance or service; business authorization determines whether that instance may perform the current operation.
The two must not be conflated. An authenticated agent should not thereby gain all of a user’s permissions.
Authorization checks should combine operation type, resource scope, invocation target, and necessary environmental conditions. For example, permission to read a project’s data should not naturally extend to modifying that project’s configuration.
2. Apply Independent Controls to High-Risk Operations
The risk of a read differs from a write, and the risk of a write differs from an irreversible operation.
Operations involving money, deletion, external publishing, or permission changes can require stricter approval, secondary confirmation, or explicit user authorization. The relevant checks should be enforced at the execution boundary, not merely written into prompts.
Prompts can guide behavior but are not a reliable access control mechanism. Even if reasoning is misled by external content, the execution side should still refuse operations beyond the authorized scope.
3. Support Revocation, and Keep Credentials Out of Model Context
Long-running tasks need to account for authorization expiry and active revocation. Valid authorization at task start does not guarantee that an operation hours later is still permitted.
Access credentials should be held by controlled components; the model generally only needs to know the currently available capabilities and their limits, not see the credentials themselves. This reduces the risk of credentials leaking into logs, conversation records, or external content.
6. Semantic Descriptions Should Be Part of the Contract
Structure definitions answer “what type is this field”; semantic definitions answer “what does this field mean in business terms.”
For example, a numeric field may represent an amount, a ratio, or a quantity; a time field may represent when an event occurred, or when the record entered the system. Type information alone is often insufficient for correct decisions.
It is recommended to supplement interface contracts with:
- The business meaning of each field.
- Numeric units and precision requirements.
- Time formats and timezone conventions.
- Enum values and their interpretations.
- The distinction between null, missing, and unknown values.
- Data source and update time.
- Whether the field may be used for automated decisions.
This information does not need to be sent to the model in full every time—it can be managed through versioned semantic descriptions. But key explanations must be available at decision time, not left to vague historical memory.
Meanwhile, externally returned data should be treated as data, not as new system instructions. Text in business documents, notes, or web content should not automatically gain the ability to change the agent’s permissions or execution policies.
7. Organize Communication Design with Five Responsibility Layers
To prevent protocol design from degenerating into endlessly stacked fields, communication responsibilities can be divided into five logical layers. This division is a design method, not a claim to replace existing protocols.
Layer 1: Transport and Message Boundaries
Handles connections, message framing, transport errors, and basic security protection. Prefer mature infrastructure rather than reimplementing all networking capabilities for agent collaboration.
Layer 2: Session and Capability Negotiation
Confirms the message types, structure versions, streaming capabilities, and necessary limits both sides support. Negotiation results should be explicit, with a handleable failure reason when compatibility is impossible.
Layer 3: Identity and Authorization
Handles runtime identity, user delegation, resource scope, and revocation checks. Authorization decisions must be made by trusted components.
Layer 4: Structure and Semantics
Handles field definitions, structure references, units, enums, and business interpretation, ensuring the receiver can correctly understand the data.
Layer 5: Task and Execution Lifecycle
Handles task association, operation status, cancellation, retries, and result confirmation, so that a single call can be tracked within a complete task.
These layers can be carried in the same message or implemented across multiple components. The key is clear responsibilities—avoid mixing business authorization, data interpretation, and network errors into one free-text result.
8. Reliable Execution: Timeout Does Not Mean Failure, Retry Does Not Mean Safety
Read operations are usually easy to retry, but write operations demand more caution.
When a caller times out, three situations are possible: the request never arrived, the operation failed, or the operation succeeded but the response was lost. The caller cannot determine which occurred from the timeout alone.
For operations that may have side effects, consider:
- Using idempotency mechanisms to identify a single business intent.
- Persisting execution state to support later queries.
- Distinguishing retryable errors from non-retryable errors.
- Providing cancellation requests for long tasks, with clarity on whether cancellation took effect.
- Designing compensation or manual-handling paths for partially successful workflows.
Idempotency keys must not be generated and reused arbitrarily by the model. They need a reliable association with the actual operation intent and request content, otherwise distinct operations may be wrongly merged, or duplicate execution may go unblocked.
Streaming responses should likewise distinguish progress messages from final results. “Submitting in progress” does not mean “submission succeeded”—the model must not tell the user the operation is complete based on progress alone.
9. How to Verify Whether a Design Is Worth Implementing
Context savings measured in one type of internal test should not be generalized as universal gains across all business scenarios. Structure repetition, record counts, field lengths, and how model input is organized all affect results.
Build a reproducible test suite covering scenarios such as small record sets, large homogeneous batches, heterogeneous results, structure changes, and network failures.
Evaluation should include at least four groups of metrics:
- Representation cost: transmitted bytes, model input tokens, structure description overhead.
- Execution efficiency: end-to-end latency, extra negotiation rounds, cache hit rates.
- Comprehension quality: field interpretation accuracy, unit handling correctness, task completion rate.
- Security and reliability: blocked unauthorized requests, duplicate writes, failure recovery, and audit completeness.
Comparative tests should keep tasks, data, and judgment criteria consistent. Do not compare a result stripped of necessary information against a complete result and attribute the entire difference to protocol optimization.
10. Incremental Integration Beats a One-Shot Rebuild
A practical rollout sequence is:
First, unify tool descriptions and error classification so the two frameworks can reliably exchange requests and results.
Second, introduce task association, operation status, and audit records to solve the untraceable call chain problem.
Then, complete identity delegation and execution-side authorization to establish a trusted boundary for actions.
Next, pilot structure negotiation on interfaces with clearly repetitive structures, keeping self-describing formats as a fallback.
Finally, decide based on real test results whether to extend to streaming interaction, capability negotiation, and fuller protocol abstraction.
This sequence deliberately places security, observability, and correctness ahead of compression gains, because a single erroneous business write usually costs more than a bit of extra context consumption.
Conclusion
Collaboration between agent frameworks is, at its core, contract design between a decision system and an execution system. Interface connectivity is only the first step; what truly determines system quality is whether responsibilities are clear, data is interpretable, authorization is verifiable, and failures are recoverable.
Structure reuse can improve the representation cost of repetitive data, but it must be designed together with version management, semantic descriptions, and fallback mechanisms. Layered communication can reduce integration complexity, but it does not require rebuilding all infrastructure.
The more reliable direction is to reuse mature transport capabilities, fill in the agent-specific pieces—identity delegation, structure understanding, and task lifecycle—and then use reproducible testing to prove that every added mechanism delivers real value.
