Designing the Runtime for Next-Generation AI Agents: From Models to Agent Harnesses
This article explains why the focus of AI agent development is shifting from models to the runtime environment around them. It distinguishes models, tool protocols, development frameworks, and agent harnesses, and lists the six core responsibilities of an agent runtime. It then covers plugin-based architecture, its benefits and risks, and the design of the main loop, context compression, approvals, session recovery, and sub-agent orchestration. The article ends with a checklist for rolling out agent runtimes in production.
1. Why the Focus Is Shifting from Models to Runtime Environments
For the past two years, discussions about AI coding tools have centered on the model itself. The main questions have been whether code generation is stronger, whether context windows are longer, whether reasoning chains are deeper, and whether calls are cheaper. These metrics matter. However, once a team places a model in a code repository with tens or hundreds of thousands of files and lets it run continuously for tens of minutes or even hours, the model is often no longer the main factor that determines success or failure.
In real workflows, the model must understand the structure of the current working directory. It must read and modify files accurately, run commands, observe compilation and test results, and keep key facts as the context keeps growing. High-risk commands cannot be allowed without control. A single failed tool call must not bring down the whole session. After an interruption, a task must be able to resume from its last checkpoint.
The problem can be summarized in one sentence: the model decides what to do next, and the system around the model makes those decisions execute safely, reliably, and traceably. This surrounding system is commonly called an Agent Harness, or agent runtime environment. Some vendors have recently open-sourced projects of this kind and summarized their core idea as “everything is a plugin.” These projects offer a useful example for discussing next-generation agent infrastructure.
2. Four Concepts That Are Easy to Confuse
Before discussing architecture, it helps to separate four concepts that are often used interchangeably.
1. A model is not an agent
A model receives a sequence of messages and generates the next piece of text or a tool-call intent. It does not know where the working directory is, and it does not inherently have access to a command line, an editor, version control, a browser, or a database. When a model outputs an intent to “read a certain file,” the file has not necessarily been read. Between that intent and the result lies a full chain of steps: parameter validation, path resolution, permission checks, actual execution, result truncation, and error handling. The runtime environment is responsible for this chain.
2. A tool protocol is not an agent
Take a common tool integration standard such as MCP. It defines how tools, resources, and prompts are exposed through a unified protocol, much like a socket specification. However, it does not automatically provide a complete task loop, session recovery, context compression, permission decisions, or execution state management. A protocol without a runtime is like a socket without a power supply.
3. A development framework is not a runtime environment
Common agent development frameworks help developers build business workflows. They define nodes, connect edges, and organize state transitions. An Agent Harness is closer to a complete execution environment that runs agents directly. It not only describes how nodes connect, but also sends model requests and handles retries, schedules tools, executes processes, persists logs, collects user approvals, and provides the user interface. The framework is a drafting tool, and the harness is the full factory.
4. Core responsibilities of a runtime environment
Taken together, a capable agent runtime must handle at least six responsibilities:
- Model adaptation: abstract away differences between model interfaces and unify message formats and call methods;
- Task loop: drive the iterative process of observing, reasoning, acting, and observing again;
- Tool governance: register, validate, execute, and isolate tool calls;
- Context management: compress, summarize, and retain key information within a limited context window;
- Security control: require approval for risky operations, isolate them in sandboxes, and protect credentials;
- Observability: record complete session logs to support auditing, replay, and failure recovery.
3. Plugin Architecture: A Key Design Choice for Runtimes
Recent open-source projects show a clear architectural trend. Instead of building an agent as a closed monolithic program, they split the model adapter, main loop, tool registry, session log, sandbox, approval logic, context compression, sub-agents, and even the user interface into pluggable components. The agent becomes a plugin tree. Teams can assemble the tree at startup, and they can replace or unload parts of it at runtime.
1. Benefits of plugins
This design offers three main benefits.
First, capabilities can be composed. Teams have very different requirements. Some need strict approval workflows, while others want fully automated execution. Some run in a local terminal, and others need a web interface. A plugin tree lets each team assemble the features it needs in its startup configuration, rather than accepting a fixed feature set.
Second, evolution costs less. Model interfaces, tool protocols, and security policies all change over time. When each concern is isolated in its own plugin, replacing a model adapter or upgrading a sandbox implementation does not affect the rest of the system.
Third, testing becomes easier. Monolithic agents are hard to unit test. With plugins, developers can write separate test cases for a single tool, a single context compression routine, or a single approval policy. This improves confidence in the engineering.
2. Costs and constraints of plugins
Plugins are not free. Dynamic loading means plugins may come from third parties, and their code quality and security are outside your control. A dynamic plugin sandbox is usually a resource isolation mechanism, not a strong security boundary. A malicious plugin can still cause damage through the tool permissions, credentials, or network channels it is granted. Common industry recommendations include the following:
- Pin the runtime to specific versions to avoid behavior changes from unverified upgrades;
- Restrict plugin sources and load only plugins that have passed internal audits;
- Choose a sandbox mode based on the risk level of each task;
- Apply additional isolation and least-privilege access to credentials, network egress, and persistent directories.
4. Key Design Points for Core Modules
1. The agent main loop
The main loop is the core of the runtime. A typical form looks like this:
while not done:observation = collect_context()action = model.decide(observation)if action.requires_approval:request_user_approval(action)result = execute(action) # Execute inside the sandboxrecord(result) # Persist the session log
The loop looks simple, but it hides many engineering details. These include timeouts and retries for model requests, concurrency control for tool calls, formatting of error results before they return to the model, and an upper limit on loop depth. Mishandling any of these shows up as an agent that gets stuck, repeats the same action, or fills its context window too quickly.
2. Context compression and memory
In long tasks, the context window will eventually fill up. Simply truncating early content discards the reasoning behind key decisions. Runtimes therefore usually need a layered strategy. They summarize and deduplicate tool output, roll up older conversation history, and explicitly retain key facts such as user requirements, confirmed constraints, and approaches that have already failed. The quality of this strategy often determines whether the agent still remembers its original goal late in a long task.
3. Approval and permission model
Risky operations, such as deleting files, changing version history, accessing external networks, and running arbitrary scripts, must go through an approval process. Mature runtimes provide tiered policies. Read-only operations proceed automatically. Write operations are limited by a directory allowlist. High-risk commands require explicit human confirmation. In enterprise deployments, approval records should also go into audit logs so that every grant of permission can be traced.
4. Session recovery and logging
Interrupted long tasks are common, not exceptional. The runtime should persist each step’s model request, tool calls, and results so that a session can resume from any checkpoint. This improves reliability. It also provides data for post-incident review, failure analysis, and evaluation.
5. Sub-agent orchestration
For tasks that can be split into parallel subproblems, the runtime can start sub-agents to handle each part independently and then combine their results. The key design points are how sub-agent context is isolated and how results are returned. Weak isolation lets sub-agents contaminate each other. Verbose results take up space in the main agent’s context window.
5. Practical Recommendations for Production
Before using this kind of runtime on important production repositories, follow this checklist:
- Version pinning: Projects in a fast-moving phase may introduce breaking changes. Lock the version and set up a review process for upgrades.
- Plugin allowlist: Allow only plugins that have passed internal audits into production configurations.
- Tiered sandboxing: Choose isolation strength based on task risk. Use the strongest isolation mode by default for sensitive repositories.
- Minimal credentials: Limit the blast radius with short-lived credentials, dedicated service accounts, and network egress controls.
- Full auditing: Send model requests, tool calls, and approval decisions to a centralized log service and a monitoring and alerting system. General-purpose cloud products, such as the logging service, object storage, and container platform offered by Baidu AI Cloud, can help build a centralized auditing and runtime foundation.
- Staged rollout: First run the complete task pipeline on non-critical repositories. Track metrics such as success rate, average task duration, and rate of human intervention. Then expand gradually.
6. Conclusion
The next phase of the agent race is shifting from asking how capable a model is to asking how reliable the runtime environment is. The model sets the upper bound of what an agent can do, and the runtime sets the lower bound. The runtime determines whether an agent can keep working for hours in a real repository without losing control, and whether its errors can be audited, recovered, and traced. Plugin-based architecture, layered context management, tiered approvals, and sandbox isolation form the basic skeleton of next-generation agent infrastructure. For developers, understanding the general design principles behind this skeleton has more lasting value than following any single tool.
