三只貓
Rich Mindset Zone
richmindsetzone.com
← All posts

AI Coding Agent Token 減肥實戰:從 lowfat 91.8% 到 LightAgent 80% 雙重節省

Claude Code 嘅 enterprise 平均成本係每個 developer 每日 USD $13,每月 USD $150–250。如果你 team 有 20 個人,齋係 agent 訂閱同 API 費用已經係一個全職工程師嘅人工。但大部分人只睇到個總數,冇拆開嚟睇啲錢究竟去咗邊——答案係:超過一半嘅 token 花喺你睇唔到嘅 overhead 度。OpenCode vs Claude Code 嘅 benchmark 顯示,Claude Code 每條 request 注入 33,000 tokens 嘅 scaffolding 先到你段 prompt,而 OpenCode 只需 7,000 tokens,差距 4.7 倍。cache 行爲再將呢個差距放大到 54 倍。換句話說,你每個月畀緊嘅錢入面,大部分係買緊空氣。

問題係:overhead 冇得 zero out,但可以 aggressively compress。以下三個工具分別從 command output 層、tool schema 層、同 context management 層落刀——每一層都做到 80–91% 嘅 reduction,疊加落嚟嘅效果唔係加法,係乘法。

lowfat:Command Output 層嘅 91.8% 減肥

lowfat 係一個用 Rust 寫嘅 CLI 工具,由開發者 zdk 開源。佢嘅定位極之清晰:喺 command output 去到 AI agent 之前 intercept 並過濾噪音。佢唔係一個 agent framework,唔做任何 LLM call,只係一個 pipe——你行 git diff,output 先經 lowfat 過濾,再送入 agent 嘅 context window。

實際數字方面,lowfat 提供三個過濾級別:litefullultra。根據官方 bundled samples 嘅測試,git diff 喺 ultra 級別 reduction 達 96%,git log 達 91%,git status 達 74%,docker ps 達 85%,ls -la 達 87%。佢哋自己做嘅 head-to-head 對比(同另一個工具 rtk 比較)顯示,同一 repo、同一 cwd,git log raw 3,350 tokens,lowfat full 壓到 93% off、ultra 97% off;git status 81 tokens raw,lowfat 可以壓到 91% off。

呢啲唔係實驗室數字——呢度慳到嘅 token 係直接入 context 嘅。用 Claude Sonnet 5 嘅 API pricing($3/MTok input,$15/MTok output)去計:一條 git diff 正常 output ~1,241 tokens,ultra 壓完得返 ~37 tokens。每次 agent call 節省 ~1,200 input tokens。如果一個 developer 每日 50 次 agentic request,其中 20 次涉及大型 git output,單靠呢層過濾每月可以慳到約 USD $50–80。而呢個只係 command output 層。

lowfat 嘅整合亦好簡單:lowfat hook 一鍵掛入 Claude Code,lowfat opencode install 裝入 OpenCode,或者 eval "$(lowfat shell-init zsh)" 做 shell-level auto-activation。安裝方法:cargo install lowfatbrew install lowfat。全部 local-only,無 telemetry,無 cloud dependency。

LightAgent:Tool Schema 層嘅 Adaptive 80% 削減

如果 lowfat 係減 command output,LightAgent 就係減 tool definition。wanxingai 推出嘅 LightAgent 喺 v0.3.2 引入 Adaptive Tools Mechanism,核心 insight 係:你唔需要每次都將全部 tool schema 送入 LLM。

大部分 agent framework 嘅做法係註冊晒所有 tool,然後每次 call LLM 時將所有 tool schema 做 system prompt 一部分送出去。如果 team 有 20 個 MCP server、每個 server 有 5–10 個 tool,tool schema 本身已經係 5,000–10,000 tokens 嘅固定 overhead。LightAgent 嘅做法係兩段式:先俾 LLM 一個輕量 router 揀 candidate tool set,filter 走無關嘅 tool,然後先將真正需要嘅 tool schema 送入主 call。

佢哋公布嘅 benchmark 數字:每 call token 消耗由 ~5,000 tokens 降到 ~1,000 tokens——80% reduction。Response time 由 2.5s 降到 1.2s——52% 提升。而 tool capacity 由上限 100 個變成 unlimited,因爲 router 層可以 handle 幾千個 tool 嘅 indexing。

呢個 80% reduction 同 lowfat 嘅 91.8% 係 orthogonal 嘅——佢哋減嘅係唔同層面嘅 token。用返上面 50 requests/day 嘅情景,假設每 call 嘅 tool schema overhead 由 5,000 降到 1,000 tokens,daily input token 節省係 50 × 4,000 = 200,000 tokens。以 Claude Sonnet $3/MTok 計,每日慳 USD $0.60,每月 ~$18。聽落唔多?但如果你係 heavy agentic user,每 call 涉及多個 subagent + 大量 tool,或者你用緊 Opus/Fable 級別嘅 model,個乘數就唔同講法。

更重要嘅係,呢個係一層一次過嘅 infrastructure 節省——set 好之後唔使再理,每個月自動扣減。

Synapse + Context Compaction:第三層嘅管理智慧

V2EX 上 chuan2015 分享嘅 Synapse 項目,同前面兩個工具定位唔同:佢係一個 multi-agent orchestration framework,但其中內建嘅 context compaction 機制直接影響 token 成本。Synapse 嘅 auto_compact 功能設兩個 threshold:先 cheap trim(drop 最舊嘅 tool call output,唔使 LLM call),如果 recover 唔夠 20% context,先做 LLM summarise(壓縮到原本嘅 ~30%)。呢個兩段式設計避免咗無謂嘅 LLM call。

另一邊廂,Synapse-Agent(LameGz 版本)用 memory graph 取代 flat file 做 context loading。佢哋嘅 benchmark 顯示:一個 10-module 嘅 project,flat full-load baseline 用 ~2,600 tokens,graph-based load 只用 ~750 tokens——71% reduction。呢個數字同 lowfat 同 LightAgent 嘅 80–91% 係同一數量級,但解決嘅問題完全唔同:佢減嘅係長期 session 入面 memory 累積嘅 token waste。

最新嘅 Self-Compacting Language Model Agents 論文(arXiv:2606.23525, June 2026)進一步證實呢個方向:用 judgment-based compaction(模型自己決定何時壓縮)取代 fixed-threshold 壓縮,可以喺同等或更好 quality 之下降低 30–70% 嘅 per-question cost。呢個研究直接對應 Synapse 嘅設計哲學——compaction 係一個 decision,唔係一個 threshold。

疊加效應:三層嘅乘法,唔係加法

將三層疊埋一齊睇:

層面工具Token reduction每月潛在節省(50 req/day, Sonnet)
Command outputlowfat ultra91.8% on git diff/log~$50–80
Tool schemaLightAgent80% per call~$18–36
Context/memorySynapse graph71% on long sessions~$30–60
疊加三層一齊用~98–99% on affected tokens~$100–175/month/dev

當然呢個係理想情境——command output 唔係每一個 request 都咁大,tool schema 節省 depends on MCP 數量,memory compaction 只影響長時間 session。但粗略估算:一個 active dev 每月 USD $150–250 嘅 agent cost 入面,靠呢三層 tooling 可以 cut 到 $50–100,節省幅度 40–60%。

對於一個 20 人 engineering team,每月節省 USD $2,000–3,000。呢個數字同 OpenCode 嘅 4.7x overhead gap 所帶嚟嘅 $3,200/month savings 係同一數量級——即係話 token 優化唔係 marginal gain,係同 switching tool 同等級嘅 cost lever。

行動點:由邊度開始?

如果你今日想開始 token 減肥,建議行呢條路:

第一週:裝 lowfat,ultra 級別行一星期。cargo install lowfat && lowfat hook 五分鐘搞掂。睇住 /cost 嘅數字變化,呢個係最快見效嘅 quick win。

第二週:如果你嘅 workflow 涉及多個 MCP server(5+),研究 LightAgent 嘅 Adaptive Tools 機制。特別係你哋用緊自建 tool 嘅 team,呢層節省隨住 tool count 增長只會越來越大。

第三週:檢視你嘅 agent session 長度。如果平均 session 超過 50 turns 或者 context 經常逼近 window limit,研究 Synapse 式嘅 graph memory 或者至少 set up auto_compact。呢層嘅節省唔明顯但持續——特別係做大型 refactoring 嘅時候。

最後一個忠告:唔好盲信 benchmark 數字。每個工具嘅 README 都寫咗句「measure on your own workload before trusting any of it」。lowfat 對 git-heavy workflow 最有效,LightAgent 對 tool-heavy workflow 最有效,Synapse 對 long-session workflow 最有效。你真係要做嘅係:set up,run 兩星期,睇 real usage data,然後先決定邊層最有槓桿。Token 減肥唔係一次性 project——係一個要持續 optimize 嘅 operating metric。