How a Model and a Harness Form an Agent
A model supplies understanding, reasoning, and generation, but real workflows also need state, tools, side effects, and verification. This article explains why a model alone is not enough, what a harness covers, how the observe–reason–act–verify loop forms an agent, and how to ship and evaluate that system.
In agent engineering, attention often stays on the foundation model: parameter scale, reasoning depth, instruction following, and generation quality. Those capabilities are the agent’s cognitive base. Once a task leaves a chat demo and enters a real workflow, a model by itself is usually not enough. Files must be changed, commands must run, tools must be called, intermediate state must be recorded, failures must be rolled back, and results must be checked. Systematizing all of that work outside the model is the harness. A model combined with a harness is what becomes an agent that can operate in a business setting.
A simple division of labor captures the idea. The model understands, reasons, and generates. The harness connects those results to a real environment and continuously brings feedback back. An agent is not a model product shape on its own. It is an execution system that can plan, act, and verify. The sections below cover capability boundaries, core modules, a path to production, and the evaluation loop.
Why a model alone cannot enter a real workflow
A model is good at producing the next text from a given context: explaining a requirement, drafting a patch, or planning steps. A real workflow has properties the model does not naturally own.
First, state lives outside the model. Repositories, configuration, runtime environments, and ticket status are not inside the context window. They must be read and written through the file system, a terminal, or APIs. Second, actions have side effects. Changing code, running scripts, or calling internal services can succeed, fail, or partially succeed. Permission boundaries, audit trails, and rollback policies are required. Third, tasks are long-running. One session often spans many tool calls, multi-file edits, and several rounds of verification. That needs memory, checkpoints, and task planning, not a single generation. Fourth, correctness must be testable. The business needs a task that is finished and verifiable, not one that only looks finished.
Connecting a model directly to business work therefore fails in familiar ways: truncated context causes forgetting; tool-call formats are unstable; plans are optimistic but not executable; logs and test results are not collected after execution; and without evaluation there is no way to iterate. The harness exists to close those gaps.
What the harness covers: everything outside the model
A harness should not be treated as one plugin. It is the runtime that connects the model to the workflow. Its capabilities usually fall into the following groups. They are coupled, and leaving one out breaks the system.
Context management. This includes system prompts, task briefs, repository summaries, relevant code snippets, prior tool results, and the selection and compression of error stacks. The goal is not to pack in as much as possible. It is to keep high-signal information that matters to the current decision inside a limited window. A common engineering approach is layering: stable roles and conventions in a long-lived layer; the current goal and constraints in a task layer; retrieved code and recent execution results in a working layer, trimmed by priority.
Tool calling. The model outputs intent. The harness turns that intent into an executable call: read a file, write a file, search, run tests, or query an internal API. This needs a strict protocol: parameter validation, timeouts, retries, permission allowlists, and a second confirmation for sensitive operations. Tool results must be returned in a structured form, not dumped back into the model as raw noise.
Task planning and decomposition. Complex work should be split into verifiable subgoals: locate the problem, propose a change, apply the change, run checks, and replan from failures. The model may generate the plan, but scheduling, dependency order, and parallelism limits should be controlled by the harness so the model does not spin on hallucinated steps.
File and code operations. Reads and writes need path constraints, encoding handling, diff previews, and conflict detection. For code changes, prefer a reviewable diff over overwriting a whole file. Combined with static checks and tests, “it looks like it compiles” becomes “it passes the defined gates.”
Terminal and runtime execution. Command execution should be isolated, auditable, and interruptible. Standard output, exit codes, and elapsed time should enter the feedback channel. Destructive commands should be denied by default or require explicit authorization.
Feedback and the evaluation loop. After each action, the harness should collect whether it succeeded, key logs, test results, coverage, and the gap against acceptance criteria. That feedback drives retries in the current run and also becomes material for later evaluation sets, so agent capability can be measured instead of judged by impression.
How an agent forms: model capability times engineering constraints
An agent can be described as a loop of observe, reason, act, and verify under harness constraints. The model supplies the policy. The harness supplies the observation channel, the action channel, and the stop conditions.
A typical loop works as follows. The harness assembles the task goal, a repository snapshot, and the list of available tools into context and passes it to the model. The model proposes the next step: for example, read a module, propose a patch, or run tests. The harness validates and executes that step, compresses the result, and appends it to the context. If tests fail, the model adjusts from the failure. If failures continue or a budget is exceeded—steps, time, or cost—the harness stops and returns a diagnostic report. On success, it outputs a change summary, the diff, and verification evidence.
A few engineering principles matter here.
Give determinism to the system and uncertainty to the model. Path resolution, permissions, format checks, and retry policy belong in the harness. What to change, and why, is the model’s decision.
Keep side effects inside a sandbox. Default to least privilege, make writes replayable, and isolate the execution environment from production.
Turn long tasks into a recoverable state machine. Save checkpoints: files already read, patches already applied, tests already run. After an interruption, resume from that state instead of starting the conversation over.
Put acceptance criteria first. At the start of the task, state which tests must pass, which interfaces must not break, and which files must not be changed. Otherwise the model tends to optimize for looking done.
The pseudocode below only shows control flow. It does not correspond to any specific product interface:
state = init(task, repo_snapshot, tools, budget)while not state.done and state.cost < budget:ctx = assemble_context(state)plan = model.infer(ctx) # understand and planaction = validate(plan, policy) # harness constraintsresult = execute(action) # files, terminal, toolsstate = update(state, result) # collect feedbackif meets_acceptance(state):state.done = Truereturn report(state)
From a demo agent to an operable product
To apply this formula in a product, slice by workflow instead of aiming first for an all-purpose assistant.
Choose tasks with clear boundaries: defect fixes, test completion, configuration checks, keeping docs in sync with code, or generating repetitive operations scripts. For each class of task, define the input artifacts, allowed tools, acceptance commands, and failure categories.
Build a tool layer rather than stacking prompts. Stable retrieval, diff application, and a test runner are more effective than an ever-longer system prompt. Prompts should describe conventions and decision principles. Details should come back from tools.
Use general-purpose capabilities such as logging, object storage, and a container platform to support the runtime: an execution sandbox, artifact archival, and trajectory replay. Monitoring and alerting should watch abnormal step counts, tool failure rates, and acceptance pass rates, not generation speed alone.
Design human collaboration into the loop. High-risk changes need human confirmation. Low-risk steps that can be verified automatically may proceed on their own. The value of an agent is to shorten the loop, not to bypass governance.
Evaluation: without a closed loop there is no agent quality
Evaluation should cover the trajectory, not only the final text. At minimum, track four kinds of metrics: task success (whether acceptance criteria are met); efficiency (steps, retries, and elapsed time); safety (privilege violations and the rate at which dangerous commands are blocked); and recoverability (whether a run can resume after interruption and whether errors are located accurately).
When building scenario sets, use real failure logs and repository fragments, including dirty cases such as incomplete context, failing tests, and insufficient permissions. Regression-test that set on every harness or prompt change so a better demo does not become a worse production system.
Also feed sanitized production trajectories back in: which tool results the model misread, and which planning steps were unnecessary. Evaluation is not a one-time benchmark. It is an asset that evolves with the harness.
Closing
Model + harness = agent describes a split of responsibility. The model provides understanding, reasoning, and generation. The harness provides context governance, tools and runtime, planning and scheduling, file and terminal operations, and feedback and evaluation. An agent is their product. A product means that if either side is weak, the whole result approaches zero. When building agents for real workflows, treat the harness as a first-class design concern: constrain side effects, structure observation, set acceptance criteria up front, and close the loop with measurement. Only then does model capability become reliable task completion, rather than a correct-looking pose inside a conversation.
