Layered Design and Evolution of LLM Agent Harnesses
This article explains the role of the agent harness, the external program that turns model outputs into real actions. It separates the harness from the model and the user interface, compares single-loop scheduling with runtime-extensible microkernel designs, and covers the risks of letting a system modify itself. It also lists metrics for evaluating a harness and practical steps for teams building or choosing one.
1. The Starting Point: What a Model Needs Beyond Its Capabilities
A large language model only generates text from its input. To read and write files, run commands, retrieve information, and complete multi-step tasks, the system needs an external program. This program converts the model’s output into real actions and sends the results back to the model. The industry usually calls this layer the agent harness. To evaluate a harness, you first need to separate it from the model and the user interface.
An analogy helps. The model is like the strength of a horse. The interface (editor plugins, chat windows, command-line entry points) is like the carriage cabin, which determines how users interact with the system. The harness is like the saddle and reins, which determine how the capability is constrained, controlled, and connected to the outside world. Users can see the first two directly. The harness determines whether the system stays reliable during long tasks.
2. Responsibilities of the Three Layers
- Model layer: understands, plans, and generates. It outputs natural language replies or structured tool call requests.
- Interaction layer: handles user entry points, interface display, session management, and action confirmation.
- Harness layer: handles tool registration, call scheduling, execution isolation, state persistence, context trimming, and error recovery.
Clear boundaries between the three layers make each one easier to replace and test. The same harness can connect to different interfaces. The same model can run in different harnesses, which makes it possible to compare behavior and identify where a problem originates.
3. Classic Implementation: Single-Loop Scheduling
Most current solutions use a loop that runs continuously. The core flow looks like this:
Initialize: load the system prompt and register the parameter description of each toolwhile the task is not finished:response = call_model(context)if response contains a tool call request:check whether the parameters match the descriptionresult = execute_locally(tool, parameters)context.append(tool call record, result converted to text)else:output the final answer and end the loop
This structure has three advantages. First, it is simple to implement. A minimal prototype can run in a few dozen lines of code. Second, it is easy to debug, because every decision happens in one linear flow. Third, its interaction protocol with the model is stable. Tool descriptions can use a common structured format, which makes it easier to move between models.
Its limitations are also clear. Rules and flow logic are usually hard-coded inside the loop, so adding a capability often means modifying the main program. The context grows with every round, and once it exceeds the model’s window, the system needs a truncation or summarization strategy. All tools share the same execution permissions, which makes fine-grained isolation by task difficult. As the number of branches grows, the single-loop code quickly becomes bloated, and maintenance costs rise.
4. Ideas for a Runtime-Extensible Design
Another approach treats the harness as a system that can be assembled at runtime, rather than a fixed flow. Its core elements include the following four.
- Lifecycle management: each capability module goes through defined stages of loading, readiness, pausing, and unloading. The harness manages the scheduling order and dependencies.
- Plugin composition: tools, policies, memory, and other modules register through a unified interface and can be enabled or disabled per task.
- Reflection and introspection: the harness can query its own module list, interface definitions, and state at runtime. Higher-level logic can use this information to make decisions.
- Event bus: modules communicate through events, which reduces coupling caused by direct calls.
This design is often described as a microkernel architecture. The kernel keeps only the minimal responsibilities of scheduling, registration, and lifecycle management. All other capabilities exist as modules. The structure looks like this:
Microkernel├─ Lifecycle manager├─ Module registry (supports adding and removing modules at runtime)├─ Event bus└─ Feature modules├─ File read/write module├─ Command execution module (runs in a sandbox)├─ Retrieval module└─ Memory module
The value of this structure lies in composing capabilities. Replacing the retrieval module with a different implementation requires no changes to the scheduling logic. The harness state can also be recorded in a structured way and replayed, which supports debugging and auditing.
5. Letting the System Modify Itself: Benefits and Risks
Some designs go further and allow the model to adjust module configuration at runtime. For example, the model might add a parsing tool for a task, or disable a module that is no longer needed. Conceptually, this resembles homoiconicity and reflection in programming. The structure of a program can be read and rewritten as data.
For open-ended tasks, this ability can reduce the effort of listing every tool in advance. The risks are equally clear:
- If a module is modified incorrectly, its behavior may drift from what was intended, and the problem may be hard to notice.
- A module generated by the model may contain unauthorized operations that bypass the original permission boundaries.
- If self-modification is not logged, it is difficult to review what happened afterward.
A reasonable approach is to limit which parts can be modified. Each structural change should produce a version record. New modules should undergo static checks and a trial run in a sandbox. Critical operations should still require human confirmation.
6. Dimensions for Evaluating a Harness
To judge whether a harness is reliable, run controlled comparisons on a fixed test set. Demonstration results alone are not enough. Focus on the following metrics.
- Task completion rate: the share of tasks completed successfully on the same set, along with the average number of steps.
- Error recovery: whether the harness can retry, fall back, or ask the user for clarification when a tool fails, times out, or returns an unexpected format.
- Context management: how often key information is lost during long tasks, and how well the summarization or truncation strategy works.
- Security boundaries: whether permission levels are clear, whether the execution environment is isolated, and whether sensitive information is masked.
- Cost and latency: the number of model calls, token consumption, and end-to-end time per task.
- Maintainability: how many code locations must change to add one tool, and whether test coverage is sufficient.
Record every metric on the same test set. This avoids drawing wrong conclusions because tasks differ in difficulty.
7. Practical Recommendations
Teams that are building or selecting a harness can proceed in the following order.
First, implement a single loop to build a minimal working cycle, and define the tool protocol and log format. Second, when the number of tools grows and the flow branches become more complex, split scheduling, registration, and lifecycle management into separate modules. Finally, if the system supports self-modification, validate it first in a read-only or sandboxed environment. Expand permissions gradually only after confirming that its behavior is controllable.
Overall, the value of a harness lies in reliably turning the model’s reasoning into controllable execution results. Elegant structure is only one part of the picture. Whether the system behaves predictably during failures, unauthorized actions, and long tasks is the core standard for judging a harness.
