Token Cost Optimization for Office Agents: A Practical Guide
This guide breaks down the real cost structure of office AI agents and explains why model pricing is rarely the dominant factor. It introduces a cost model, an observability baseline, and four controllable levers—cache hit ratio, output length, reasoning-tier routing, and harness design—along with quota and free-tier mechanics, plus load-testing and acceptance criteria for reducing cost without sacrificing task success.
1. Background: Cost Structure and Common Optimization Mistakes
A recurring data point in recent industry discussions is that, on the same batch of office tasks, the average cost per run across different agent products can differ by an order of magnitude. The observation scope in the source material covers roughly 50 task categories, including investment research analysis, growth marketing, document writing, presentation generation, data processing, and application development. When executed with a low-multiplier lightweight model, more than 88% of tasks fell into the free tier, with an average cost of about RMB 0.065 per run—roughly 10% of comparable products. After switching to a more capable general-purpose model, average consumption was about RMB 3.134 and RMB 3.990, equivalent to 50%–70% of comparable products.
The point is not the numbers themselves, but the engineering fact they reveal: model unit price is not the dominant cost factor. With the same model and the same tasks, the differences mainly come from four areas:
- Cache hit ratio (Prompt Cache / KV Cache reuse rate);
- Output length (especially redundant output from chain-of-thought and intermediate artifacts);
- Over-reasoning (simple tasks routed to heavy reasoning pipelines);
- Scheduling and context-trimming capability of the execution framework (Harness).
Many teams stop at “switch to a cheaper model,” which is a classic local optimum. What is actually reusable is an end-to-end cost governance method.
2. Cost Model: Do the Math First
Let the cost of a single task be C, which can be approximated as:
C = (Tin_effective × Pin) + (Tout × Pout) + N_tool × C_tool + C_retryTin_effective = Tin_raw × (1 - h) # h is the cache hit ratio
Improving h has a linear impact on the bill, while N_tool (number of tool-call rounds) and C_retry (failed retries) are often the overlooked “hidden majority.” A poorly planned agent may issue a dozen tool-call rounds in a single task, each carrying the full historical context, and the cost is amplified quadratically.
In practice, establish an observable baseline first, instrumenting at least the following fields:
record = {"task_type": "doc_write", # task category, for bucketed accounting"model_tier": "lite", # model tier"cache_hit_ratio": 0.72, # key metric"input_tokens": 8200,"output_tokens": 640,"reasoning_tokens": 310,"tool_calls": 3,"retries": 0,"cost": 0.0,}
Without bucketed instrumentation, no cost reduction can be attributed; you can only tune parameters by feel.
3. Concrete Practices for the Four Controllable Variables
3.1 Improve the Cache Hit Ratio
The prerequisite for cache reuse is a stable prefix. In practice, split the prompt into a “stable segment + volatile segment”:
[Stable segment] System role, output spec, glossary, tool descriptions, examples (placed first)[Volatile segment] User input for the current turn, retrieved snippets, timestamps (placed last)
A common anti-pattern is prepending timestamps, random IDs, or retrieval results to the beginning of the prompt, which invalidates the entire prefix and drops the hit ratio to zero. In addition, controlling the in-session history trimming strategy and avoiding rewriting the system prompt every turn can significantly improve h.
3.2 Control Output Length
Output tokens are usually more expensive than input tokens, and redundant output pollutes the context of subsequent turns. Recommendations:
- Enforce structured output (JSON Schema / fixed subheadings) to reduce free-form generation;
- Set an upper limit on the “thinking process,” keeping only conclusions and supporting evidence;
- For long documents, use “outline first, then fill in section by section” to avoid generating everything at once and then heavily reworking.
3.3 Tiered Routing by Reasoning Depth
This is the most cost-effective layer. Use a lightweight classifier or rules to assess difficulty first, then decide the model tier:
def route(task):if task.risk == "low" and task.steps <= 2:return "lite" # simple dialogue, formatting, summarizationif task.domain in {"finance", "code"}:return "pro" # requires strong reasoningreturn "standard"
The essence of “88% of tasks falling into the free tier” in the source material is that the vast majority of office actions (rewriting, polishing, extraction, table organization) do not need heavy reasoning, yet are routed by default to the most expensive pipeline.
3.4 Harness Optimization
The Harness determines how context is organized, how tools are called, and how failures are recovered. Four actionable principles:
- Load context on demand rather than injecting everything;
- Summarize tool results before adding them to history; externalize raw long text to object storage and pass only a reference;
- Idempotent design plus bounded retries to avoid duplicate billing;
- Parallelize tool calls with no dependencies to compress rounds.
4. Productizing Quotas and Free-Tier Mechanics
Once cost is down, how to use quota mechanics to support “high-frequency daily, low cost per run” scenarios is a product design question. A reference combination:
- Small free tier: low-consumption tasks are not counted against quota and are opened up directly;
- Check-in supply: daily check-ins grant a fixed quota, doubled on Mondays, and completing a full cycle of consecutive check-ins grants cumulative quota close to one month of a standard plan;
- New-user trial: eligible users can claim a 30-day trial membership;
- Multiplier tuning: set an extremely low consumption multiplier (e.g., 0.01) for high-frequency lightweight models, making “cheap” a perceivable product language.
The financial prerequisite for this design is that unit cost is controllable and predictable, so the governance capability in Section 3 is a precondition, not an ancillary optimization.
5. Load Testing and Acceptance Criteria
Do not evaluate cost with a single prompt; build a task-set regression:
Task set: ≥50 real office scenario categories, ≥20 samples per categoryMetrics: free-tier coverage, average cost per run, P95 cost, task success rate, average tool roundsGate: success rate does not drop by more than 1%, P95 cost does not increase
Only by putting “success rate” and “cost” in the same gate table can cost reduction avoid coming at the price of quality collapse.
6. Conclusion
The competitiveness of office agents ultimately comes down to “unit cost at equivalent task quality” and “sustainability of quota supply.” For developers, the four knobs—cache hit ratio, output length, reasoning-tier routing, and Harness scheduling—are more worth prioritizing than switching models. For platform providers, making low-consumption tasks free and using check-ins and trial periods to smooth the quota curve is an effective path to turn technical dividends into user experience. If enterprises want to deploy similar capabilities in their own environments, they can build observability and scheduling systems on general-purpose cloud container platforms, object storage, log services, and monitoring and alerting components, forming a cost baseline matched to their business.
