AI Agent = LLM + Harness: How Agent Execution Really Works
This article breaks down the formula "AI Agent = LLM + Harness" to explain why an agent is more than its underlying model. It covers the core observe-reason-act loop, termination conditions, context management, tool-layer design, failure recovery, cost control, and observability, offering a practical engineering guide to building agents that can reliably complete end-to-end tasks.
1. Starting With the Formula: Why an Agent Is Not Just an LLM
In engineering discussions, a frequently cited expression is that an agent equals a large language model plus an execution framework. This execution framework is commonly called a Harness. It is not part of the model itself, but an engineering layer wrapped around it. The model handles language understanding, solution generation, and decision tendencies, while the Harness provides the environment, schedules tools, maintains state, enforces boundaries, and processes results. Without either one, you cannot build an agent that runs reliably.
This formula is not meant to diminish the model’s capabilities. It is a reminder to developers that failures in real tasks often do not come from the model “not knowing how to think,” but from external mechanisms failing to organize information, actions, and feedback properly. The model only sees a trimmed context and can only take the actions exposed to it. Therefore, the quality of the Harness design directly determines the agent’s ceiling.
2. The Core Execution Mechanism: The Observe-Reason-Act Loop
An agent’s operation can be abstracted as a continuous loop: observe the environment, reason, and act.
- Observe: Read information returned by the environment, such as command output, test reports, file snippets, API responses, and log contents. The key to observation is not just “reading,” but reading accurately and reading only what is critical.
- Reason: Based on the current observation, identify the problem, plan the next action, and decide whether more information is needed. The output of reasoning should be an executable next step, not a vague description.
- Act: Call tools to produce real side effects, such as reading and writing files, running scripts, making requests, or retrieving information, then feed the new results back into the observation stage.
Take a common AI coding scenario as an example: when automated tests fail, the agent first reads the failure summary and stack trace, then locates the relevant code area, modifies the implementation, and finally reruns the tests to confirm the result. If it still fails, the loop begins again. This process continues until the task is completed, an unsolvable problem is encountered, or a preset execution limit is reached.
3. Why the Loop Needs Brakes: Designing Termination Conditions
A loop without termination conditions is not an agent, but a runaway process. In engineering, three types of brakes are usually needed:
- Goal achieved: Confirmed by a verifiable signal, such as all tests passing, validation succeeding, or an artifact existing in a valid format.
- Unrecoverable error: For example, insufficient permissions, missing dependencies, or contradictory input. Continuing to try only amplifies the cost.
- Resource and step limits: Including maximum iterations, timeout, tool-call budget, and cost ceiling.
Among the three, the second is the most easily overlooked. Many implementations only set a step limit, causing the agent to repeatedly consume resources in the wrong direction. A more robust approach is to introduce “repeated action detection”: if observations across several consecutive rounds are highly similar and the state has not changed, the agent should proactively converge and output a diagnostic conclusion.
4. Context Management: What Determines Whether an Agent Gets Dumber Over Time
After running for multiple rounds, the context expands rapidly. Without governance, the model’s attention is diluted and early critical constraints get buried, showing up as contradictions and repeated work. Common governance techniques include:
- Layered memory: Keep short-term context for the current subtask, and distill long-term conclusions into structured summaries or external records.
- Observation compression: Keep only the error type, key line numbers, and the minimal reproduction snippet, discarding lengthy, irrelevant output.
- Externalized state: Write the to-do list, modified files, and verified items into an external state file, reading them on demand rather than carrying everything at once.
An illustrative state structure could look like this:
{"goal": "Fix failing unit tests in the specified module","done": ["Read failure logs", "Located the parsing function"],"pending": ["Fix boundary conditions", "Rerun tests"],"constraints": ["Do not change public interface signatures", "No more than two files per change"],"budget": {"steps": 12, "elapsed_seconds": 600}}
The benefit of this externalized state is recoverability: after a process interruption, a new Harness instance can pick up the unfinished part and continue.
5. Tool-Layer Design: The Boundaries and Verifiability of Actions
Action capability comes from tools, but more tools do not mean a stronger agent. Three principles should be followed in design:
- Minimal sufficiency: Each tool takes on one clear responsibility, with a stable input/output structure that makes it easy for the model to use correctly.
- Verifiable results: Tool returns should include a success flag, structured data, and readable error messages, avoiding leaving the model to guess from unstructured text.
- Tiered permissions: Read operations can be open, while write operations and operations with external side effects require confirmation or sandbox isolation. High-risk actions require explicit authorization.
In scenarios that require accessing external resources, general cloud capabilities are typically used, such as object storage for saving artifacts, a logging service for collecting execution traces, a message queue for decoupling long-running tasks, a container platform for providing isolated execution environments, and monitoring and alerting as a fallback for abnormal loops. These are general-purpose capabilities, and specific choices should be evaluated based on compliance and cost.
6. Failure Recovery and Cost Control
A stable agent must assume that “every step can fail.” Practical approaches include: setting retry and backoff strategies for tool calls; keeping rollback snapshots for modification actions; breaking large tasks into independently verifiable subgoals; and proactively degrading to “output diagnostics and suggestions” when the budget approaches its limit, rather than continuing to try blindly.
The core of cost control is binding the budget to the loop, rather than measuring it after the fact. Checking the remaining steps and time before each step and converging immediately when the limit is exceeded can significantly avoid long-tail consumption.
7. Observability and Evaluation
Agents are hard to debug, often because there is no trace. It is recommended to record each round’s observation summary, reasoning conclusion, action parameters, and result status to form a replayable trace. At the same time, build an offline evaluation set covering normal paths, boundary inputs, and fault-injection scenarios, using pass rate, average steps, and number of human interventions as core metrics. Iteration without evaluation is just tuning parameters by feel.
8. Conclusion
Understanding an agent as “model plus execution framework” essentially means bringing an uncontrollable generation process into a controllable engineering system. Observation must be precise, reasoning must converge into executable actions, actions must be verifiable and rollbackable, and the loop must have clear brakes. Only when these four points are seriously implemented does an agent truly gain the stability to complete end-to-end tasks.
