agentbelt 0.3.0:以實測數據優化本地 AI Agent 的 token 使用
agentbelt 0.3.0: token optimization for local AI agents, with honest numbers
agentbelt 0.3.0 為本地 AI Agent 加入 Goose adapter,並實測上下文壓縮對 token 使用的影響,每項任務各執行 3 次。處理錯誤測試日誌時,輸入 token 減少 56%,每次執行均完成;讀取檔案時準確度不變,但平均輸入 token 沒有減少。
agentbelt gives every AI coding app (Claude Code, Codex, Cursor, Copilot, DeepSeek, LM Studio) the same safe, audited dev tools over MCP. Version 0.2.0 added context compaction for agents running on local models with small context windows (gpt-oss 20B, 16k context, on a MacBook Air). 0.3.0 adds a Goose adapter and a demo GIF.
I measured it instead of guessing
I ran the same tasks with compaction off and on, 3 runs each. Token counts are what Ollama itself reported.
| Task | Compaction | Correct | Avg input tokens | Largest prompt |
|---|---|---|---|---|
| read 5 files | off | 3/3 | 46,916 | 13,317 |
| read 5 files | on | 3/3 | 50,410 | 10,269 |
| failing test log, twice | off | 1/3 | 42,267 | 6,182 |
| failing test log, twice | on | 1/3 | 18,448 | 3,338 |
- The largest prompt was lower in every run.
- On the log-heavy task: 56% fewer input tokens, and every run finished instead of running out of steps.
- On the file-reading task: same accuracy, but no average saving. One run re-read files and cost more.
- My first version did worse. It shortened file contents too much, and the model re-read what it had lost.
Takeaway: for local agents, the biggest win is not repeating the same logs. Shrinking file contents can backfire.
Full method and raw results: docs/token-optimization.md
Try it
npx agentbelt setup
Then ask your AI app: "Use agentbelt's agent_run with compact: true to …"
⭐ If this is useful, a star on GitHub helps other developers find it. And if you run agents on local models, I'd love to hear what you've measured.
來源:DEV Community · dev.to