From LLMs to Agents: Architecture and Practices of Agent Runtime Frameworks
As LLM applications expand from question answering to task execution, the challenge shifts from "can the model generate a correct answer" to "can the system reliably get work done in a real environment." This article explains the distinction between model capabilities and system capabilities, defines the boundary between LLMs and agents, and introduces the concept of a runtime framework (or harness) as the layer that safely turns model decisions into real-world actions. It covers key components—task contracts, context organization, tool interfaces, state management, and memory/retrieval—along with reliability mechanisms for the execution loop, how to evaluate agents from prototype to production, and a phased roadmap for building agent systems that start with a minimal, controllable closed loop.
1. Discussing Agents: Separate Model Capabilities from System Capabilities
As LLM applications expand from question answering to task execution, the problems developers face have changed. In the past, the main question was “can the model generate the correct answer.” Now, developers must also answer “can the system reliably complete the work in a real environment.”
Consider a request like “organize today’s to-dos and flag any scheduling conflicts.” Fulfilling it requires not only natural language understanding, but also reading the calendar, checking the current time, detecting conflicts, generating adjustment suggestions, and—after authorization—modifying the relevant records. Some of this plays to the model’s strengths in semantic understanding and reasoning; the rest depends on external systems for data access, permission checks, and execution confirmation.
When discussing agents, it helps to establish a basic distinction up front:
- Model capabilities: understanding input, generating content, proposing courses of action, selecting tools within a given context, and interpreting results.
- System capabilities: providing an accessible environment, executing tool calls, persisting task state, controlling permissions, handling failures, and verifying task outcomes.
Even if the model generates a tool-call request, that does not mean the tool has executed. And if the model claims “task complete,” that does not mean the external environment has actually changed as expected. A truly useful agent must connect language-level judgments with environment-level facts.
2. Where Is the Boundary Between an LLM and an Agent?
There is no single, strict definition of an agent that fits every scenario. Different research and engineering practices draw the boundary based on degrees of autonomy, modes of environment interaction, or task duration.
For engineering purposes, a more useful criterion is: can the system, oriented around a goal, use environmental feedback to continuously decide and execute the next step?
A typical closed loop looks like this:
Goal input → Environment observation → Action selection → Tool execution → Result feedback → State update → Continue or terminate
This differs clearly from one-shot content generation. A standard Q&A exchange ends once an answer is produced, whereas an agent may need multiple rounds of action and may adjust its strategy based on actual execution results.
That said, “has tool calls” should not be equated with “is a highly autonomous agent.” If a system rigidly executes a two-step “query data → generate summary” pipeline and the model never decides what comes next, it is closer to a workflow with model capabilities baked in. Conversely, if the model can decide—based on query results—whether to retrieve more, whether to ask the user for clarification, or whether to change the plan, its agent-like character is far more pronounced.
Similarly, adding a prompt does not, by itself, prove that a system exhibits full agent behavior. Prompt enhancement, tool augmentation, workflow orchestration, and autonomous task execution should be treated as different degrees of capability, not lumped together as the same kind of system.
3. Why a Runtime Framework Is Needed
For architectural discussion, a useful abstraction is:
Agent system = Foundation model + Runtime framework + Environment connection
The foundation model may process text, handle multimodal inputs such as images, or participate in action decisions. The runtime framework organizes the engineering capabilities that sit outside the model. It is often called a harness—understood here as “the execution, constraint, and feedback mechanisms built around the model.”
This is not a strict mathematical formula, nor an industry standard. It is an engineering lens that helps developers divide responsibilities clearly.
The core value of a runtime framework is that it turns the model’s judgments into safe, stable external actions, and feeds the results of those actions back to the model. Its responsibilities typically include:
- Organizing task goals, constraints, and context.
- Managing tool descriptions, call requests, and execution results.
- Persisting task state and action history.
- Controlling permissions, budgets, and termination conditions.
- Handling failures, retries, and human handoff.
- Recording evidence to support evaluation, auditing, and troubleshooting.
The runtime framework is sometimes compared to an agent’s “operating system layer.” The analogy emphasizes resource management and execution control—it does not imply the same kernel, process, or device management mechanisms as a traditional OS.
4. Key Components and Design Principles of a Runtime Framework
1. Task Contracts: Define “Done” First
Many agent failures are not caused by the model failing to understand the task, but by the system never clearly defining the goal and acceptance criteria.
For example, “analyze sales performance” is too vague. A proper task contract should specify the analysis time range, data sources, statistical definitions, deliverable format, and which operations are allowed to run automatically.
A complete task description should at least answer:
- What result must be produced?
- Which data can be accessed?
- Is modifying external state permitted?
- How is a correct result verified?
- When must execution stop or request human confirmation?
The clearer the task contract, the less likely the model is to drift off-target during execution. For deterministic matters—monetary calculations, rule-based judgments, format validation—programmatic checks should take priority over relying on the model’s self-assessment.
2. Context Organization: Don’t Just Stuff Everything into the Model
Model input typically needs to include the user’s goal, system constraints, tool descriptions, retrieved material, and execution history. As a task progresses, this can grow quickly.
The point of context management is not simply to maximize input length, but to retain the information that genuinely affects the next decision. It usually breaks down into:
- Stable constraints, such as permission boundaries and safety rules.
- Current task information, such as goals, open questions, and recent tool results.
- Material retrievable on demand, such as historical records and knowledge documents.
For completed phases, you can store structured results instead of re-feeding the entire process. But summaries may lose key details, so information like amounts, identifiers, evidence sources, and execution status should be stored independently rather than only inside a natural-language summary.
3. Tool Interfaces: Make Actions Understandable and Verifiable
A tool is not just an exposed function entry point. To use a tool correctly, the model needs to clearly know its purpose, input constraints, return semantics, and possible side effects.
Design should distinguish sharply between read-only tools and write tools. Querying a record and deleting a record may both be “data access,” but their risk levels are entirely different.
For operations that modify external state, combine authorization checks, parameter validation, human confirmation, and execution receipts based on the actual scenario. When accounts, funds, or critical business data are involved, model-generated parameters must never be treated as trusted input.
Tool output should also use a clear structure that distinguishes successful results, business rejections, transient failures, and input errors. Otherwise, the model may misread “execution failed” as “no data found” and draw wrong conclusions.
4. State Management: Separate Task Progress from Chat History
Chat history describes the interaction process, but it does not necessarily reflect the system’s current state. Reliable task execution requires an independent state record, for example:
- The current phase and pending steps.
- Completed actions and their receipts.
- Preconditions not yet satisfied.
- Remaining budget and deadlines.
- Whether the system is waiting for user authorization.
- Whether irreversible external changes have already occurred.
This design is especially valuable for long-running and asynchronous tasks. Even if the execution process is interrupted, the system can determine where to resume based on persisted state, rather than asking the model to guess what was done before.
5. Memory and Retrieval: Solving for Relevance, Not Just Capacity
Improvements in long-context capability do not make retrieval and external knowledge management obsolete. Enterprise materials keep updating, and access permissions may vary by user identity—problems that cannot be solved by simply increasing model input length.
Retrieval augmentation does more than fetch documents that exceed the context window. It also locates relevant evidence, controls access scope, supports source tracing, and reduces irrelevant information.
Memory should distinguish within-task memory from cross-task memory. The former serves the current execution process; the latter may store user-confirmed preferences or stable facts. Cross-task memory needs explicit write conditions, retention periods, and deletion mechanisms—conversation content should never be automatically deposited as long-term facts.
Instructions, tool descriptions, and domain knowledge required by a task can be organized as reusable capability modules. This does not mean retrieval, tools, and knowledge all become the same mechanism; they still serve different responsibilities and merely cooperate at runtime.
5. Reliability Mechanisms for the Execution Loop
An agent can dynamically choose its actions, but execution boundaries must be enforced by the system. The following pseudocode illustrates the division of labor between model decisions and external control:
Create task and save goal, permissions, and budgetWhile task is not terminated:Check time, call count, and resource budgetRead current state and build contextAsk the model to propose the next actionIf the model requests clarification:Save state and wait for user inputIf the model proposes a tool call:Validate tool permissions and input parametersRequest confirmation for high-risk operationsExecute the tool and save the real receiptUpdate task state based on the resultIf the model proposes to finish:Check the result against acceptance rulesDeliver if acceptedOtherwise provide feedback or escalate to a humanIf an unrecoverable error occurs:Stop execution and report what is done and what is not
This process emphasizes three principles.
First, the model cannot grant itself permissions. Even if it generates a seemingly reasonable call, the execution layer must check it again.
Second, retries must not happen unconditionally. Read operations and write operations carry different risks—a timed-out write request may mean “executed, but the response was not received.” Retrying directly in that case may cause duplicate submissions. The system should use idempotency mechanisms allowed by the business, or status queries, to confirm whether the operation already took effect.
Third, completion must be backed by evidence. For document generation, check content and format; for external operations, require an actual receipt or result query. Never judge success purely from the model’s closing statement.
6. Will Runtime Frameworks Be Replaced by Stronger Models?
Stronger models can indeed reduce some peripheral design. For example, as models understand tool descriptions better, prompts can become simpler; as planning improves, some fixed decomposition steps may become unnecessary.
But it’s important to distinguish two categories of responsibilities:
- Capability-compensation responsibilities: compensating for current models’ weaknesses in reasoning, understanding, or context organization.
- System-governance responsibilities: managing permissions, resources, state, auditing, and consistency of external operations.
The former may shrink as models improve. The latter does not disappear just because models get smarter. A model that can understand access rules should not thereby acquire the right to bypass access control; a model that can predict the outcome of an operation cannot replace the external system’s factual records.
So the more reasonable view of evolution is this: the boundaries of the runtime framework will shift, and some complex logic may be simplified, but execution control and lines of responsibility must remain clearly defined. The real goal is not to make the framework ever thicker, but to ensure every component has a verifiable reason to exist.
7. From Prototype to Production: How to Evaluate Real Value
An agent prototype demo usually asks “can it complete the task once.” A production system must answer “does it remain reliable across different inputs, edge conditions, and permission restrictions.”
Evaluation should cover these dimensions:
| Dimension | Key Question |
|---|---|
| Task quality | Are acceptance criteria met, and are the facts well-grounded? |
| Execution correctness | Were the right tools called, with reasonable parameters and ordering? |
| Safety boundaries | Were permissions exceeded, and were high-risk operations handled correctly? |
| Running cost | Are there redundant calls, ineffective retrievals, or loops? |
| Recoverability | Can the system correctly recover after interruptions, timeouts, or tool failures? |
| Explainability | Can key inputs, actions, and execution receipts be traced? |
Test sets should not contain only happy paths. Include cases with missing information, tool timeouts, insufficient permissions, contradictory material, and malicious instructions embedded in external content. Tool results and retrieved text should be treated as data, never as trusted commands that can change system permissions.
Logging must balance observability with privacy protection. Keep records of task state changes, tool-call summaries, and error classifications, while avoiding indiscriminate logging of sensitive content. When troubleshooting, the goal is to reconstruct the information the decision relied on and the actual execution results—not to collect unnecessary internal reasoning traces.
8. A Practical Roadmap: Start with the Minimal Closed Loop
For development teams, the safest starting point is usually not to build an all-purpose general agent, but to pick tasks with clear goals, controllable risks, and well-defined acceptance criteria.
In phase one, connect only read-only tools and build the minimal “read → analyze → deliver” closed loop. Focus on validating whether the context is sufficient, whether results are grounded in evidence, and whether failures can be correctly identified.
In phase two, introduce limited write operations and build out authorization, confirmation, state persistence, and exception recovery. Define the scope of automatic execution clearly—do not remove necessary human controls just to increase autonomy.
In phase three, optimize planning, retrieval, and capability-module reuse based on real task data. Only when a single execution loop is stable enough and the task genuinely requires division of labor should you consider multi-role or multi-agent collaboration, so as to avoid the added complexity of communication, state synchronization, and responsibility partitioning.
Ultimately, the key to agent engineering is not how many components you bolt onto the model, but establishing a trustworthy chain: clear goals, usable information, controlled actions, verifiable results, and recoverable failures. The foundation model determines how far the system can understand and reason; the runtime framework determines whether those capabilities can reliably enter real business workflows.
