AI Agent Architectures: Four Common Frameworks from Runtime Mechanics to Production Deployment
This article explains what an agent runtime framework, or harness, must provide beyond the model, then compares four common execution architectures: iterative tool-calling loops, workflows, state graphs, and multi-agent collaboration. It covers decision, state, and side-effect boundaries; context and memory; security and permissions; observability and evaluation; and a phased path from a minimal system to greater autonomy.
1. Start with What an Agent Needs Beyond the Model
Large language models are good at generating output from input context, but generating text and completing a task are not the same thing.
For example, a user asks the system to “analyze recent order anomalies, generate a report, and notify the owner.” The system must not only understand the request. It must also read order data, determine the analysis criteria, run statistics, organize conclusions, and send a notification within the authorized scope. A model can participate in judgments at these steps, but it cannot complete all external operations through text generation alone.
This requires a runtime framework that turns model output into behavior that can be checked, executed, and traced.
In the context of agents, this kind of runtime framework is often called a harness. It is not a single fixed component. It is the execution and governance layer around the model, typically including:
- Constructing model input and managing prompts and context;
- Registering tools, validating tool parameters, and executing calls;
- Saving task state, session information, and intermediate results;
- Controlling iteration counts, time budgets, and termination conditions;
- Handling exceptions, retries, pauses, and human approval;
- Recording the execution process to support monitoring, auditing, and evaluation.
The structure can be understood as follows:
User goal↓Runtime framework: context, state, permissions, execution control↓ ↑Model: understanding, reasoning, decision generation↓ ↑Tools: queries, computation, retrieval, business operations↓External environment and business systems
One common misunderstanding should be clarified: a model is not “completely stateless.” During a single generation, the model uses the current context; some inference implementations also save computation caches. But these mechanisms are not the same as reliable business memory. Task progress across requests, authorization results, and historical operation records still need to be explicitly maintained by external systems.
Likewise, an agent does not necessarily have to use a dedicated reasoning model. Whether stronger reasoning is needed should be determined by task complexity, accuracy requirements, and resource budget.
2. The Core of the Framework Is Not Wrapping the Model, but Establishing Control Boundaries
Adding a function wrapper around a model call is usually not enough to make a complete agent runtime framework. What really affects system reliability is three boundaries.
2.1 Decision Boundary: What the Model Is Allowed to Decide
A model can propose the next operation, but it should not automatically have all business decision rights.
For example, the model can suggest querying orders for a certain time range, and it can judge that refund records need to be retrieved. However, whether sensitive fields may be read, whether messages may be sent externally, or whether order status may be changed should be determined by permission rules and business policies.
Therefore, model output is better treated as an “operation proposal” than as an unquestionable execution instruction.
2.2 State Boundary: What Information Must Become a Reliable Record
Conversation text is suitable for expressing semantics, but it is not suitable as the only source of business state.
“The report appears to have been generated” and “the report file has been successfully saved and has a verifiable record identifier” are different facts. The framework needs to distinguish:
- The goal the user wants to achieve;
- What the model infers;
- What the tool returns;
- Business events that have been confirmed to have occurred.
This distinction helps prevent the model from treating a plan as a result or an inference as a fact.
2.3 Side-Effect Boundary: Which Actions Must Not Be Retried Casually
Reading data can usually be retried, but sending notifications, creating tickets, deducting inventory, and similar operations may produce duplicate side effects.
The framework must know whether an action was not executed, has already been executed, or has an unknown result. Otherwise, a network timeout can lead to duplicate notifications or duplicate writes.
Agent engineering is therefore not only prompt engineering. It also involves state consistency, idempotency, and failure recovery in distributed systems.
3. Four Common Architectures: Understanding Frameworks by Execution Organization
The source material does not provide implementation details for four specific frameworks, so this section does not compare specific products. Instead, it analyzes four common architectures according to how execution is organized.
These categories are not mutually exclusive. A real system may use a workflow to organize the main process, run a tool-calling loop inside a node, and then use a state graph to handle approval and recovery.
4. Type 1: Iterative Tool-Calling Architecture
The core of the iterative architecture is repeatedly executing “generate decision—call tool—observe result” until the task is complete or a limit is reached.
Goal and context↓Model generates next decision↓Is a tool needed?┌──┴──┐Yes No↓ ↓Validate and execute Output result↓Record tool result↓Continue decision-making
4.1 Suitable Tasks
This architecture is suitable for tasks whose paths are not fully determined and that require adjusting direction based on intermediate results, such as:
- Continuing to look for supplementary material based on retrieval results;
- Querying multiple data sources and gradually investigating anomalies;
- Trying to solve technical problems in a restricted environment;
- Adjusting the analysis process based on additional user information.
Its advantage is flexibility: developers do not need to enumerate all execution paths in advance.
4.2 Main Risks
Flexibility also means that the execution trajectory is hard to predict fully. The model may repeatedly call the same tool, end prematurely when information is insufficient, or keep collecting information that is not closely related to the goal.
The framework should therefore set at least:
- A maximum iteration count;
- An overall execution time limit;
- A time limit for each tool call;
- The range of tools that may be used;
- Duplicate-call detection;
- Clear completion conditions.
“The model says it is done” should not always be the only completion criterion. For tasks such as generating reports, objective conditions should also be checked, such as whether the file exists, whether key sections are present, and whether references are traceable.
4.3 A Generic Execution Sketch
The following is conceptual pseudocode, not an actual interface from any product:
Create task stateSet execution budgetRepeat until the budget is exhausted:Build context from task stateGet model decisionIf the decision is to finish:Check whether the result meets completion conditionsIf yes, return the resultOtherwise, write missing items into state and continueIf the decision is a tool call:Validate tool name, parameters, and call permissionIf it involves a high-risk operation, enter approvalExecute the toolSave execution state and resultContinueIf the decision cannot be parsed:Record the error and correct or stop according to policyAfter the budget is exhausted:Return completed parts, reasons for incompletion, and follow-up suggestions
What matters most here is not the loop itself, but the validation, budgeting, and state recording inside the loop.
5. Type 2: Workflow Architecture
A workflow architecture first defines the main steps, then places the model into steps where it is suitable.
Receive request↓Validate input↓Read data↓Model analysis↓Rule validation↓Human confirmation↓Publish result
5.1 Why It Is Easier to Control
A workflow makes the execution order explicit. Which nodes may call the model, which nodes must run deterministic logic, and which nodes require human confirmation all have clear boundaries.
For example, amount aggregation should be calculated by a program; the model can explain the cause of an anomaly and organize report language. This avoids asking the model to perform tasks that can be calculated precisely.
5.2 Suitable Scenarios
Workflows suit business processes with stable steps and clear review requirements, such as document processing, report generation, ticket classification, and material review.
Their advantages include:
- Execution paths are easy to understand;
- Node inputs and outputs are easy to test;
- Failed nodes can be retried individually;
- Human review can be inserted easily;
- Cost and latency are easier to estimate.
However, these advantages depend on the implementation. Reliable resume-from-checkpoint execution is possible only when node state is actually saved and recovery mechanisms are designed.
5.3 How to Avoid Excessive Rigidity
Not every detail needs to be fixed as a workflow node. A more reasonable approach is to keep the main process deterministic while allowing limited autonomy for complex local tasks.
For example, “generate an analysis report” can be a workflow node that internally runs a restricted tool-calling loop. But that node must not bypass subsequent approval and send the report directly.
This combination balances flexibility and control.
6. Type 3: State Graph Architecture
A state graph architecture describes the task lifecycle through states, nodes, and transition conditions.
Its difference from a workflow is not whether a flowchart can be drawn, but whether branching, loops, pauses, and recovery are treated as core execution semantics.
Pending → Analyzing → Awaiting approval → Executing → Completed↓ ↓ ↓Awaiting input Rejected Result pending confirmation↓ ↓Analyzing Resume or manual handling
6.1 Why Long-Running Tasks Need Explicit States
A task may last a long time while waiting for the user to provide additional information, waiting for approval, or pausing because of a tool failure. A continuously growing conversation alone makes these states difficult to express reliably.
A state graph can separate “where the task is now” from “what is allowed next.”
For example, in the “awaiting approval” state, even if the model continues to propose execution suggestions, protected operations cannot be triggered. The task can enter the execution state only after a valid approval event is received.
6.2 State Design Pitfalls
Too few states can mix many special cases together; too many states can make transition relationships hard to maintain.
It is advisable to make independent states only for differences that affect execution permissions, recovery strategy, and business semantics. Ordinary explanatory text, temporary reasoning, and display content do not necessarily need to become states.
At the same time, each transition should specify:
- What the triggering event is;
- Whether preconditions are met;
- Which data is updated;
- Whether an external side effect is produced;
- Which state is entered after failure.
6.3 Recovery Is Not Simple Replay
Saving checkpoints can help recover tasks, but rerunning a node may produce side effects again.
Checkpoints should therefore be designed together with tool execution records. During recovery, the system must determine which steps can be recomputed, which steps require querying business systems to confirm results, and which steps can only be handled manually.
For external write operations, local state alone is not enough to assume that an action has or has not been executed.
7. Type 4: Multi-Agent Collaboration Architecture
Multi-agent collaboration divides a task among multiple execution units with different responsibilities, contexts, or permissions.
Coordinator├─ Data analysis unit├─ Source verification unit└─ Content organization unit↓Aggregation, validation, and delivery
“Multiple agents” here does not necessarily mean using different models. They may use the same model but have different responsibility scopes, tool permissions, and input materials.
7.1 The Real Value Comes from Task Decomposition
The value of multi-agent systems is not in adding role names. It is in establishing clear division of labor.
For example, a data analysis unit generates structured statistical results, a source verification unit verifies the basis for conclusions, and a content organization unit organizes the final report.
If every unit receives all information, uses all tools, and freely discusses the same question, the system often only adds communication cost.
7.2 Collaboration Requires Explicit Handoff Protocols
Each execution unit should specify:
- What input it receives;
- What result it must produce;
- Which conclusions require evidence;
- Under what conditions it should return failure;
- Which operations exceed its own permissions.
The coordinator also should not judge quality only by the tone of the output. It should check result completeness, evidence consistency, and task coverage.
7.3 Multi-Agent Systems Are Not Inherently More Accurate
Multiple units may share the same false assumptions or reinforce each other’s incorrect conclusions. “Mutual review” is more likely to work only when information sources, review rules, or reasoning tasks have substantive differences.
In addition, parallel execution can shorten the time for some independent tasks, but the final benefit is also affected by the slowest branch, the aggregation process, and communication overhead. It should not be assumed directly that more units mean faster execution.
8. How to Choose Among the Four Architectures
| Architecture | Task Characteristics It Fits Better | Main Advantages | Main Engineering Challenges |
|---|---|---|---|
| Iterative | Unknown paths, need for exploration | Flexible adjustment of next steps | Runaway loops, budget governance |
| Workflow | Stable steps, clear rules | Easy to test and audit | Exception branches and workflow maintenance |
| State graph | Long-running tasks with many pauses and recoveries | Clear states and transitions | State design and consistency |
| Multi-agent collaboration | Decomposable tasks with clear responsibility differences | Specialized division of labor and parallel processing | Collaboration cost and result validation |
A practical principle is: parts that can be completed by deterministic programs do not need to be handed to the model for free-form decisions; tasks that can be solved by a single execution unit do not need complex collaboration first.
The more complex the framework, the more states, failure paths, and test combinations usually need to be maintained. Architecture selection should start from business uncertainty, not from architecture hype.
9. Context and Memory: Saving More Does Not Mean Better Understanding
The runtime framework needs to decide what information to provide to the model on each call, rather than continuously appending all historical records.
Information can be divided into three layers:
9.1 Task State
Save the current goal, completed steps, pending items, approval results, and confirmed facts. This information should be structured and should not rely only on model summaries.
9.2 Working Context
This includes materials needed for the current stage, recent tool results, and relevant historical conversation. It should be selected according to task relevance to avoid crowding the context with large amounts of irrelevant information.
9.3 Long-Term Memory
This includes confirmed user preferences, reusable experience, and stable knowledge. Long-term storage should consider necessity, access permissions, update mechanisms, and deletion requirements.
In particular, model-generated summaries may omit constraints, tool-returned data may be outdated, and historical preferences may no longer apply. Memory should therefore retain source, time, and scope of applicability, rather than only a single conclusion.
10. Security and Permissions: Tool Results Are Also Untrusted Input
When an agent reads web pages, documents, emails, or business records, it may encounter persuasive content, such as instructions to ignore rules, leak information, or perform unrelated operations.
This content is external data and should not automatically be upgraded to system instructions.
The framework should control risk at multiple levels:
- Provide the minimum necessary tool permissions for the task;
- Validate tool parameters against format and business rules;
- Apply separate controls to sensitive reads and external writes;
- Clearly distinguish external content from trusted control instructions;
- Require human approval for high-risk operations;
- Recheck actual execution parameters after approval.
Approval should be bound to a specific action and key parameters. A user’s approval to send a particular report should not be interpreted as approval to send any subsequently generated content.
For tool access, the range of accessible resources should also be controlled so that the model cannot indirectly obtain data beyond authorization through an overly broad tool.
11. Observability and Evaluation: Do Not Look Only at the Final Answer
If only the user question and final response are recorded, it is difficult to explain why an agent failed.
More valuable records include:
- Task identifiers and identifiers for each attempt;
- Model configuration and prompt version used;
- Tool requests, execution status, and returned summaries;
- State transitions and approval events;
- Latency and resource usage for each stage;
- Results of completion-condition checks;
- Reasons for exceptions, retries, and human takeover.
Logs should avoid unnecessarily storing sensitive raw text. Risk can be reduced through redaction, access control, and retention limits.
Evaluation should also check both results and process:
- Whether the user goal was actually completed;
- Whether key conclusions have supporting evidence;
- Whether permissions were exceeded or unnecessary writes occurred;
- Whether duplicate side effects appeared;
- Whether the task ended within budget;
- Whether an actionable recovery path was provided after failure.
The test set should cover not only normal tasks but also empty results, timeouts, malformed tool responses, insufficient permissions, approval rejection, and conflicting materials.
For scenarios that produce side effects, it is advisable to validate first in isolated environments with simulated tools, then gradually open real execution permissions.
12. Start with a Minimal System and Increase Autonomy Gradually
When deploying agents, a phased strategy can be used.
In the first phase, use a fixed workflow to read data, run model analysis, and display results, without allowing automatic writes to external systems.
In the second phase, introduce restricted tool calling so the model can choose query and analysis actions within a clear scope, with budgets and termination conditions.
In the third phase, add persistent state, checkpoints, human approval, and idempotency controls to support long-running tasks and failure recovery.
In the fourth phase, introduce multi-agent collaboration only when tasks can truly be decomposed and evaluation can demonstrate the benefit.
Each increase in autonomy should be accompanied by corresponding constraints and verification mechanisms. Otherwise, the system only gains more opportunities to act without gaining greater reliability.
Conclusion
The model determines how far an agent can understand and reason. The runtime framework determines how those capabilities act safely and continuously on real business systems.
Each of the four architectures has its applicable scope, but none can replace state management, permission control, failure recovery, and result validation. A strong agent system is not one that lets the model act as much as possible. It is one in which every action has a clear basis, explicit boundaries, and checkable results.
What is truly worth revisiting is not the calling convention of a particular framework, but the engineering mechanisms that must be added when an agent moves from “generating text” to “completing tasks.”
