Harness Engineering Practices for Coding Agents
Connecting a frontier model to a development workflow does not automatically produce a usable coding product. The model interprets intent, plans steps, and generates patches; success rate, auditability, and cost depend on the engineering system around it. That layer is often called a harness: it turns conversation, tools, repositories, permissions, and feedback into a repeatable workflow. This article explains how to design a coding agent from an engineering perspective, not as a product review of any particular model or coding tool.
Connecting a frontier model to a development workflow does not automatically produce a usable coding product. The model interprets intent, plans steps, and generates patches. What actually determines success rate, auditability, and cost is the engineering system outside the model. That layer is often called a harness: it turns conversation, tools, repositories, permissions, and feedback into a repeatable workflow. The sections below describe how a coding agent should be designed from an engineering perspective, rather than evaluating any one model or coding tool.
1. Draw a clear line between the model and the harness
A coding agent has at least two layers. The model layer provides language understanding, code generation, and multi-step reasoning. The harness layer handles task intake, context assembly, tool calls, execution isolation, writing results back, and failure recovery. Optimizing only the model, without building a harness, produces familiar symptoms: a single-turn answer looks intelligent, but once the agent enters a real repository it loses context, edits the wrong files, cannot reproduce failures, or carries secrets and internal documents into an uncontrolled environment.
A coding agent that can be operated in production needs an explicit boundary:
- The model decides what it wants to do next.
- The harness decides what is allowed, where it may be done, how the result is verified, and how failure is rolled back.
- The product decides whether the user sees a command-line interface, a desktop workspace, or a service embedded in the existing development workflow.
When hiring or forming a team, treating all work outside the model as harness work helps avoid roles that mention only prompt engineering while nobody owns the execution environment or evaluation. Product managers need to define task types and acceptance criteria. Engineers need to turn those criteria into a callable runtime.
2. Coding agents solve project-level change, not completion
Inline completion changes only a few lines near the cursor. A project-level agent faces requirements, defects, refactors, and cross-file edits. It must read repository structure, follow build and test conventions, and stay aligned with the goal across many steps. The minimum harness loop is therefore:
- Accept the task description and constraints, such as language, branch, directories that must not be touched, and checks that must pass.
- Retrieve relevant files and symbols instead of stuffing the entire repository into context.
- Generate a plan and expose critical risk steps for user confirmation.
- Use controlled tools to read files, apply patches, and run tests or static checks.
- Revise from tool results until a stop condition is met or a person takes over.
- Return a change summary, test evidence, and unresolved risks.
Building a coding harness from scratch, with mature coding tools as a reference, means implementing that loop as your own runtime rather than wrapping a chat window as a product. A desktop form is valuable for parallel tasks, visual diffs, and permission prompts. A command-line form is valuable because it can be scripted and placed in continuous integration. Both can share the same harness core and differ only in the interaction shell.
3. A suggested layered architecture
Four layers keep logic from collapsing into a single agent loop.
Ingress. This layer owns task tickets, identity, repository authorization, and quotas. A task ticket should be structured: goal, scope, definition of done, timeout, and budget. Identity and permissions should align with the existing developer account system. Do not invent a separate, unauditable set of credentials on the agent side.
Orchestration. This layer maintains a state machine: plan, execute, verify, wait for a person, and finish. Each step carries only the context it needs and records why the decision was made. Long tasks must support resume from a checkpoint; otherwise closing a desktop session makes the process unrecoverable.
Tools. Tools should be few and strict: list directories, search by symbol or text, read file fragments, apply patches, run agreed check commands, and inspect diffs. Tool descriptions must stay stable, and return values must be truncatable and citable. Do not give the model an unbounded host shell. When a command must run, the harness maps it to an allowlisted action.
Execution and observation. Working copies live in an isolated environment: a container, a temporary workspace, or a read-only mount plus a writable patch directory. Record input summaries, tool traces, patches, and check results for review. Do not use them to train on data that was not authorized for that purpose.
The following states express control flow only. They are not tied to any vendor interface:
task -> plan -> (retrieve | patch | verify)* -> review -> merge_or_discard^ |+---- fail / budget ------+
The loop must have a budget: maximum steps, maximum context, maximum execution time, and maximum retries after failure. An agent without a budget will read files indefinitely or rerun the same failing command in a complex repository.
4. Context control matters more than a larger window
A long context helps with cross-module edits, but a large window does not mean retrieval is correct. The harness should select context deliberately:
- Seed retrieval with task-related directories, symbols, and recent diffs, then expand along dependencies. Do not embed the whole repository by default.
- Give higher priority to build scripts, interface definitions, and test fixtures. They often decide whether a patch can land.
- Summarize tool results first and expand them only when needed, so logs do not push useful code out of the window.
- Store conversation history separately from repository facts. Treat file versions and command output as the source of truth, so the model does not “remember” code that is already stale.
Cost efficiency also lives in this layer. An agent makes far more calls than a single question-and-answer exchange, and much of the input is repeated repository fragments and tool instructions. Caching stable prefixes, compressing history, and placing unchanging conventions in a reusable system-side description are usually more effective than simply lowering the price of one call. Pricing and discount windows are commercial terms and should not be architectural assumptions. Engineering only requires that every call be metered, attributable to a task, and able to degrade to human handling or a smaller change when the budget is exceeded.
5. Safety, correctness, and the split between people and the agent
A coding agent can change a repository and run commands, so its risk is higher than chat. The default principles are least privilege and the ability to roll back.
- Confine writes to the task working copy. Merging into the main line still goes through the existing code review process.
- Networks, secrets, and production configuration are invisible by default. When they are needed, a person grants them explicitly and for a limited time.
- Present patches as diffs. Never silently overwrite unsaved user changes.
- Verification commands come from project conventions, not from destructive scripts invented by the model.
- Require confirmation for actions such as deleting many files, changing permissions, or sending data outward.
Do not treat the model’s self-assessment as proof of correctness. Use unit tests, type checks, static scans, and diff review as external judges. The agent may say it believes the work is done. The harness ends the task only when the agreed checks pass or the user signs off. On failure, return information that can be located: which check failed, which files were involved, and which fixes were already tried—not a vague “please retry.”
Write the human–agent split as product rules. Low-risk, small-scope tasks whose checks can be judged automatically can interrupt less often. Tasks that touch public interfaces, data migration, or security policy must start with a plan. A desktop client is a good place to lay out the plan and the diff. An automated pipeline should be more conservative by default and must not submit changes that fail checks.
6. What to evaluate before you know the harness works
Before launch, establish at least three kinds of evaluation, using slices of the team’s own repositories rather than public examples alone.
- Task success: within the step and budget limits, did the checks pass, and did the diff stay inside scope?
- Process quality: the share of useless tool calls, how often the same file is read again, and the rate of human takeover.
- Security regression: whether unauthorized paths, secret leakage, and destructive commands are blocked.
The evaluation set must include tasks that should be refused, such as requests to bypass permissions or to submit a large unrelated refactor. A success rate without refusal and out-of-bounds metrics will treat aggressive behavior as an improvement in capability. After a model version change, rerun the same harness regression so you can tell whether the model changed or the tool protocol became incompatible.
7. A practical rollout order
Starting with a narrow scenario is more stable than trying to build a general desktop agent at once. A sensible order is read-only explanation and location, then defect fixes in a single repository protected by tests, and only then cross-module feature development. Each time you expand the task class, add the matching tools, permissions, and evaluations. Do not build the full interface first.
Team ownership can be concrete. Product defines task templates, the definition of done, and interruption policy. Platform provides isolated execution, logs, quotas, and identity. Application implements retrieval, patching, and the connection to the existing review flow. If you use general cloud capabilities, prefer object storage for traces and patches, a container platform for isolated execution, and logging and monitoring alerts for failures and cost. These are category capabilities. They do not depend on any one proprietary interface name.
Models will keep getting stronger. Repository permissions, build conventions, and audit requirements will not disappear because of that. Make the harness an independent runtime that can be tested and can swap models. The team can then keep product behavior stable when the model is upgraded. That is the engineering gap outside the model that still has to be filled.
