Token Cost Optimization for Office Agents: A Practical Engineering Guide
This article breaks down why token consumption in task-oriented office agents is driven mainly by the execution harness rather than model pricing alone. It presents a cost model, four engineering levers (prefix stabilization for cache hits, output length control, tiered routing to avoid over-reasoning, and retry suppression), guidance on allocating free or low-cost quotas, observability metrics, and a practical checklist for reducing cost without sacrificing reliability.
1. Background: Cost Structure Is Becoming the Deployment Bottleneck
Office agents are fundamentally different from chatbots. A request such as “summarize this week’s spreadsheets into a weekly report and generate a presentation page” typically involves multiple rounds of planning, tool calls, result validation, and retries. Token consumption for a single conversational turn is predictable, whereas token consumption for task-oriented calls is amplified and long-tailed—the same instruction can cost an order of magnitude more or less depending on the implementation.
Based on public information and engineering practice, when the model and task are held constant, differences in token consumption between agent applications come mainly from four areas:
- Cache hit ratio: whether prefix content such as system prompts, tool definitions, and long documents can be reused;
- Output length: whether redundant reasoning text, repeated explanations, and ineffective formatting are produced;
- Over-reasoning: whether simple tasks are routed to strong reasoning models and whether unnecessary multi-round self-reflection occurs;
- Execution framework (harness) efficiency: whether context trimming, tool result compression, and failure retry strategies are restrained.
A recent industry phenomenon is worth noting: an office agent platform reduced the quota consumption multiplier for high-frequency lightweight models and made low-consumption tasks free, so that more than 80% of daily office tasks can be completed at zero cost. Its publicly shared task tests show that the average cost of the lightweight model path is about one tenth of comparable products, while the path using more capable models costs about half to seventy percent of comparable products. We will not discuss any specific product here. Instead, we abstract this phenomenon into a general engineering proposition: the cost of an office agent is determined mainly by the harness, not only by the model’s unit price.
2. Cost Model: Do the Math Before Optimizing
Let the token consumption of a task be:
Cost ≈ (InputTokens × P_in + OutputTokens × P_out) × (1 - CacheHitRate × Discount) × RetryFactor
Where:
InputTokens: system prompt + tool schema + historical context + tool return results;OutputTokens: reasoning text generated by the model, tool call parameters, and the final response;CacheHitRate: prefix cache hit rate;RetryFactor: amplification factor from failure retries and self-correction (≥1).
This formula tells us three things:
- The input side is the main battlefield. For task-oriented agents, input is often 5–20 times the output, especially for long documents and JSON returned by tools.
- Caching is the highest-leverage item. If stable, unchanging prefixes (system prompts, tool definitions, specification notes) hit the cache, marginal cost drops significantly.
- Retries are a hidden cost. A single failed retry can double the cost of the entire task, so “making fewer mistakes” is cheaper than “fixing mistakes afterward.”
3. Engineering Practices for the Four Cost Levers
3.1 Prefix Stabilization: Make Caching Actually Hit
Cache hits require the prefix to be byte-for-byte stable. The most common破坏 factor in practice is inserting timestamps, random IDs, or user nicknames at the very front of the system prompt.
Recommended context layering (from stable to volatile):
[Layer 0] Global policies and safety rules (almost never change)[Layer 1] Tool definitions and invocation constraints (versioned, changes require a release)[Layer 2] Domain knowledge/templates (fixed per business domain)[Layer 3] Conversation history (rolling window)[Layer 4] Current user input and tool results (most volatile)
Key points:
- Place volatile content at the end; do not pollute the prefix;
- Version tool schemas to avoid frequent changes that invalidate the entire cache;
- For long documents, first perform structured extraction (headings, tables, key paragraphs) and inject on demand, rather than stuffing in the whole document.
3.2 Output Length Governance: Constraints Reduce Cost
Output tokens usually cost more per unit than input tokens, and output cannot reuse the cache. Governance measures include:
- Explicitly state in the prompt “output only necessary conclusions, do not explain the process”;
- Prioritize structured output (tables/JSON) and avoid lengthy natural language restatement;
- For tasks like “generate a presentation page,” produce an outline first and then fill it in, reducing rework.
Example constraint snippet:
Output requirements:1. Return only the final result; do not restate the input;2. Conclusions must not exceed 200 words; provide details in a table;3. Do not output reasoning or self-check text.
3.3 Suppress Over-Reasoning: Tiered Routing
Not all tasks need a strong reasoning model. A workable tiering strategy:
| Task Type | Recommended Path | Reason |
|---|---|---|
| Rewriting, summarization, format conversion | Lightweight model | Fixed patterns, high fault tolerance |
| Table cleaning, field mapping | Lightweight model + rule validation | Rules can act as a fallback |
| Cross-document attribution, complex solutions | Strong reasoning model | Requires multi-step inference |
| Code generation and debugging | Mid/strong model + unit tests | Can converge with tests |
Routing decisions can start with rules, then use a small model for classification, avoiding “always use the strong model.”
3.4 Retries and Validation: Push RetryFactor Close to 1
- Tool result compression: keep only necessary fields; for overly long results, store them in object storage and return a reference;
- Idempotent design: write operations carry an idempotency key to avoid duplicate execution;
- Front-load structured validation: fill in missing fields locally immediately, rather than making the model run another round;
- Bounded retries: allow at most one self-correction; on failure, degrade to “provide actionable suggestions.”
4. Quotas and Multipliers: Use Free Quotas in the Right Place
Many platforms lower the usage threshold through “free low-consumption tasks + daily check-in quotas + new user trial periods.” The takeaway for users is: pin high-frequency, low-complexity, fault-tolerant tasks to the lightweight path, and reserve quotas for the few tasks that truly need strong reasoning.
An executable quota allocation example:
Daily high-frequency (~80% of task volume): lightweight model + free quotaComplex tasks (~15%): mid-tier modelCritical decisions (~5%): strong reasoning model + human review
This aligns with the cost curve and avoids the quality risk of a one-size-fits-all downgrade.
5. Observability: No Measurement, No Optimization
At minimum, collect the following metrics and view them alongside task success rate:
- Input/output tokens per task, cache hit rate;
- Number of retries, number of tool calls, distribution of failure reasons;
- Cost per task, task success rate, human takeover rate.
Example instrumentation structure:
{"task_id": "t-1024","route": "light","input_tokens": 5820,"output_tokens": 310,"cache_hit": 0.71,"retries": 0,"tool_calls": 2,"success": true,"cost": 0.0007}
With this data, you can determine whether cost reduction comes from cache optimization, routing optimization, or simply sacrificing quality.
6. Implementation Checklist (Ready to Follow)
- Layer context into four tiers, place volatile content at the end, and version tool schemas;
- Perform structured extraction on long documents first; store large tool results and return references;
- Add hard constraints to output: “conclusions only, no restatement, no reasoning”;
- Establish a three-tier routing of lightweight/mid-tier/strong reasoning, defaulting to lightweight;
- Set the retry limit to 1 and make write operations idempotent;
- Collect four categories of metrics: tokens, cache hits, retries, and success rate;
- Allocate free quotas and check-in quotas to high-frequency, low-complexity tasks;
- Review the “Top 10 high-consumption tasks” weekly, prioritizing harness optimization over switching models.
7. Conclusion
The cost competition of office agents appears to be about model unit prices and discount multipliers, but it is essentially about the engineering capability of the execution framework: whether the cache can hit, whether output can converge, whether reasoning can be tiered, and whether retries can be restrained. Doing these four things well places the vast majority of daily tasks in an extremely low-cost range. Adding quota strategies and an observability system then achieves a balance between “free and usable” and “reliable for critical tasks.” For developers, this approach does not depend on any specific vendor and is an engineering practice that can be directly adopted into your own harness.
