Three token optimizations that made our agent more expensive
说明与用途
AltairAgent 的令牌优化(裁剪系统提示、激进上下文清理、按需加载工具)因缓存失效和步骤增加导致成本上升 67–82%。
问题
Optimizing token usage in an AI agent can unintentionally increase cost by affecting cache hits and step count.
结果
Each optimization increased cost by 67–82% because they broke cache continuity or added steps, demonstrating that token trimming alone can backfire.
工作流
- Trim the system prompt to essential content
- Shorten tool descriptions to first sentence
- Clear old context aggressively (reduce budget to 40K)
- Introduce tool_output(id) to retrieve hidden outputs
- Add a note before clearing to preserve needed data
- Load tools by family instead of individually
证据
The trimmed prompt made the agent 82% more expensive (6.49 m$ vs 3.56 m$).
Clearing the context budget from 120K to 40K tokens doubled the cost (58.6 m$ vs 30.6 m$).
Loading all 117 tools at once made a task 78% more expensive (10.95 m$ vs 6.15 m$).
- 记录日期: 2026-10-08T10:41:08.506Z