Model + Harness = Agent: A Practical Framework for Building AI Agent Products

    This article introduces the "Model + Harness = Agent" framework for turning general-purpose LLMs into production-ready agent products. It explains the role and limits of the model layer, breaks down the harness layer into context management, tool calling, task planning, file and terminal execution, and feedback/evaluation loops, and shows how a plugin-based architecture keeps the core stable while capabilities scale. It closes with engineering best practices for safety, evaluation-driven iteration, and closed-loop execution.

    1. Why the “Model + Harness = Agent” Formula Matters

    When productizing AI agents, a common mistake is to place all expectations on the model itself: the assumption that a strong enough foundation model will naturally “act intelligently.” Engineering practice repeatedly shows that no matter how capable the model is, it is only the “brain.” An agent without hands, memory, and a perception system cannot genuinely enter or handle real-world workflows.

    The formula “Model + Harness = Agent” was abstracted to address this misconception. It breaks a broad goal—building a usable agent product—into two parts with clear responsibilities that can evolve independently:

    • Model: The foundation of the agent, responsible for understanding, reasoning, and generation. It is the source of capability.
    • Harness: All engineering work outside the model itself. It is the critical middle layer that connects model capability to the real environment.

    The relationship can be summarized in one sentence: the model determines the upper limit, while the harness determines whether the product can actually ship. The value of this formula is that it shifts the focus of productization from “tuning the model” to “building the harness,” allowing teams to invest limited resources in the engineering work that truly affects product usability.

    2. The Model Layer: The Foundation and Its Boundaries

    The model layer handles three core functions: understanding, reasoning, and generation. A user’s natural-language instruction must first be “understood” by the model, then “reasoned” into executable steps, and finally “generated” as structured or natural-language output. These three steps form the agent’s cognitive core.

    However, the boundaries of the model layer must be recognized clearly:

    1. Statelessness: Most models have no persistent memory within a single call; information across turns must be injected externally.
    2. Knowledge cutoff: Knowledge in model parameters is tied to a training cutoff, so the model cannot directly perceive the current state of the environment.
    3. No direct action: The model can only “generate content.” It cannot directly read or write files, execute commands, or call external systems.

    Because of these boundaries, the model cannot complete real tasks on its own and must be supported by the harness layer. This is also why the formula holds: it is not that the model is not strong enough, but that the model is not designed to take on engineering responsibilities.

    3. The Harness Layer: The Key Middle Layer Connecting Capability and Workflow

    The harness is the most underestimated part of the formula, yet it most determines a product’s success or failure. It is defined as “all work other than the model itself,” and its scope is broad. It can be grouped into the following categories.

    3.1 Context Management

    Context is the agent’s “working memory” for understanding a task. The harness must decide which historical information to keep, which to compress, and which to retrieve and inject. Poor design leads to context overflow, loss of critical information, or runaway costs. Reasonable approaches typically include summarizing long conversations, retrieving external knowledge on demand, and clearly organizing task boundaries in the prompt. It can be understood as the agent’s “attention scheduler”:

    1. class ContextManager:
    2. def build_prompt(self, task, history, retrieved):
    3. # Put task constraints first, compressed history in the middle, and retrieved evidence at the end
    4. compressed = self.summarize(history) # Control context length
    5. evidence = self.retrieve(task) if retrieved else []
    6. return f"[Task] {task}\n[History Summary] {compressed}\n[Reference] {evidence}"

    3.2 Tool Calling

    Tools are the agent’s “hands and feet” for acting on the external world. The harness must describe the capabilities, parameters, and constraints of available tools to the model in a structured way, parse the call intent returned by the model, and execute it in the real environment. Key design points include the clarity of tool descriptions, parameter validation, the format for returning execution results, and fallback and retry strategies on failure.

    3.3 Task Planning

    For complex tasks, the harness must guide the model to break a large goal into executable sub-steps and maintain state between each step. Planning can be an explicit step list, or a dynamic flow generated by the model where the harness validates and corrects it. A good planning mechanism can significantly improve the completion rate of complex tasks.

    3.4 File Reading/Writing, Code Modification, and Terminal Execution

    This is the core capability set for coding agents. The harness must safely open, read, and modify files, execute terminal commands, and return output to the model. Security boundaries are especially critical here: accessible directories should be restricted, dangerous operations should require confirmation, and the execution environment should be isolated to prevent mistakes or privilege escalation.

    3.5 Feedback Collection and the Evaluation Loop

    Whether an agent can keep improving depends on forming a closed loop: execution results are collected, compared against expectations, and deviations are fed back to the model or planner to trigger the next round of correction. The evaluation loop is used to systematically measure the quality of different harness versions and provide quantitative grounds for iteration. Without a loop, an agent can only make a “one-shot attempt”; with a loop, it gains the ability to self-correct.

    4. Plugin-Based Architecture: Everything Is a Plugin

    The harness layer has many capabilities that keep evolving. A monolithic, tightly coupled design means any change in one part affects the whole. For this reason, the industry commonly adopts a plugin-based open architecture, with the core idea that “everything is a plugin”: context management, tools, planning strategies, executors, and evaluators are all abstracted into pluggable units registered and invoked through a unified interface.

    This design brings three benefits:

    • Extensibility: Adding a new tool or planning strategy only requires implementing and registering a plugin, with no changes to the main flow.
    • Replaceability: Different plugins can be flexibly combined for different scenarios—for example, presetting multiple run modes to match needs such as interactive development and batch processing.
    • Governability: Clear plugin boundaries make permission isolation, monitoring, and evaluation easier.

    A schematic plugin interface can be abstracted as follows:

    1. from abc import ABC, abstractmethod
    2. class Plugin(ABC):
    3. name: str
    4. @abstractmethod
    5. def run(self, context, **kwargs): ...
    6. class Registry:
    7. def __init__(self):
    8. self._plugins = {}
    9. def register(self, plugin: Plugin):
    10. self._plugins[plugin.name] = plugin
    11. def get(self, name: str) -> Plugin:
    12. return self._plugins[name]

    The main flow depends only on the unified interface, and plugins are assembled in the registry as needed, forming a clear separation between a stable core and flexible peripherals.

    5. Engineering Best Practices

    Turning this formula into a deliverable product requires attention to the following points:

    1. Define responsibility boundaries first: Do not try to cram every capability into the model through prompts; leave memory, tools, and execution to the harness.
    2. Prioritize safety: High-risk operations involving files, terminals, and networks must be isolated, confirmed, and audited.
    3. Drive iteration with evaluation: Build a quantifiable evaluation set first, then optimize context strategies and tool design, avoiding tuning by intuition.
    4. Adopt a plugin-based layered design: Keep the core stable and extend capabilities as plugins to reduce long-term maintenance costs.
    5. Think in closed loops: Make “execute—feedback—correct” the default working mode rather than a one-time call.

    In summary, “Model + Harness = Agent” is not a slogan but a practical engineering methodology. It reminds us that what truly determines the success of an agent product is often not the model itself, but the harness built around it. Understanding this is what allows general model capabilities to be reliably transformed into agent products that can enter real-world workflows.