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

AI Coding Agent 三國誌:AST 手術刀 vs Rust 輕騎兵 vs 可觀測重裝甲

今年 LLM 寫 code 已經唔係新聞,真正嘅新聞係:點解有人用同一條模型,快 44%、平 52%、準 43%?點解有 agent 喺 16MB RAM 嘅邊緣設備行得郁,而你呢個 64GB 嘅開發機仲要等佢諗完先郁?點解你個 agent 寫完 300 行 code 你完全唔知中間發生過咩事,但有人可以 replay 每一個 step、逐個 token 睇推理過程?

唔好再問「邊個模型寫 code 最勁」——呢條問題錯嘅。AI Coding Agent 嘅戰場已經轉移到三條截然不同嘅技術路線:AST 手術刀派、Rust 輕騎兵派、同可觀測重裝甲派。三條路線各有哲學、各有取捨,而我哋香港開發者成日陷入一個陷阱——以為裝個 OpenHands 或者 Continue.dev 就叫「用 AI 寫 code」。你冇揀過路線,路線就幫你揀咗定位。

AST 手術刀:SoulForge 嘅精準打擊點樣煉成

SoulForge 嘅 repo 入面有一句 key sentence:「We don’t fix bugs — we rebuild the AST.」呢句唔係 marketing,而係佢哋快 44% 嘅根本原因。

大部份 AI coding agent 嘅做法係咁:LLM 出 patch → apply patch → 等 diff → 睇結果。中間涉及大量 text parsing、fuzzy matching、context window 嘅浪費。SoulForge 嘅做法完全唔同——直接將 codebase parse 成 AST(抽象語法樹),所有 transformation 喺 AST 層面做,最後先 serialise 返出嚟。聽落好似多咗一步,實際上係快咗成倍,因為 AST 係 deterministic,唔使 LLM 用 token 去「估」啲括號同分號放喺邊。

準 43% 嘅秘密亦喺度。Text-based patch 嘅 common failure mode 係格式錯、indentation 亂咗、import 漏咗——呢啲全部係 AST 嘅強項。AST node 嘅 parent-child relationship 係 exact match,唔會出現「LLM 改咗 function body 但唔記得加 return type」呢類低級錯誤。SoulForge 嘅做法係比 LLM 一個 sub-tree 嘅 spec,由 AST-level 嘅 code generator 填空,LLM 只需要做 decision,唔需要做 formatting。呢個 division of labor 直接將 token cost 斬咗一半。

對於香港嘅團隊,呢條路線嘅 trade-off 好清楚:AST-based agent 嘅前期 infra investment 好高——你要為每一種語言寫 parser、traverser、transformer。但如果你嘅 codebase 夠大、agent 用量夠密,呢個 upfront cost 好快 amortize 返。SoulForge 揀咗好聰明嘅 entry point:先 support TypeScript/JS 呢啲 AST infra 最成熟嘅語言,community 貢獻咗 parser,佢哋專注做 transformation engine。

Rust 輕騎兵:Zerostack 嘅 16MB 哲學

Zerostack 係成個 ecosystem 最反直覺嘅存在。16MB RAM 行到一個 coding agent?仲要唔係 POC,而係 production-ready?呢個數字逼使我哋重新思考「Agent Runtime 到底需要咩」。

大部份 agent framework 嘅 RAM consumption 來自三樣嘢:Python runtime(~30MB baseline)、LLM context cache(唔好提)、同嗰堆 dependency tree——你 npm install 一個 agent framework,node_modules 隨時 200MB。Zerostack 用 Rust 由頭寫起,binary size 壓到 3MB 之內,runtime memory 靠 zero-copy parsing 同 arena allocator 慳到盡。16MB 唔係 hard limit,而係佢哋嘅 design constraint——逼住做更好嘅資源管理。

呢條路線對香港開發者嘅啟示好大。我哋慣咗「RAM 唔夠就加 RAM」嘅思維,但 Zerostack 話畀我哋知:agent runtime 嘅 overhead 唔係自然定律,而係 engineering choice。當你嘅 agent 要 deploy 去 edge device、CI/CD pipeline、或者 serverless function——呢啲 memory 受限嘅環境——你就會明點解 16MB 比 200MB 更加係 moat。

不過 Zerostack 嘅 trade-off 係 ecosystem。Rust 嘅 dynamic typing 支援要靠 FFI bridge,唔似 Python 或者 JS 咁可以直接 eval。佢哋嘅解法係 layered architecture:core 用 Rust,plugin 層可以用 WASM 或者 script language。呢個設計令 Zerostack 唔只係一個 framework,而係一個 runtime platform。

可觀測重裝甲:Voltagent 點樣解決「Agent 黑盒」問題

SoulForge 同 Zerostack 解決嘅係 efficiency 問題,Voltagent 解決嘅係 trust 問題。用到 AI coding agent 嘅團隊遲早會問同一條問題:「頭先 agent 改咗啲咩?點解要咁改?」如果答唔到,就唔會 merge。

Voltagent 嘅核心 insight 係:AI agent 唔係一個 tool,而係一個 distributed system。佢同外部 API 互動、call tool、讀文件、寫 code——每一步都有可能錯,而 error recovery 嘅 cost 遠高過 error detection。所以佢哋成個 platform 建基於 event sourcing:agent 嘅每個 decision、每個 tool call、每個 token 嘅 generation 全部 log 低,結構化成一個可 query 嘅 timeline。

呢個唔係單純嘅 logging。Voltagent 嘅 replay system 可以將一次 agent session 重新執行一次,但喺某個 decision point 改參數、改 prompt、改 tool choice,然後睇結果有咩分別。呢種 causal tracing 喺 production agent 嘅 debugging 入面係殺手應用——你唔使再靠 LLM 嘅 introspection「你頭先諗咩」,而係直接睇到當時嘅 context、當時嘅 prompt、當時嘅 state。

對於香港嘅 production team,Voltagent 路線嘅最大價值係 compliance 同 audit trail。金融、醫療、legacy enterprise——呢啲客戶唔會信「個 agent test pass 咗」,佢哋要睇到每一個改動嘅 justification。Voltagent 嘅可觀測性唔係「好有」,而係 mandatory。

opencode-orchestrator 嘅協同效應:組合多過發明

上面三條路線看似各走極端,但 opencode-orchestrator 嘅做法揭示咗第四條路:唔 reinvent the wheel,而係 orchestrate the ecosystem。

以我理解,opencode-orchestrator 嘅設計哲學係「agent composition over monolithic framework」。佢唔追求自己做最快、最輕、最 observability——而係提供一個 framework 俾你 plug in SoulForge 做 editing engine、Zerostack 做 runtime、Voltagent 做 monitoring。呢個 orthogonal 嘅設計俾到 team 最大靈活性:你可以用 SoulForge 嘅 AST engine,但用返自己嘅 frontend;或者用 Zerostack 做 CI agent,但 production 用 Voltagent 睇住。

呢個設計背後嘅假設係:AI coding agent 嘅 killer app 唔係單一工具,而係 integration chain。你嘅 agent 要 call Supabase、Postgres、AWS、GitHub API——每一條 integration 都係一個 potential failure point。opencode-orchestrator 嘅做法係將呢啲 integration 變成 pluggable middleware,唔係 tight coupling。

面對三條路,香港開發者應該點揀

如果你係 startup,codebase 細、迭代快、team 細——SoulForge 路線係最直接嘅 win。AST-based editing 嘅效率提升會直接反映喺 PR cycle time,而前期 infra cost 對於 TS/JS-heavy stack 嚟講好 manageable。

如果你做 edge computing、IoT、或者 CI/CD pipeline——Zerostack 嘅 resource efficiency 係唔使諗嘅 choice。16MB 嘅足印意味住你嘅 agent 可以行到開發者嘅 laptop 以外嘅地方,呢個 freedom 值好多錢。

如果你嘅客戶係 enterprise,或者你嘅 codebase 改錯會炸 production——Voltagent 嘅 observability 唔係 option,而係 license to operate。你要嘅唔係 agent,而係可 audit 嘅 automation layer。

而如果你唔想被任何一條路線 lock in,opencode-orchestrator 嘅 composition model 俾你保留全部 flexibility,代價係多一層 abstraction 要 manage。

最後講句嘢:揀 agent framework 同揀 programming language 一樣——冇 absolute best,只有 best fit。今日用 SoulForge 嘅 AST 慳 44% token cost,聽日可能被新模型嘅 inference efficiency 追平。但有一樣嘢唔會變:理解你條 pipeline 入面每一層嘅 trade-off,永遠係你嘅 moat。