Why Enterprises Build Their Own Agent Harness
This article explains why many enterprises invest engineering resources in a custom agent harness instead of relying only on off-the-shelf agent products. It separates model capability from the harness layer, breaks down what a harness handles (context management, tool execution, state persistence, retries, termination, and human approval), and shows why instruction files alone cannot enforce hard constraints such as approvals, budgets, access scope, and audit trails. It also covers common adaptation needs, a practical decision method for classifying constraints before choosing between configuration and custom development, and the role of general cloud capabilities in supporting deployment and operations.
Why Enterprises Build Their Own Agent Harness
In discussions about deploying agents in the enterprise, one question keeps coming up: if mature agent products already exist, why do so many companies spend engineering resources building their own harness, and even create dedicated engineering roles for it? To answer this, you first need to separate two things completely: model capability and the harness.
What a Harness Actually Does
The core capability of a large language model is reasoning and generation. On its own, it does not naturally “keep working until a task is finished.” What moves a model into a production workflow is the surrounding system wrapped around it, commonly called a harness. Its responsibilities break down into several layers:
- Context management: deciding which information goes to the model, in what order, within which time window, and how to compress or drop content as the context approaches its limit.
- Tool supply and execution: defining the set of capabilities the model can call, validating arguments, running them, and writing results back.
- State persistence and recovery: saving intermediate outputs, completed steps, and pending items so long-running tasks can be interrupted and resumed.
- Failure handling and retries: distinguishing retryable from non-retryable errors, and designing backoff strategies and fallback paths.
- Termination and human intervention: deciding whether the goal has been met, when to stop, and which actions require human approval.
One common confusion is worth clearing up: this is an agent harness, not an evaluation framework used to set tasks and score results. The former is about how to get a task done; the latter is about how well it was done. Both often exist in engineering practice, but their goals and implementations are entirely different. At the same time, no usable AI coding tool is a “bare model.” Every one of them contains a scenario-specific harness internally; that part is simply not exposed as a configurable surface.
Why Writing Rules into an Instruction File Is Not Enough
A natural follow-up question: if you put repository conventions, testing requirements, and permission boundaries into a project instruction file and have the model read it every time, is that enough?
It is not, because two kinds of constraints have different natures. Telling the model what it should do is not the same as having the system restrict what it can do. The first relies on the model’s attention and memory stability over long text, which makes it a probabilistic constraint. The second is enforced by an external execution layer, which makes it a deterministic constraint.
A few typical scenarios:
- Approval before production changes. Written into an instruction file, the model will most likely comply, but once the context is crowded out by large volumes of logs, the chance of omission rises sharply. The reliable approach is to have the tool layer or permission system directly reject operations that do not carry an approval credential.
- Cost budget control. A budget is a hard numerical boundary. It should not depend on the model “remembering not to spend too much”; cumulative metering and a circuit breaker belong on the calling side.
- Data access scope. The principle of least privilege must be implemented by the identity and authorization system, not by self-restraint in a prompt.
- Audit trail. Who triggered which action at what time needs to be written by the system into tamper-resistant logs. A model’s own account cannot serve as an audit basis.
A schematic view of the constraint layers:
User goal↓Policy layer (hard constraints: permissions, budget, approval, audit) ← enforced by the system↓Harness (context, tools, state, retries, termination)↓Model reasoning and generation (probabilistic compliance with instruction files)
This does not mean existing solutions offer only prompt-based constraints; mature AI coding tools have their own permission controls. What an enterprise really needs to judge is whether the existing mechanisms cover its compliance and process requirements, rather than deciding to build from scratch the moment it hears the phrase “hard constraints.”
Enterprise Needs Usually Center on Adaptation, Not Rewriting
From actual feedback, the customization points enterprises care about cluster in a few areas: integration with internal systems, embedding into CI pipelines, connecting to code review workflows, isolating data permissions, and keeping costs controllable and attributable. What these needs share is that they do not change the model, but they determine whether the model can work reliably inside existing organizational processes.
One concrete engineering example is handling test output. A full test log can easily run to tens of thousands of lines. Handing it to the model directly consumes the context budget quickly and drives up cost at the same time. A more sensible approach is to trim it before the tool returns: keep failing assertions, exception stacks, and relevant files and line numbers first, fold the rest into a searchable summary, and expand details only when the model explicitly asks.
def compress_test_output(raw: str, keep: int = 200) -> str:lines = raw.splitlines()key = [l for l in lines if any(k in l for k in ("FAIL", "Error", "assert"))]head = key[:keep]return "\n".join(head) + f"\n... {max(0, len(lines) - len(head))} lines omitted, searchable on demand"
This kind of work looks plain, yet it directly determines task completion rate and cost per task. Similar adaptation points include wrapping internal services as controlled tools, running batch jobs headlessly inside a pipeline, and feeding structured review comments back as the next instruction.
Decision Method: Classify Constraints First, Then Decide What to Invest
To turn “do we need to build our own” into an actionable judgment, work through the following order:
- List all hard constraints: compliance, permissions, budget, audit, and data residency.
- Check one by one whether existing solutions can meet them through configuration, plugins, tool extensions, or process integration.
- If all can be met, prefer configuration and integration, and avoid the long-term cost of maintaining a self-built framework.
- If the way of running is itself different (for example, long-running tasks that need suspension and recovery, multi-role collaboration, or a special tool protocol), customization has clear value.
- Whether you build or not, plan evaluation and observability together; otherwise you cannot quantify the benefit of a change.
Conclusion
Always keep two questions separate: whether the model is capable of completing a task, and whether the system can make it complete reliably under given conditions. The harness handles the latter. Whether an enterprise needs to build its own should start from the specific constraints that existing tools cannot cover. What can be solved through configuration, tool extensions, and integration with internal processes does not require rewriting the entire framework; customization pays off clearly only when the way of running is genuinely different. In the general capability system of cloud platforms such as Baidu AI Cloud, categories like container platforms, message queues, object storage, log services, and monitoring and alerting are usually enough to support the deployment and operation of such a harness, keeping engineering effort focused on adapting to the constraints that are truly differentiating.
