From Models to Execution: Engineering Practices for Agent Runtime Frameworks
This article explains why agent systems require a runtime framework beyond the model itself. It covers the responsibility boundaries among the model, agent, and runtime; how to design a reliable execution loop with task contracts, explicit state, termination conditions, safe tool use, and layered context; and how to approach evaluation, staged production adoption, general-purpose versus vertical agents, multi-agent collaboration, reusable skills, and the governance boundaries of automation. Readers will gain a practical engineering view of how to turn model capabilities into repeatable, auditable, and maintainable production systems.
1. Why Agent Discussions Must Include the Runtime Framework
Discussions around agents are shifting from “what a model can answer” to “what a system can complete.” Answering a question usually requires generating a piece of text, while completing a task often requires retrieving information, calling business APIs, modifying files, checking results, and choosing a recovery path after a failure.
The gap between these two modes cannot be closed by simply adding a few prompts.
Suppose a user asks: “Compile this month’s abnormal orders, analyze the causes, and generate handling recommendations.” A model can explain how to perform the analysis, but actually executing the task still requires resolving a series of concrete questions:
- Does the user have permission to read order data?
- Which time zone and statistical definition does “this month” refer to?
- Can the data query be retried if it fails?
- Does the analysis process contain sensitive information?
- Are the generated recommendations consistent with the actual order status?
- Can the system distinguish between read-only analysis and operations that modify orders?
- If the task is interrupted, can it resume from existing progress?
The agent runtime framework is what handles these questions. It can be understood as an execution and governance layer around the model: it provides context, connects tools, persists state, constrains behavior, validates results, and controls the lifecycle of the entire task.
Therefore, an agent is not “a model plus a chat interface.” It is a complete application in which the model participates in decision-making while the software system is responsible for reliable execution.
2. Responsibility Boundaries Among the Model, Agent, and Runtime Framework
To avoid conceptual confusion, it helps to understand the system at three layers.
1. Model layer: understanding, reasoning, and generation
The model generates output based on input context. It can be used to analyze user intent, decompose tasks, select tools, and explain execution results.
However, model output itself does not mean that an operation in the real world has been completed. When it generates the sentence “the record has been updated,” that does not prove that the database was actually updated. When it provides a query plan, that does not prove that the query result matches the business definition.
Model output must be validated against tool execution results and external evidence.
2. Agent layer: continuous decision-making around a goal
The agent organizes model capabilities into a goal-oriented work process. It does not merely respond to a single request; it decides the next action based on environmental feedback.
A typical process is:
Goal understanding -> plan formulation -> action execution -> feedback inspection -> plan adjustment -> result delivery.
Not every step requires model participation. Fixed data cleaning, permission checks, amount calculations, and format validation are usually better handled by deterministic programs. Model decision-making is needed only when there is semantic understanding, path selection, or uncertainty judgment.
3. Runtime framework layer: controllable, recoverable, and auditable execution
The runtime framework is responsible for enforcing execution rules, including:
- Tool registration and call validation;
- Identity authentication and permission decisions;
- Context assembly and history compression;
- Task state persistence;
- Timeouts, cancellation, and retries;
- Cost and execution-step limits;
- Human approval;
- Result validation and logging.
A practical principle is: the model can propose actions, the runtime framework decides whether an action is allowed, and tool feedback proves whether the action was actually completed.
This separation of responsibilities reduces the risk of loss of control and helps keep business systems stable when models are replaced.
3. How to Design a Complete Execution Loop
From an engineering perspective, agent execution is better treated as a task with explicit states rather than an infinitely extending conversation.
1. Define the task contract first
Before a task starts, four types of information should be clarified:
Input scope: which data, files, and systems are allowed.
Target outcome: whether the final deliverable is a report, structured records, or a business operation that has gone through approval.
Constraints: execution time limits, resource budget, prohibited actions, and human confirmation requirements.
Completion criteria: what evidence can prove that the task has been completed.
For example, the completion criteria for an abnormal-order report should not be merely “a document was produced.” They should also include a clear statistical definition, traceable key conclusions, an explanation of missing data, and recommendations that correspond to the anomaly types.
The more specific the completion criteria, the easier it is to automate later validation.
2. Use explicit state management
A task can have the following general states:
Pending, running, waiting for approval, waiting for external result, completed, failed, and canceled.
State transitions should be driven by actual events, not merely declared by the model. A task can enter “completed” only after result validation passes. Operations that require human authorization should enter “waiting for approval” and must not continue executing on their own.
State records should at least include the task identifier, current step, tool call results, pending items, and failure reasons. Long-running tasks also need checkpoints so that they do not restart from the beginning after a process restart.
3. Set termination conditions for loops
An agent without termination conditions can easily consume resources through repeated retrieval, modification, and self-checking.
Reasonable stopping mechanisms include:
- Reaching the maximum number of execution steps;
- Exceeding the task deadline or budget;
- Making no effective progress for several consecutive attempts;
- Being unable to obtain necessary data;
- Detecting insufficient permissions;
- The result already meeting acceptance criteria.
Here, “no progress” cannot be judged only by whether the text has changed. It should also consider whether new valid evidence has been added, whether blockers have been removed, and whether the task state has advanced.
An illustrative flow is:
Load task stateCheck deadline, budget, and cancellation signalIf human authorization is required:Save stateEnter waiting for approvalOtherwise:Generate next actionValidate action parameters and execution permissionsCall toolSave actual execution resultValidate result and update stateIf completion criteria are met:Generate deliverableElse if the task cannot continue:Output failure reason and recovery suggestionsElse:Proceed to next iteration
The key here is not the loop itself, but that each step has clear inputs, real feedback, and inspectable state changes.
4. Tool Calls: From “Can Use” to “Safe Use”
Tools are the main interface through which agents interact with the external environment, and they are also where risk is most concentrated.
1. Tool interfaces should be narrow and explicit
Overly broad tools shift too much decision-making responsibility to the model. For example, an interface that “executes arbitrary operations” may be flexible, but it is difficult to limit its impact.
A safer approach is to split tools according to business responsibilities and define for each tool:
- Parameter types and required fields;
- Accessible resource scope;
- Success and failure return structures;
- Whether there are external side effects;
- Whether repeated calls are supported;
- Whether approval is required.
Tool returns should also distinguish among “request received,” “operation executed successfully,” and “business goal achieved.” These three states are not equivalent.
2. Apply tiered authorization to operations with side effects
Reading public information and deleting business records should not use the same authorization policy.
Risk can be classified by data sensitivity, impact scope, and reversibility:
- Low-risk operations: automatically execute under existing permissions;
- Medium-risk operations: restrict the resource scope and record audit information;
- High-risk operations: show the specific changes and request confirmation before execution;
- Irreversible or large-scope operations: use stricter approval and verification mechanisms.
The confirmation page should present the actual action, such as target records, modified fields, and affected count, rather than only a vague description generated by the model.
3. Retries must consider idempotency
A network timeout does not mean that the operation was not executed successfully. For actions such as creating orders, sending messages, or modifying records, a direct retry may cause duplicate execution.
The framework should choose a strategy based on tool semantics: deduplicate using operation identifiers, query execution status first, or hand actions with uncertain results to human handling.
“Automatic retry” is an availability mechanism and should not become the default behavior for hiding business risk.
5. Context and Memory: More Is Not Always Better
Long-running tasks need to remember history, but continuously stuffing all content into the model context increases cost and may drown key constraints in a large amount of detail.
A more reasonable approach is to store information in layers.
1. Current task context
This includes the user goal, constraints, recent tool feedback, and evidence needed for the next step. It emphasizes immediate relevance and does not need to include all historical records.
2. Structured task state
This stores completed steps, pending items, resource identifiers, approval status, and verified facts. Key state should not exist only in natural-language summaries.
3. Reusable experience and user preferences
This type of information may be used across tasks, but its scope, source, update time, and access permissions must be marked. A user’s temporary requirement in one task should not automatically become a permanent preference.
Context compression also needs to preserve the evidence chain. “The model suspects the cause may be inventory shortage” cannot be compressed into “the cause is inventory shortage”; otherwise, an uncertain judgment will be mistaken for a fact in later steps.
6. Will Better Models Replace the Runtime Framework?
As model capabilities improve, some complex prompts, task decomposition, and error-correction logic may indeed be simplified. Engineering teams should not permanently encode the current shortcomings of models into system architecture.
However, better models will not eliminate permission management, auditing, business state, external tools, or accountability.
Runtime framework functions can be divided into two categories:
Capability-compensation functions: mainly used to compensate for model limitations, such as complex prompt orchestration, repeated explanations, and specific error correction. These functions should be continuously evaluated as models improve to determine whether they are still needed.
Governance and execution functions: such as identity verification, data isolation, transaction processing, approval, budget management, and result tracking. These come from business requirements, not from model weaknesses.
Therefore, a long-term effective architecture is not one that keeps adding orchestration layers. It preserves necessary governance boundaries while gradually simplifying cognitive work that models can reliably handle.
7. How General-Purpose and Vertical Agents Should Divide Work
General-purpose agents are good at handling open-ended tasks and can search across different information sources and tools to find solution paths. Vertical agents place more emphasis on domain rules, process constraints, and result accountability.
The two do not necessarily have a relationship of full replacement.
In scenarios with simple rules, low risk, and standardized tools, general capabilities are more likely to cover user needs. But in scenarios such as financial processing, production scheduling, and compliance review, domain knowledge, data definitions, approval chains, and audit requirements remain important.
The value of a vertical system cannot be based only on “writing a set of domain prompts.” It should be reflected in:
- Verifiable business rules;
- High-quality task data;
- Execution permissions consistent with real processes;
- Clear exception handling mechanisms;
- Continuously maintained evaluation sets;
- Complete ownership of result accountability.
A more feasible combination is general understanding plus domain constraints and deterministic execution, rather than letting the model freely interpret all business rules.
8. Multi-Agent Collaboration: Prove the Benefit of Splitting Before Adding Roles
Multi-agent systems do not automatically achieve higher quality simply by assigning one task to more models. Collaboration introduces additional communication, state synchronization, duplicate work, and conflict-handling costs.
It is more suitable for the following situations:
- Subtasks can be executed relatively independently and in parallel;
- Different subtasks clearly require different tools or permissions;
- Results have clear input/output contracts;
- There is a coordination mechanism for unified acceptance.
For example, a research task can be split into information collection, data verification, and conclusion review. But each role should deliver a defined artifact rather than merely exchange open-ended dialogue.
The coordinator needs to check whether sources are duplicated, conclusions conflict, and evidence is sufficient. Adding a “review role” does not equal independent validation; if all roles depend on the same incorrect data, they may jointly reach a wrong conclusion.
For tasks with fixed paths and few branches, a single agent combined with a deterministic workflow is usually easier to maintain. Multi-agent design should be a choice made after evaluation, not the default architecture.
9. What Steps Are Needed to Turn Personal Experience into Skills?
Encapsulating experience as reusable skills is essentially transforming a tacit way of working into an explicit execution contract, rather than simply copying an individual’s writing style.
A maintainable skill unit should include:
- Applicable and non-applicable scenarios;
- Required inputs and prerequisites;
- Standard operating steps;
- Callable tools and permission scope;
- Output format and acceptance criteria;
- Common exceptions and handling methods;
- Examples, version, and maintenance responsibility.
For example, “organize requirements review notes” can be defined as: extract confirmed requirements, open questions, and action items from meeting materials, and require each action item to have an owner and deadline. When this information is missing, the skill should mark it as to be supplemented rather than guessing.
Skills need to be tested through historical task replay and failure cases. Shortcuts in personal experience are not necessarily suitable for automated execution, and they must not bypass organizational approval rules.
10. Enterprise Adoption: Build Evaluation Before Expanding Automation
From demonstration to production, the biggest change is that the system must face repeated use, abnormal inputs, and real business consequences.
A phased path is recommended.
Phase 1: Choose tasks with clear boundaries
Prioritize scenarios where inputs are available, results are verifiable, and the impact of errors is limited. Knowledge organization, read-only analysis, and draft generation are usually better starting points than directly modifying core business data.
Phase 2: Build an offline evaluation set
Evaluation should cover normal samples, missing information, insufficient permissions, tool timeouts, duplicate requests, and malicious instructions.
In addition to final answer quality, observe:
- Task completion rate;
- Tool call correctness;
- Unauthorized attempts and interception;
- Human intervention rate;
- Execution time and resource cost;
- Recovery capability after failure.
Fluency of expression alone cannot determine whether a system is reliable.
Phase 3: Enter real workflows with limited permissions
Initially, the system can keep read-only permissions or generate operation recommendations for human confirmation before execution. After accumulating real feedback, gradually open up low-risk automation.
Phase 4: Establish continuous observability and regression mechanisms
Task logs should connect user requests, model decisions, tool calls, state changes, and final results, while protecting sensitive fields as necessary.
Whenever the model, tool definitions, prompts, or skills change, regression tests should be run. A seemingly minor adjustment may also change tool selection and task-stopping behavior.
11. Where Are the Boundaries of a Fully Automated Organization?
Agents can take on more information processing and process execution work, but “no human involvement” does not mean “no governance responsibility.”
Organizations still need to define business goals, bear legal responsibility, handle conflicts of interest, and make value judgments in exceptional situations. Especially when tasks affect customer rights, financial safety, or major business decisions, responsibility cannot simply be transferred to the model.
A more realistic direction is to increase the organization’s automation ratio: let machines handle repetitive, verifiable work, and let humans be responsible for goal setting, authorization, supervision, and high-risk decisions.
When evaluating the level of automation, do not look only at how many operators have been reduced. Also consider whether exception handling is clear, errors are controllable, processes are traceable, and overall delivery quality has improved.
Conclusion: The Value of the Runtime Framework Is Turning Capability into Reliable Delivery
The core of agent engineering is not to give the model unlimited room for action, but to enable it to complete tasks within clear boundaries with evidence, state, and acceptance criteria.
The model determines how complex a problem the system can understand, tools determine which environments the system can reach, and the runtime framework determines whether these capabilities can be used safely and continuously in real business.
For development teams, the most worthwhile investment is not adding more roles and prompts, but establishing task contracts, controlling execution permissions, preserving real state, validating operation results, and continuously improving through evaluation. Only when these foundations are solid can agents move from a one-time successful demonstration to repeatable, maintainable production systems.
