tiny-agent從第一性原理打造可靠 Agent

繁體中文(臺灣)· 開源工程教材

從第一性原理,打造能穩定執行的 AI Agent

這不是功能清單,也不是 prompt 技巧合集。我們從不可再刪的 model → tool → result 閉環開始,逐步推導 context、durable intent、crash recovery 與 production 邊界。

8 章約 164 分鐘TypeScript / Go / Python / Rust
開始第一章 →

學習路徑

01

從 LLM 到 Agent

拆開 LLM、Agent 與 coding agent,親手建立不可再刪的 model → tool → result 閉環。

02

訊息、Transcript 與 Provider Adapter

理解無狀態模型如何藉由 transcript 延續工作,以及 provider wire format 為何不能直接進入核心。

03

Tool 是 Agent 的手

設計小而深的 Tool 介面、runtime validation、錯誤語意與可安全擴充的 plugin bundle。

04

Context、AGENTS.md 與 Skills

把專案規則與領域知識放入正確層級,使用 progressive loading 控制 context 成本。

05

Durable Session:先記 Intent,再做 Effect

用 transactional JSONL 保存接受的工作、model attempt 與 tool intent,讓 crash 後仍可解釋。

06

Reducer、Planner 與 Recovery

以 pure reducer 重建狀態,再由 planner 區分 retry、replay、interrupted 與 blocked。

07

Cancellation 與 Durable Compaction

處理 abort race、合法 transcript,以及 active-context cut 與 durable source partition 的差異。

08

測試、Observability 與安全邊界

用 deterministic fixtures 與 run events 提升成功率,同時劃清 MCP、sandbox 與多租戶責任。

本書內容對照 repository 目前狀態;四語言能力差異等細節請以 repo 原始碼為準。

接下來會寫

以下是已規劃的 polyglot 與企業實戰篇;先顯示路線,不建立空白頁面。

  • TypeScript 實作深讀:從 CLI 到 Agent loop
  • Go 實作深讀:context、process group 與 terminal
  • Python 實作深讀:同步 I/O 與 cancellation
  • Rust 實作深讀:ownership、blocking transport 與 CJK terminal
  • 企業調查 Agent:Sentry、logs、code search 與 evidence packet