nano logo
the nano series

Agent loops & harness engineering,
small enough to read in an evening.

Agent loop 与 harness engineering,
小到一个晚上就能读完。

Every idea that reshapes AI engineering eventually gets a minimal implementation you can hold in your head. The nano series is that for agent loops and harness engineering — real, working systems, kept deliberately small, and mapped chapter-by-chapter onto the harness-101 course.

每个重塑 AI 工程的思想,最终都会有一个能装进脑子里的最小实现。nano 系列就是 agent loop 与 harness engineering 的最小实现——真实可运行的系统,刻意保持小巧, 并与 harness-101 课程逐章对应。

nano-agent — zsh

01The projects系列项目

Three layers of one stack: a single agent loop, an orchestrator that runs many of them, and the distributed backend that runs the fleet.

同一套技术栈的三个层次:单个 agent loop、批量调度它的编排器、以及运行整个集群的分布式后端。

Go

A minimal AI coding assistant — the agent loop, tools, and context management without framework bloat. TUI + daemon modes, swarm multi-agent, sandboxed by default.

极简 AI 编程助手——agent loop、工具与上下文管理,没有框架包袱。TUI + daemon 双模式,swarm 多智能体,默认沙箱隔离。

TypeScript · Bun

A lightweight orchestration service for running coding agents on tracked issues — plan runs with DAG execution, human approval gates, cost budgets, and a web dashboard.

轻量级 agent 编排服务——把 coding agent 跑在可追踪的 issue 上:DAG plan run、人工审批门禁、成本预算和 Web 仪表盘。

Go

Distributed execution for agents — a gateway/worker architecture that runs agent fleets in isolated Docker runtimes, with pairing-based onboarding and an admin console.

agent 的分布式执行——gateway/worker 架构,在隔离的 Docker 运行时里运行 agent 集群,配对式接入和管理控制台。

02One methodology, two ways in一套方法论,两种打开方式

harness-101 teaches the Harness 12-Factor methodology with skeleton code you fill in yourself. The nano series is the same twelve factors, already running in production-shaped systems. The two are bound chapter by chapter: harness-101 用需要你自己补全的骨架代码讲授 Harness 12-Factor 方法论; nano 系列则是这十二条因素在真实系统里跑起来的样子。两者逐章绑定:
learn the factor in harness-101 → read it running in nano → build your own
在 harness-101 学会因素 → 在 nano 里读到它的实现 → 动手写出自己的
Every factor below links the course chapter to the exact file or doc where that idea lives in the nano codebases. When the course says "context budgeting is a first-class concern", you can open context_compression.go and see what that sentence costs in real code. 下表把每个因素的课程章节链接到 nano 代码库里它真正所在的文件或文档。 当课程说「上下文预算是一等公民」时,你可以直接打开 context_compression.go 看这句话在真实代码里值多少行。

03The 12 factors, mapped to running code12 因素 → 运行中的代码

Each factor links to the course chapter, the starter code, and the nano implementation.

每个因素都链到课程章节、骨架代码和 nano 中的实现。

Factor因素 Course课程 In the nano seriesnano 系列中的实现
F1 · Single Agent Loop chapter · starter nano-agent: architecture & turn loop
F2 · Explicit Tool Contract chapter · starter nano-agent: tool runtime
F3 · Context Budgeting chapter · starter nano-agent: model-aware context compression
F4 · Knowing When to Stop chapter · starter nano-agent: turn termination policy
F5 · Failure-First Design & Graceful Degradation chapter · starter nano-agent: retry / fallback / circuit-breaker · multi-provider fallback
F6 · Permission Models chapter · starter nano-agent: permission policy · auto-approval · sandbox design
F7 · Human-in-the-Loop Gates chapter · starter nano-symphony: plan approval gates
F8 · Plan & Goal Modes chapter · starter nano-agent: plan mode · nano-symphony: plan runs
F9 · Workspace & Artifacts Management chapter · starter nano-symphony: workspaces & unified artifacts
F10 · Composable Agents chapter · starter mailbox · swarm · roles ADR
F11 · Config-Driven & Reproducible Runs chapter · starter nano-agent: configuration · checkpointing · workflow templates
F12 · Observability & Continuous Evaluation chapter · starter nano-agent: event schema · SWE-bench evaluation · nano-symphony: metrics & dashboard

04A suggested path建议的学习路径

  1. Work through the course prep and F1–F3 while reading nano-agent's core: pkg/agent is the loop the course asks you to write, at production scale.
  2. 完成课程准备和 F1–F3,同时对照读 nano-agent 的核心:pkg/agent 就是课程让你手写的那个 loop 的生产级版本。
  3. F4–F6: termination, failure, and permissions — study pkg/agent/turn_policy.go to see how nano-agent decides a run is done (or stuck), then run it in its strictest permission mode and watch it refuse things.
  4. F4–F6:终止判定、失败处理与权限模型——读 pkg/agent/turn_policy.go 看 nano-agent 如何判定任务完成(或陷入循环),然后把权限开到最严,看它如何拒绝操作。
  5. F7–F9: graduate to nano-symphony — approval gates, plan runs, and isolated workspaces with durable artifacts are orchestrator concerns, not agent concerns.
  6. F7–F9:进阶到 nano-symphony——审批门禁、plan run、隔离工作区与持久 artifacts 是编排层的关注点,而不是 agent 本身。
  7. F10–F12: mailbox, swarm, and evaluation — then the capstone: deploy your own fleet on nano-cloud.
  8. F10–F12:mailbox、swarm 与评估——最后是毕业项目:在 nano-cloud 上部署你自己的 agent 集群。