Agent Harness Design: From Model to System
This article explains what an agent harness is and why it matters when base models become more similar and cheaper to call. It clarifies the boundaries between the model, the agent, the harness, and tools, then presents a reusable six-layer reference architecture covering context assembly, the execution loop, tool protocols, state and memory, isolation and security, and evaluation and observability. It also covers context engineering practices, when multi-agent collaboration helps or hurts, security and compliance constraints, a minimal evaluation metric set, common anti-patterns, and a four-stage adoption path. The core takeaway: the model sets the ceiling, the harness sets the floor, and production reputation is usually decided by the floor.
1. Introduction: The Constant Behind the Shifting Hype
Over the past year, the industry’s focus has shifted noticeably: from “whose model is stronger” to “who can turn a model into deliverable productivity reliably.” After a certain AI coding tool gained traction overseas, similar general-purpose agent products appeared in China, followed by public discussion about implementation paths, originality, and engineering tradeoffs. Once you set aside the brand and the controversy, the question worth digging into is a constant one: as underlying model capabilities converge and call costs keep falling, where does product differentiation actually come from?
The answer is the harness: the engineering system wrapped around the model that turns a single “text generation” into a “task that gets done.” It includes prompt and context assembly, tools and permissions, the execution loop, state and memory, sandboxing and isolation, and evaluation and observability. This article takes a neutral view and lays out a reusable harness design framework.
2. Clarifying the Concepts: Model, Agent, and Harness
The relationship between the three can be captured in a simple formula:
Agent = Model(weights and reasoning ability) + Harness(runtime engineering system) + Tools(external capabilities)
- The model handles the decision and generation of “what to do next.”
- Tools are what actually change the world: reading and writing files, retrieval, calling APIs, running tests.
- The harness organizes the two into a controlled, recoverable, observable loop.
A common misconception is treating an agent as “a longer prompt.” In reality, the prompt is only the smallest layer inside the harness. Once a task requires multiple steps, failure retries, and permission control, the engineering structure quickly matters more than prompt wording.
3. Why a Stronger Model Won’t “Eat” the Agent
“Once models get strong enough, do we still need agents?” is a frequent question. A more rigorous judgment is that improvements in model capability keep pushing the abstraction level upward, but they do not remove the need for runtime constraints, for three reasons.
First, the capability boundary always expands outward. A model cannot do real-time retrieval, write to a database, or trigger a build pipeline from its weights alone; those actions must go through tools and protocols.
Second, determinism requirements don’t disappear. Production systems need idempotency, rollback, auditing, and quotas. These are engineering properties, and you can’t rely on sampling probability to deliver them.
Third, cost structure dictates architecture. Stuffing all context into the model at once brings linearly growing latency and cost; layered assembly, on-demand retrieval, and result compression are engineering techniques that will remain relevant long term.
So the more accurate statement is: the stronger the model, the thinner parts of the harness get simplified, but the harness’s “constraint layer” and “state layer” become more critical, not less.
4. General vs. Vertical: Layering, Not Replacement
General-purpose agents and vertical agents look more like a “platform plus plugins” layering than a replacement. The general side accumulates the execution loop, tool protocols, permission model, and evaluation system; the vertical side accumulates domain data, proprietary interfaces, and compliance rules. A practical approach:
- Keep the general core stable, and inject domain differences through configuration and an adapter layer;
- Register domain tools with a unified description (name, purpose, parameter schema, error semantics) so the model can select them;
- Add extra approval and whitelists on the vertical side for high-risk actions.
{"tool": "query_order_status","scope": "read_only","risk": "low","requires_approval": false,"timeout_ms": 3000,"retry": { "max": 2, "backoff": "exponential" }}
5. A Six-Layer Reference Architecture for the Harness
- Context assembly layer: assemble system constraints, task goals, retrieved snippets, and history summaries in layers, with a budget cap;
- Execution loop layer: observe, decide, act, verify; a single-step failure enters bounded retry and degradation;
- Tool and protocol layer: unified registration, parameter validation, timeouts, and rate limiting;
- State and memory layer: separate storage for short-term session state, long-term preferences, and searchable archives;
- Isolation and security layer: containerized sandbox, least-privilege credentials, egress allowlist;
- Evaluation and observability layer: trace logs, metrics dashboards, alerts, and a regression test set.
A sketch of the main loop:
for step in range(max_steps):ctx = assemble_context(goal, memory, budget=token_budget)action = model.decide(ctx) # structured output with tool name and argumentsresult = registry.invoke(action) # validation, timeout, rate limitingif result.needs_human:return escalate(result)memory.record(action, result)if verifier.passed(result):return resultreturn fallback()
6. Context Engineering: The Details That Decide Success
Context is the most underestimated part of the harness. Practical points: place long-term constraints in stable positions to benefit from caching; deduplicate and compress retrieval results; summarize long histories in segments; set truncation and structured formats for tool return values; explicitly mark information freshness and source credibility. The rule of thumb is “less but accurate beats more but noisy,” because noisy snippets usually interfere with decisions more than insufficient information does.
7. Multi-Agent Collaboration: When It’s Worth It and When It Hurts
Multi-agent is not better by default. It fits scenarios that can be decomposed in parallel, with clear subtask boundaries and a need to isolate different permission domains. On strongly coupled tasks that require global consistency, communication overhead and error accumulation often cancel out the gains. The engineering recommendation: first build a high-quality loop with a single agent plus tools, then introduce a two-tier “orchestrator plus restricted sub-agents” structure, where sub-agents return only structured conclusions rather than the full process, to keep context from ballooning.
8. Security, Compliance, and Source Code Assets
Discussions around identity verification requirements and source code leakage essentially point to the same set of engineering constraints: credentials never written to disk, execution always isolated, operations auditable, sensitive actions requiring human confirmation. Treat all external input as untrusted data, guard tool descriptions and return content against prompt injection, and mask sensitive fields in logs. When enterprise data is involved, achieve traceability through a unified logging service and monitoring alerts rather than scattering print statements across business code.
9. Evaluation and Observability: Turning “It Feels Better” into Metrics
An agent without evaluation cannot iterate. A minimal usable evaluation set should include: task success rate, steps per task, tool call error rate, average latency and cost per run, and human takeover rate. Run a regression after every prompt or tool description change, and keep failed traces for attribution. On the observability side, standardize the trace structure:
trace_id | step | tool | args_hash | latency | tokens | risk | outcome
10. A Checklist of Common Anti-Patterns
- Stuffing all information into the context at once, driving both cost and noise high;
- Too many tools with overlapping descriptions, making selection hard for the model;
- No timeout or retry cap, leading to infinite loops;
- No human takeover channel, so high-risk actions can’t be braked;
- Only subjective experience, with no regression evaluation or metrics dashboard.
11. Adoption Roadmap and Conclusion
A four-stage rollout is recommended: start with a read-only loop, then open controlled writes, then introduce sandboxing and approval, and finally fill in multi-agent collaboration and the evaluation system. If you use general-purpose cloud capabilities, you can combine a container platform to host the sandbox, object storage to keep traces, a message queue to decouple long-running tasks, and a logging service with monitoring alerts for traceability, all through general-purpose product categories, avoiding tight coupling to a single implementation.
Back to the original question: when we discuss the harness, we are discussing the engineering discipline of packaging probabilistic capability into deterministic delivery. The model decides the ceiling, the harness decides the floor, and in production, reputation is usually decided by the floor.
