A Practical Guide to Token Cost Optimization for Office Agents
This article explains why office AI agents running on the same model can produce bills that differ by several times, and how engineering choices in the execution framework (Harness) drive that gap. It breaks task cost into unit price, input/output/reasoning tokens, cache discount, and retry factors, then covers three main levers: raising cache hit rate through a stable prompt prefix, constraining output length, and routing simple tasks to lighter models. It also presents a task tiering and quota model, a four-step rollout plan for existing agents, and common pitfalls to avoid.
1. Where the Problem Starts: Why the Same Model Produces Bills That Differ by Several Times
When enterprises adopt office agents, a pattern keeps reappearing: the underlying large model is the same, the task description is the same, yet the actual invocation cost across teams can differ by several times. Many engineering teams start from the assumption that “unit model price determines cost,” but real bills often overturn that judgment.
Breaking cost apart gives an approximation that is easier to analyze:
cost per task ≈ unit price × (input tokens + output tokens + reasoning tokens)× (1 - discount from cache hits)× retry and rollback factor
This expression shows that unit price is only one factor. What really determines the bill is the three multipliers outside the parentheses: whether the cache is effectively reused, whether output and reasoning are constrained, and whether failed retries are contained. Publicly available data from one platform shows that, with the model and task held constant, average cost per task in office scenarios can be as low as roughly one tenth of comparable solutions; after switching to a stronger model with higher reasoning capability and a higher unit price, cost rises but can still be kept within half to seventy percent of comparable solutions. The source of the difference is not the model, but the engineering optimization capability of the execution framework (Harness).
2. Three Main Lines: Where the Savings Come From
2.1 Cache Hit Ratio: The Most Overlooked Lever
Office tasks have a natural advantage: context is highly repetitive. System prompts, tool definitions, enterprise knowledge base fragments, and summaries of prior conversation barely change across consecutive rounds. If the framework sends every round as a brand-new request, this content gets billed repeatedly.
The effective approach is to split each request into a “stable prefix” and a “changing suffix”:
[stable prefix] system role + tool schema + policy constraints + long-term knowledge fragments[changing suffix] current user input + incremental retrieval results + intermediate artifacts
In engineering terms, the prefix must be byte-level stable: do not insert timestamps, random request IDs, or rotating example order into it. These seemingly harmless fields change the prefix hash and invalidate the cache entirely. In practice, moving volatile information to the end is the lowest-cost step for improving the hit rate.
2.2 Output Length: From “Phrased Nicely” to “Sufficient”
Output tokens usually carry a higher unit price and directly determine how long users wait. What office scenarios actually need is structured, directly usable results rather than lengthy elaboration. Three types of constraints can contain this:
- Format constraints: require tables, lists, or fixed fields to be returned, cutting pleasantries and repeated statements;
- Length budgets: set output limits per task type, and when exceeded, give the conclusion first and add details afterward;
- Staged output: for long documents, produce an outline first and fill in section by section, avoiding large-scale rework after a single generation.
2.3 Reasoning Depth Scheduling: Don’t Pair a Heavy Model with a Simple Task
Over-reasoning is a hidden cost driver. Tasks such as classification, extraction, format conversion, and field mapping can be handled by a small-parameter model or even a rules engine; only cross-document reasoning, complex attribution, and code refactoring warrant upgrading the model. The key is to build a routing layer:
def route(task):if task.type in ("classify", "extract", "format_convert"):return "light_model", {"max_output": 512, "reasoning": "off"}if task.type in ("summarize", "draft"):return "mid_model", {"max_output": 2048, "reasoning": "low"}return "strong_model", {"max_output": 4096, "reasoning": "high"}
Routing decisions should be based on task type and confidence rather than user identity, so that the cost policy stays predictable.
3. Task Tiering and Quota Mechanisms: Keeping Eighty Percent of Tasks in the Free Zone
Another path to cost governance sits at the product design level: “small amounts free + low-multiplier quotas.” The logic is to separate high-frequency, low-consumption tasks from the billing system and charge only for genuinely resource-heavy tasks. A reusable tiering framework:
| Tier | Typical Tasks | Resource Profile | Billing Policy |
|---|---|---|---|
| L0 | Simple Q&A, single-sentence rewriting | Short input, single round | Free outright |
| L1 | Summarization, table extraction, format conversion | Medium input, structured output | Very low multiplier quota |
| L2 | Document writing, presentation material generation | Long context, multiple iterations | Standard quota |
| L3 | Data analysis, application development, cross-system orchestration | Tool-call intensive | Standard or accelerated rate |
Supporting user-side incentives (a trial period for new users, daily check-in quotas, cumulative rewards for consecutive check-ins) essentially lower the trial barrier for low-frequency users to zero, letting them naturally cross L0 and L1. Under the measured accounting, covering roughly fifty categories of office tasks across investment research analysis, growth marketing, document writing, presentation creation, data processing, and application development, more than 88% of tasks fall into the free range, with average cost per task around 0.065 CNY. The engineering meaning of these numbers is that the free zone is not a marketing giveaway, but a reflection of real cost after cache and routing optimization.
4. Rollout Path: Four Steps to Refactor an Existing Agent
- Instrument the baseline. First collect input/output/reasoning tokens, cache hit counts, and retry counts per task type; without a baseline there is no way to tell whether optimization works.
- Rebuild the prefix. Unify the system-layer template, remove volatile fields, and watch how the hit rate changes.
- Routing and budgets. Ship model routing and output budgets, and degrade over-budget requests rather than failing outright.
- Contain failures. Set timeouts and idempotent retries for tool calls to avoid billing the same task repeatedly.
Illustrative cost dashboard query logic:
Aggregate by task type: avg_cost = total_cost / task_countAggregate by tier: free_ratio = free_task_count / task_countAnomaly detection: cost_per_task > 3 × trailing seven-day median → trigger framework-side investigation
5. Common Pitfalls
- Switching only to a cheaper model. Model downgrades often bring quality drops and rework, raising total cost instead.
- Ignoring prefix stability. When the cache is invalidated, the bill jumps suddenly and is hard to attribute.
- Setting no output budget. Generation tasks without a cap can easily run out of control in long-document scenarios.
- Treating free quota as an unlimited resource. The free zone still needs rate limiting and quotas, otherwise a few heavy callers can drag down overall cost.
6. Conclusion
Cost competition for office agents has shifted from “model unit price” to “execution framework efficiency.” Get cache hit rate, output length, and reasoning depth solid, then layer on task tiering and small-amount-free mechanisms, and the vast majority of everyday office tasks can be completed at very low or even zero cost. This approach depends on no specific vendor capability; any team can reproduce it in its own agent framework and continuously validate optimization results with quantifiable metrics.
