How a Minimal Harness Reduces AI Agent Costs
This article examines why a minimal agent harness—the framework that assembles prompts, registers tools, schedules loops, and manages context—can lower the cost of running AI agents without sacrificing output quality. It outlines four baseline constraints of minimal harness design, explains how context discipline drives cost differences, and presents six practical methods for context governance, including context budgets, retrieval instead of preloading, history compression, lazy-loaded tool descriptions, turn-count optimization, and regression testing on real tasks. Readers will learn where agent cost actually comes from and how to build a measurable cost baseline.
How a Minimal Harness Reduces AI Agent Costs
1. The Core Debate: Should the Agent Framework Add More or Step Back?
In agent engineering, a long-standing disagreement centers on one question: should the framework that runs the model—commonly called the harness, meaning the sum of prompt assembly, tool registration, loop scheduling, and context management—keep stacking on capabilities, or should it get out of the way as much as possible and leave decisions to the model itself?
Most intelligent coding tools and general-purpose agent products today have taken the additive route: system prompts keep growing, tool counts keep expanding, and layers such as skill libraries, long-term memory, context compression, task planning, multi-agent collaboration, and various orchestration layers are piled on top. The implicit assumption is that a thicker framework makes a stronger agent.
That assumption is now being corrected in practice. One judgment worth taking seriously is this: the stronger the model, the more restraint the framework should show. Models already acquire a great deal of general capability during pre-training and post-training, so having the framework “teach it all over again” yields diminishing returns while adding a definite cost. What the framework genuinely needs to solve is the environment information the model cannot obtain on its own—repository structure, executable tools, test results—rather than repeatedly injecting common-sense methodology into prompts.
2. Four Default Constraints of the Minimal Approach
A typical minimal design usually includes the following constraints, which can serve as a design baseline:
- A minimal tool set: expose only a small number of core tools by default, such as reading files, writing files, executing commands, and search-and-locate. Fewer tools give the model a clearer choice space and a lower rate of wrong tool calls.
- A controlled total volume of prompts and tool descriptions: keep the system prompt plus all tool definitions within the thousand-token range, rather than thousands of lines.
- Capabilities that grow on demand: extra capabilities stay out of the default path and are loaded as extensions only when genuinely needed, then unloaded when done.
- Minimal state: keep only the intermediate state required to finish the task; everything else is excluded from the next turn’s context.
The essence of these constraints is not “fewer features” but converting complexity from a standing cost into an on-demand cost.
3. Where the Cost Difference Really Comes From: Context Discipline
Public engineering practice in the industry has shown a key phenomenon: with the same model and the same thinking effort, simply swapping the harness can produce more than a twofold difference in cost per task, while final quality stays roughly on par. One cloud vendor built a task set from real historical merge requests in its large-scale internal codebases, covering multiple mainstream programming languages and using real tests as the correctness criterion, and reached the conclusion above.
The main source of the difference is context. A minimal harness can feed the model several times less context per turn while maintaining a smaller working set and fewer turns. This can be summarized as context discipline:
- Context is not free. It is billed per turn, and every turn may be fed again.
- The framework itself is the largest hidden token consumer. Lengthy prompts, huge tool descriptions, and full memory retrieval results get priced repeatedly in every loop.
- The number of turns is a multiplier. Context size × turns = real cost; compressing either one helps, and compressing both compounds the effect.
A simplified cost illustration (only to show the order-of-magnitude relationship, not measured data):
Cost per task ≈ Σ(context tokens per turn × turns) × unit price + tool call and execution overheadOption A: 30K context per turn × 8 turns = 240K tokensOption B: 10K context per turn × 5 turns = 50K tokensWith comparable quality, the cost differs by roughly 4–5x
4. Practical Methods for Context Governance
1. Establish a context budget
Set separate limits for the system prompt, tool definitions, retrieval results, and message history, and enforce hard trimming at the assembly stage rather than relying on the model to “ignore things on its own.”
2. Replace preloading with retrieval
Instead of stuffing in knowledge that might be needed, provide a retrieval tool and let the model fetch what it needs on demand. Hit rates are usually far lower than expected, so the marginal benefit of preloading is low.
3. Compress history instead of replaying it in full
Produce a structured summary of completed history steps, keeping only conclusions, the list of modified files, and unresolved issues, while discarding raw process output.
4. Keep tool descriptions lean and lazy-load them
Tool descriptions should state only inputs, outputs, and boundary conditions; complex capabilities are dynamically registered through extensions and deregistered when the task ends.
5. Treat turn count as a first-class optimization metric
Put “reducing the number of loops” on par with “reducing tokens per turn” as optimization goals, and instrument both separately in monitoring, alerting, and logging services.
6. Validate with regression testing on real tasks
Use a real task set close to your own business plus automated tests as the regression baseline, confirm that quality does not degrade after slimming down, and then tighten budgets step by step.
5. Conclusion
A minimal framework is not short on capability; it puts complexity in the right place: the model handles reasoning, and the framework supplies the environment and constrains cost. As models keep getting stronger, “what else can we give the model” should give way to “what actually does not need to be given to the model.” Context discipline is poised to become a foundational principle of agent framework engineering, and putting it into practice can rely on general cloud capabilities such as container platforms, logging services, and monitoring and alerting for observation and governance—for example, the relevant general product categories offered by Baidu AI Cloud can be used to build a measurable cost baseline.
