The Universal Formula for Agent Development: Model and Harness

    This article explains a common engineering formula for building AI agents: Model + Harness = Agent. It breaks down what the base model contributes, why the surrounding harness is often underestimated, and the eight coupled subsystems that make up the harness, including context management, tool calling, task planning, file editing, terminal execution, feedback collection, evaluation loops, and runtime governance. It also covers how to combine the two layers, common failure patterns and their fixes, and a practical three-step path for moving agents from demos to stable production systems.

    1. Background: Why an Agent Is Not Just a “Bigger Model”

    A common misconception in discussions about AI agents is that quality problems can all be traced back to model size: swap in a stronger model, and the agent will naturally work well. Engineering practice repeatedly shows otherwise. The same model, wrapped in different surrounding engineering structures, can vary enormously in its success rate on real tasks. The industry has therefore converged on a simple development formula:

    1. Model + Harness = Agent

    Here, the Model is the base model with capabilities for understanding, reasoning, and generation. The Harness refers to all engineering structure outside the model. The Agent is the system that results from combining the two, able to enter a real workflow and continuously produce results. The value of this formula is that it separates “intelligence” from “engineering”: the model sets the upper bound of capability, while the harness determines whether that capability can be delivered reliably.

    It is worth stressing that this formula expresses a general engineering consensus in the industry, not a proprietary claim from any single vendor. Every team building agents faces the same layering problem.

    2. Model: The Reasoning Foundation and Capability Boundary

    In the formula, the model plays the cognitive role: parsing natural-language instructions, maintaining intent consistency across multiple turns, reasoning over complex constraints, and generating structured output. Selection typically focuses on four general criteria:

    • Instruction following: whether it strictly adheres to output formats, role settings, and prohibited actions;
    • Long-context handling: locating key information within large amounts of reference material without losing mid-context information;
    • Structured output stability: producing valid structured data (such as JSON) and supporting field constraints;
    • Tool-use tendency: raising a call request at the appropriate moment rather than fabricating results out of thin air.

    At the same time, the model’s inherent boundaries must be acknowledged: knowledge has a cutoff date, it cannot perceive the real-time state of the runtime environment, it cannot actually write files or run commands, and it lacks a natural sense of memory and pacing for very long tasks. These gaps are not closed by switching models; they are filled by the harness. Recognizing the boundary clearly is the prerequisite for designing the harness.

    3. Harness: The Underestimated Engineering Body

    The harness is the middle layer connecting the model to the real workflow. It can be broken into eight coupled subsystems.

    3.1 Context Management

    Context is the agent’s only “working memory” and the first resource to be exhausted. In engineering terms, it is usually organized in layers: a system layer for the role and hard constraints, a task layer for goals and acceptance criteria, a reference layer for retrieved snippets, and a history layer for compressed conversation summaries. Rolling summaries are used for very long histories, and on-demand retrieval rather than full injection is used for reference material.

    3.2 Tool Calling

    Tools are the hands that turn model intent into real side effects. The design requires semantically clear names and descriptions, parameters with type and value constraints, and readable error messages. Tool returns should be short and structured, avoiding feeding back too much content at once and crowding out the context.

    3.3 Task Planning

    For multi-step tasks, the harness needs to break the goal into verifiable subgoals and decide on serial, parallel, or conditional branching. A common approach is to maintain an explicit plan checklist, updating the state after each completed step so the model always sees a clear boundary between “done” and “to do.”

    3.4 File Reading/Writing and Code Modification

    This is the core of agentic coding scenarios. The harness must provide controlled read, search, write, and diff-edit capabilities, and enforce small-step modification: change only the locations relevant to the current subgoal each time, verify immediately after, and avoid large-scale rewrites that cause regressions.

    3.5 Terminal Execution

    Command execution gives the agent verification and build capabilities, but also carries the highest risk. A working-directory allowlist, command classification, timeouts and resource limits must be set, and irreversible operations such as deletion, pushing, and deployment must require explicit confirmation.

    3.6 Feedback Collection

    Execution results, compile errors, test failures, and API exceptions should all be cleaned into model-readable Observations, with key context attached rather than raw long logs. Feedback quality directly determines the efficiency of self-correction.

    3.7 Evaluation Loop

    An agent without evaluation cannot iterate. A fixed task set and automatic judging rules should be established, recording the pass rate, average number of steps, and distribution of failure types for each change, so optimization moves from subjective impressions to quantifiable comparison.

    3.8 Runtime Governance

    This includes permission isolation, sensitive-information redaction, full-chain logging, and cost quotas. Governance is not optional; it is the threshold for an agent to enter production.

    4. Composition Logic: From Model Capability to a Deliverable Agent

    The key to composition is not piling the two together, but designing a clear contract of responsibilities: the model is responsible only for decisions and generation and never touches the environment directly; the harness is responsible for execution, validation, and state maintenance, and standardizes results before returning them. A sketch of the structure is as follows:

    1. def run_agent(task, model, harness):
    2. ctx = harness.build_context(task) # context assembly
    3. plan = harness.make_plan(task) # task planning
    4. for step in plan.pending():
    5. decision = model.decide(ctx, harness.tool_specs())
    6. if decision.type == "tool":
    7. result = harness.execute(decision) # controlled execution
    8. ctx = ctx.append_observation(result) # feedback collection
    9. else:
    10. ctx = ctx.append_answer(decision.text)
    11. if harness.verify(step):
    12. plan.mark_done(step)
    13. return harness.evaluate(ctx) # evaluation loop

    This pseudocode embodies three principles: side effects happen only inside the harness; every step has a verifiable completion criterion; and the final output must go through evaluation rather than being accepted on the model’s own say-so.

    5. Common Failure Modes and Fixes

    • Context bloat: full injection of material dilutes key information; switch to retrieval plus summarization;
    • Vague tool descriptions: the model picks the wrong tool or parameters; add type constraints and positive/negative examples;
    • One-shot large changes: an overly broad modification scope triggers regressions; switch to small-step edits with immediate verification;
    • Unreadable feedback: raw logs are too long; apply structured trimming;
    • Missing evaluation: it is impossible to tell whether a change is progress or regression; build the task set before talking about optimization.

    6. Implementation Advice

    On the enterprise side, a general cloud foundation can be used: a container platform to host runtime isolation, object storage to hold artifacts and datasets, a message queue to decouple long tasks, and logging services with monitoring and alerting for observability and quota control. General-purpose capabilities from cloud vendors such as Baidu AI Cloud can serve as the hosting environment for this kind of layered architecture, but the architecture itself is vendor-independent.

    A practical path is suggested in three steps: first, solidify the evaluation set for a single scenario; then, complete the permissions and validation for the tool and execution layers; finally, extend to multi-task planning and parallel scheduling. By following the division of labor in which “the model handles thinking and the harness handles delivery,” an agent can move from a demo to a stable, deliverable production system.