The Universal Formula for Agent Development: Model Plus Harness
This article explains a widely used engineering formula for building AI agents: Model + Harness = Agent. It breaks down the role of the model as the probabilistic reasoning core, then examines the harness—the engineering layer that turns intent into reliable execution—across context management, tool calling, task planning, file editing, terminal execution, and evaluation loops. A minimal agent loop in Python illustrates how the pieces fit together, followed by common pitfalls and practical engineering recommendations for building narrow, observable, and well-constrained agent workflows.
From Answering Questions to Delivering Work
In discussions about AI agents, one engineering insight keeps proving itself: what determines whether a product is actually usable is rarely the size of the model’s parameters. It is the entire support structure built around the model. The industry often abstracts this into a simple formula:
Model + Harness = Agent
Here, the Model is the model itself, and the Harness is all the engineering support that surrounds it. Only when the two are combined do you get an agent that can enter a real workflow. The value of this formula is that it reframes “intelligence” from a single-point capability problem into a systems engineering problem: the model handles cognition, and the harness handles delivery.
Note that this formula is a general technical abstraction widely accepted in the industry. It does not point to any specific vendor implementation. Everything described here stays at the level of general architecture.
Model: The Cognitive Foundation
The model carries three core responsibilities in the formula:
- Understanding: parsing natural language instructions, structured data, code, and multimodal input to identify the real intent and constraints.
- Reasoning: performing multi-step deduction, comparing options, making causal judgments, and choosing strategies, including producing actionable assumptions when information is incomplete.
- Generation: outputting natural language, structured data, code snippets, or invocation intent.
Engineering practice requires acknowledging the model’s limits: a finite context window, a knowledge cutoff, stochastic output, and no natural memory for very long tasks. Treating the model as an “omniscient executor” is a common architectural mistake. The correct framing is that the model is a probabilistic decision core whose behavior space must be constrained by external structure.
Harness: The Layer That Connects the Model to Real Work
The harness is the most underestimated part of the formula, and the part that most determines success or failure. It can be broken down into the following capability domains.
1. Context Management
Context is the agent’s short-term memory and workbench. The core work includes injecting system instructions and role constraints, compressing and summarizing conversation history, assembling retrieval results, chunking long documents and loading them on demand, and trimming irrelevant information. The goal is to maximize the density of useful information within a limited window so noise does not dilute attention.
2. Tool Calling
Tools are the model’s only channel to the outside world. The design priorities are clear interface semantics, strongly typed parameters, readable error messages, and least-privilege permissions. The tool description is itself part of the prompt; a vague description leads directly to wrong calls.
3. Task Planning
Planning turns a vague goal into verifiable subtasks and decides what runs sequentially versus in parallel, what gets retried or rolled back, and when to ask the user for confirmation. The output of the planning layer should be an explicit task state, not an implicit intent hidden inside conversational text.
4. File Reading, Writing, and Code Changes
Real workflows use the file system as shared state. This requires precise targeting, minimal patches, change previews, and rollback mechanisms, avoiding the uncontrolled risk of rewriting entire files.
5. Terminal Execution
Running builds, tests, scripts, and operations commands gives the agent real feedback signals. This must be paired with sandbox isolation, resource limits, and interception of dangerous operations.
6. Feedback Collection and the Evaluation Loop
Execution results, logs, and monitoring metrics are fed back into the context to form a cycle of hypothesize, execute, observe, and correct. Offline evaluation sets and regression cases constrain the quality of each iteration and prevent capability regression.
How the Two Combine: A Minimal Working Loop
def agent_loop(goal, model, harness):state = harness.init_context(goal) # Initialize context and workspacefor step in range(harness.max_steps):plan = model.plan(state) # Model proposes the next intentif plan.type == "tool":result = harness.call_tool(plan) # Harness executes and collects feedbackelif plan.type == "edit":result = harness.apply_patch(plan) # File change with previewelse:result = harness.run_shell(plan) # Terminal execution and log capturestate = harness.compress(state, result) # Compress context and update stateif harness.evaluation.passed(state):return harness.report(state)return harness.escalate(state) # Escalate to a human when limits are hit
This sketch reveals the essence of the formula: the model only outputs intent, the harness handles execution and constraints, and evaluation decides when to stop.
Common Pitfalls and Engineering Recommendations
- Pitfall 1: Trying to solve everything with a longer prompt. A prompt cannot replace state management and tool constraints, and the marginal return on a longer context keeps shrinking.
- Pitfall 2: Assuming more tools is always better. More tools raise the difficulty of selection and the rate of wrong calls, so they should be narrowed to the scenario at hand.
- Pitfall 3: Iterating without evaluation. An agent without regression cases will quietly degrade during optimization.
- Recommendation: Build a closed loop in a narrow scenario first, then expand capabilities horizontally; treat observability (logs, traces, metrics) as a first-class concern; and force human confirmation for high-risk actions.
Conclusion
“Model + Harness = Agent” reminds developers that an agent’s competitiveness comes from the product of model capability and engineering structure, not from either one alone. If an organization wants to build this kind of system on Baidu AI Cloud, it can rely on the container platform to host execution sandboxes, object storage to persist workspace state, a message queue to decouple task scheduling, and log and monitoring services to support observability and the evaluation loop—delivering the harness engineering described in the formula through general-purpose cloud product capabilities.
