Armin Ronacher 博客 · 原文 2026-01-31 · 译文 2026-10-21 · 难度 进阶
精读 · 译文(非本站原创)
来自资源池 · Armin Ronacher 博客 ↗ · 原文:Pi: The Minimal Agent Within OpenClaw ↗ · 版权归 Armin Ronacher 博客 所有 · 译文为个人学习的非官方翻译,以原文为准;如权利方有疑虑可联系公众号「疯了再说」删除
导读 · Flask 作者的 Pi 科普:小内核+自扩展哲学,「软件造软件」的一瞥未来

为什么精读这篇这是外部视角给 Pi 定调的最好一篇——Flask 作者以近三个月日用体验论证「极简内核+agent 自扩展」为什么成立:他的 extensions 全是让 Pi 自己写的(一个都不下载),浏览器自动化用技能替代 MCP/CLI。「这将成为我们的未来」的判断出自工程品味被反复验证的人,值得当坐标。

  • 背景定位:OpenClaw(朋友 Peter 的爆红项目,「带一点疯狂的科幻」)的引擎之下是小 coding agent Pi(Mario Zechner 所写、非常接地气)——两者共享同一理念:LLM 极擅长写代码与运行代码,所以拥抱它,而不是围起来
  • Pi 的两个关键设计:极小内核(作者所知最短的系统提示词+仅四个工具 Read/Write/Edit/Bash)+ 用扩展系统补足(扩展能把状态持久化进会话——极其强大);加分项:软件工程质量极高(不闪屏、低内存、不随机崩)
  • Pi 同时是组件集合:OpenClaw、作者的 Telegram bot、Mario 的 mom 都是在它之上搭的——把 Pi 指向它自己与 mom,它能给你变出一个连到你想要的渠道的 agent
  • 无 MCP 不是偷懒而是哲学:想让 agent 做它还不会的事,不是去下载扩展/技能,而是**让 agent 扩展它自己**——庆祝「代码写代码、代码跑代码」;要 MCP 就用 mcporter 把 MCP 调用包成 CLI
  • 为「可捏塑如黏土的软件」设的核心架构约束:会话可容纳多家 provider 的消息(不过度依赖单一 provider 不可迁移的特性);模型消息之外维护自定义消息(扩展存状态、系统存不必发给 AI 的信息);扩展状态可落盘+内置热重载(agent 写码→重载→测试循环直到功能成立);会话是树(开支线修坏工具不浪费主会话上下文,修完回卷+支线自动摘要)
  • 树状会话 vs MCP 的深层对比:MCP 工具需在会话启动时装进系统上下文——几乎不可能在不打爆缓存、不混淆 AI 的情况下完全重载工具定义;Pi 的扩展热重载没有这个约束
  • 作者的扩展清单全是「agent 按我的规格写的」:/answer(把 agent 回答里的问题重排成输入框)、/todos、/review(树状会话分支出干净审查上下文,UI 仿 Codex)、/control(Pi 给 Pi 发提示词的极简多 agent)、/files——社区还有 subagent 扩展与可观察 TUI 覆盖层里自主跑交互式 CLI 的 interactive-shell
  • 结论:用极简 agent 生活的迷人之处是「用造软件的软件过日子」——推到极致就是去掉 UI、接进聊天:这正是 OpenClaw,而它的爆发增长让作者越来越确信「这将以某种方式成为我们的未来」
27 段 · 约 16 分钟

Pi: The Minimal Agent Within OpenClaw, written on January 31, 2026. If you haven't been living under a rock, you will have noticed this week that a project of my friend Peter went viral on the internet. It went by many names. The most recent one is OpenClaw but in the news you might have encountered it as ClawdBot or MoltBot depending on when you read about it. It is an agent connected to a communication channel of your choice that just runs code. What you might be less familiar with is that what's under the hood of OpenClaw is a little coding agent called Pi. And Pi happens to be, at this point, the coding agent that I use almost exclusively.

《Pi:OpenClaw 里的极简 Agent》,2026 年 1 月 31 日。如果你这几天没住在石头下,应该注意到我朋友 Peter 的一个项目在互联网上爆红。它有过很多名字:最新的叫 OpenClaw,早些的新闻里你可能见过 ClawdBot 或 MoltBot(取决于你什么时候读到的)。它是一个接上你选择的通讯渠道、只管运行代码的 agent。你可能不太熟悉的是:OpenClaw 引擎盖之下,是一个叫 Pi 的小 coding agent。而 Pi 恰好是我此时几乎唯一在用的 coding agent。

Over the last few weeks I became more and more of a shill for the little agent. After I gave a talk on this recently, I realized that I did not actually write about Pi on this blog yet, so I feel like I might want to give some context on why I'm obsessed with it, and how it relates to OpenClaw.

过去几周我越来越像这个小 agent 的自来水。最近就它做了一次分享之后,我意识到博客里居然还没写过 Pi——所以想交代一下我为什么沉迷它、它和 OpenClaw 是什么关系。

Pi is written by Mario Zechner and unlike Peter, who aims for "sci-fi with a touch of madness," Mario is very grounded. Despite the differences in approach, both OpenClaw and Pi follow the same idea: LLMs are really good at writing and running code, so embrace this. In some ways I think that's not an accident because Peter got me and Mario hooked on this idea, and agents last year.

Pi 出自 Mario Zechner 之手。与追求「带一点疯狂的科幻」的 Peter 不同,Mario 非常接地气。尽管路数迥异,OpenClaw 与 Pi 遵循同一个想法:LLM 极其擅长写代码与运行代码——所以拥抱它。某种意义上这不是偶然:去年是 Peter 把我和 Mario 带上这条 agent 路的。

What is Pi? · Pi 是什么

So Pi is a coding agent. And there are many coding agents. Really, I think you can pick effectively anyone off the shelf at this point and you will be able to experience what it's like to do agentic programming. In reviews on this blog I've positively talked about AMP and one of the reasons I resonated so much with AMP is that it really felt like it was a product built by people who got both addicted to agentic programming but also had tried a few different things to see which ones work and not just to build a fancy UI around it. Pi is interesting to me because of two main reasons: First of all, it has a tiny core. It has the shortest system prompt of any agent that I'm aware of and it only has four tools: Read, Write, Edit, Bash. The second thing is that it makes up for its tiny core by providing an extension system that also allows extensions to persist state into sessions, which is incredibly powerful.

Pi 是一个 coding agent。而 coding agent 有很多——真的,此刻随便从货架上拿一个,你都能体验到 agentic programming 是什么滋味。我在博客评论里正面谈过 AMP,与它共鸣的原因之一是:它真像是「既对 agentic programming 上瘾、又试过多种方案验证什么有效」的人做的产品,而不是围着它搭个花哨 UI。Pi 让我感兴趣有两条主因:**一,内核极小**——据我所知它是所有 agent 里系统提示词最短的,且只有四个工具:Read、Write、Edit、Bash;**二,用扩展系统补足小内核**——扩展还能把状态持久化进会话,这极其强大。

And a little bonus: Pi itself is written like excellent software. It doesn't flicker, it doesn't consume a lot of memory, it doesn't randomly break, it is very reliable and it is written by someone who takes great care of what goes into the software.

还有个加分项:Pi 本身写得像优秀软件。不闪屏、不吃内存、不随机崩、非常可靠——出自一位对进入软件的每一行都极其在意的人之手。

Pi also is a collection of little components that you can build your own agent on top. That's how OpenClaw is built, and that's also how I built my own little Telegram bot and how Mario built his mom. If you want to build your own agent, connected to something, Pi when pointed to itself and mom, will conjure one up for you.

Pi 还是一小组组件的集合,你可以在上面搭自己的 agent——OpenClaw 是这么建的,我的小 Telegram bot 是这么建的,Mario 的 mom 也是。想造一个接到某个渠道的自有 agent?把 Pi 指向它自己和 mom,它就能给你变一个出来。

What's Not In Pi · Pi 里没有什么

And in order to understand what's in Pi, it's even more important to understand what's not in Pi, why it's not in Pi and more importantly: why it won't be in Pi. The most obvious omission is support for MCP. There is no MCP support in it. While you could build an extension for it, you can also do what OpenClaw does to support MCP which is to use mcporter. mcporter exposes MCP calls via a CLI interface or TypeScript bindings and maybe your agent can do something with it.

要理解 Pi 里有什么,更重要的是理解 Pi 里**没有**什么、为什么没有、以及更重要的:为什么永远不会加。最显眼的缺席是 MCP 支持——Pi 里没有。你可以为它写个扩展,也可以照 OpenClaw 的做法用 mcporter:它把 MCP 调用暴露成 CLI 接口或 TypeScript 绑定,你的 agent 也许能拿它做点什么。

And this is not a lazy omission. This is from the philosophy of how Pi works. Pi's entire idea is that if you want the agent to do something that it doesn't do yet, you don't go and download an extension or a skill or something like this. You ask the agent to extend itself. It celebrates the idea of code writing and running code.

这不是偷懒的省略,而是 Pi 工作哲学的一部分。Pi 的全部想法是:想让 agent 做它还不会的事,不是去下载一个扩展、一个技能之类的东西——**你让 agent 扩展它自己**。它庆祝「代码写代码、代码跑代码」这个理念。

That's not to say that you cannot download extensions. It is very much supported. But instead of necessarily encouraging you to download someone else's extension, you can also point your agent to an already existing extension, say like, build it like the thing you see over there, but make these changes to it that you like.

这不是说不能下载扩展——完全支持。但与其鼓励你下载别人的扩展,你还可以把 agent 指向一个现成扩展,说:照那边那个东西的样子造一个,但按我的喜好改这几处。

Agents Built for Agents Building Agents · 为「造 agent 的 agent」而造的 agent

When you look at what Pi and by extension OpenClaw are doing, there is an example of software that is malleable like clay. And this sets certain requirements for the underlying architecture of it that are actually in many ways setting certain constraints on the system that really need to go into the core design.

看 Pi(以及延伸开的 OpenClaw)在做什么,你会看到一种**像黏土一样可捏塑的软件**的实例。这给底层架构设了要求——很多方面是必须进核心设计的约束。

So for instance, Pi's underlying AI SDK is written so that a session can really contain many different messages from many different model providers. It recognizes that the portability of sessions is somewhat limited between model providers and so it doesn't lean in too much into any model-provider-specific feature set that cannot be transferred to another.

比如 Pi 底下的 AI SDK 写成这样:一个会话可以真正容纳来自多家模型 provider 的不同消息。它认识到会话在 provider 之间的可移植性有限,所以不过度依赖任何一家不可迁移的 provider 特性。

The second is that in addition to the model messages it maintains custom messages in the session files which can be used by extensions to store state or by the system itself to maintain information that either not at all is sent to the AI or only parts of it.

第二,除了模型消息,它还在会话文件里维护自定义消息——扩展可以用它存状态,系统自己也可以存「完全不发给 AI 或只发一部分」的信息。

Because this system exists and extension state can also be persisted to disk, it has built-in hot reloading so that the agent can write code, reload, test it and go in a loop until your extension actually is functional. It also ships with documentation and examples that the agent itself can use to extend itself.

因为这套机制存在、扩展状态又能落盘,它内置了热重载:agent 可以写代码→重载→测试,循环往复直到扩展真正能用。它还随附文档和示例——agent 自己就能拿它们来扩展自己。

Even better: sessions in Pi are trees. You can branch and navigate within a session which opens up all kinds of interesting opportunities such as enabling workflows for making a side-quest to fix a broken agent tool without wasting context in the main session. After the tool is fixed, I can rewind the session back to earlier and Pi summarizes what has happened on the other branch.

更妙的是:Pi 的会话是**树**。你可以在会话内分支与导航,打开各种有趣的玩法——比如开一条支线去修一个坏掉的 agent 工具,而不浪费主会话的上下文;工具修好后,我把会话回卷到早先,Pi 会把另一条分支上发生的事总结给我。

This all matters because for instance if you consider how MCP works, on most model providers, tools for MCP, like any tool for the LLM, need to be loaded into the system context or the tool section thereof on session start. That makes it very hard to impossible to fully reload what tools can do without trashing the complete cache or confusing the AI about how prior invocations work differently.

这一切之所以重要,举个对照:MCP 的机制要求(在多数 provider 上)MCP 工具与任何 LLM 工具一样,必须在会话启动时装进系统上下文或工具区。这导致「完全重载工具定义」变得极难或不可能——要么打爆整个缓存,要么把 AI 搞糊涂(它记得的先前调用方式和新定义对不上)。

Tools Outside The Context · 上下文之外的工具

An extension in Pi can register a tool to be available to the LLM to call and every once in a while I find this useful. For instance, despite my criticism of how Beads is implemented, I do think that giving an agent access to a to-do list is a very useful thing. And I do use an agent-specific issue tracker that works locally that I had my agent build itself. And because I wanted the agent to also manage to-dos, in this particular case I decided to give it a tool rather than a CLI. It felt appropriate for the scope of the problem and it is currently the only additional tool that I'm loading into my context.

Pi 的扩展可以注册一个供 LLM 调用的工具,偶尔我也觉得这有用。比如,虽然我批评过 Beads 的实现方式,但给 agent 一个待办清单确实很有用。我在用一个本地运行的、agent 专属的 issue 跟踪器——就是让 agent 自己造的。因为我还想让 agent 管待办,这个场景我决定给它一个工具而不是 CLI:就问题的规模而言这样合适,而且它目前是我加载进上下文的唯一额外工具。

But for the most part all of what I'm adding to my agent are either skills or TUI extensions to make working with the agent more enjoyable for me. Beyond slash commands, Pi extensions can render custom TUI components directly in the terminal: spinners, progress bars, interactive file pickers, data tables, preview panes. The TUI is flexible enough that Mario proved you can run Doom in it. Not practical, but if you can run Doom, you can certainly build a useful dashboard or debugging interface.

但大多数时候,我给 agent 添加的不是技能就是 TUI 扩展——让与 agent 协作更愉快。斜杠命令之外,Pi 扩展能直接在终端渲染自定义 TUI 组件:转圈指示、进度条、交互式文件选择器、数据表格、预览面板。这 TUI 灵活到 Mario 证明过能在里面跑 Doom——不实用,但既然能跑 Doom,造个有用的仪表盘或调试界面自然不在话下。

I want to highlight some of my extensions to give you an idea of what's possible. While you can use them unmodified, the whole idea really is that you point your agent to one and remix it to your heart's content.

挑几个我的扩展给你看看可能性。原样可用当然没问题,但整套想法的真义是:把 agent 指向其中一个,按你的心意重混(remix)。

### /answer I don't use plan mode. I encourage the agent to ask questions and there's a productive back and forth. But I don't like structured question dialogs that happen if you give the agent a question tool. I prefer the agent's natural prose with explanations and diagrams interspersed. The problem: answering questions inline gets messy. So /answer reads the agent's last response, extracts all the questions, and reformats them into a nice input box.

我不用计划模式。我鼓励 agent 提问,来回切磋很有产出。但我不喜欢「给 agent 一个提问工具」后出现的结构化问答对话框——我偏好 agent 的自然散文,解释与图示穿插其间。问题是:就地回答问题会越来越乱。于是 /answer 读取 agent 的上一条回复,抽出所有问题,重排成一个漂亮的输入框。

### /todos Even though I criticize Beads for its implementation, giving an agent a to-do list is genuinely useful. The /todos command brings up all items stored in .pi/todos as markdown files. Both the agent and I can manipulate them, and sessions can claim tasks to mark them as in progress.

虽然批评过 Beads 的实现,但给 agent 待办清单是真有用。/todos 命令列出 .pi/todos 下以 markdown 文件存储的全部条目——agent 和我都能改,会话还能认领任务标记为进行中。

### /review As more code is written by agents, it makes little sense to throw unfinished work at humans before an agent has reviewed it first. Because Pi sessions are trees, I can branch into a fresh review context, get findings, then bring fixes back to the main session. The UI is modeled after Codex which provides easy to review commits, diffs, uncommitted changes, or remote PRs. The prompt pays attention to things I care about so I get the call-outs I want (eg: I ask it to call out newly added dependencies.)

越来越多代码由 agent 写,把没完的活直接扔给人之前先让 agent 审一遍才合理。因为 Pi 会话是树,我可以分支出一个干净的审查上下文、拿回发现、再把修复带回主会话。UI 仿 Codex:轻松审查 commit、diff、未提交变更或远端 PR。提示词盯我在意的东西,得到的提醒正是我要的(比如我要求它专门标出新加的依赖)。

### /control An extension I experiment with but don't actively use. It lets one Pi agent send prompts to another. It is a simple multi-agent system without complex orchestration which is useful for experimentation.

一个我在试验但没日常使用的扩展:让一个 Pi agent 给另一个发提示词。一个没有复杂编排的极简多 agent 系统,适合做实验。

### /files Lists all files changed or referenced in the session. You can reveal them in Finder, diff in VS Code, quick-look them, or reference them in your prompt. shift+ctrl+r quick-looks the most recently mentioned file which is handy when the agent produces a PDF.

列出会话中变更或引用过的所有文件:在 Finder 里显示、在 VS Code 里 diff、快速预览、或在提示词里引用。shift+ctrl+r 快速预览最近提到的文件——agent 产出 PDF 时很好用。

Others have built extensions too: Nico's subagent extension and interactive-shell which lets Pi autonomously run interactive CLIs in an observable TUI overlay.

别人也造了扩展:Nico 的 subagent 扩展,以及 interactive-shell——让 Pi 在一个可观察的 TUI 覆盖层里自主运行交互式 CLI。

Software Building Software · 软件造软件

These are all just ideas of what you can do with your agent. The point of it mostly is that none of this was written by me, it was created by the agent to my specifications. I told Pi to make an extension and it did. There is no MCP, there are no community skills, nothing. Don't get me wrong, I use tons of skills. But they are hand-crafted by my clanker and not downloaded from anywhere. For instance I fully replaced all my CLIs or MCPs for browser automation with a skill that just uses CDP. Not because the alternatives don't work, or are bad, but because this is just easy and natural. The agent maintains its own functionality.

这些都只是「你能用 agent 做什么」的点子。重点是:**没有一样是我写的——全是 agent 按我的规格造的。**我跟 Pi 说做个扩展,它就做了。没有 MCP、没有社区技能、什么都没有。别误会,我用了大量技能——但它们都是我的 clanker 手工打的,不是从哪儿下载的。比如我把浏览器自动化的全部 CLI 和 MCP 换成了一个只用 CDP 的技能——不是因为替代品不好使,而是这样做就是简单、自然。agent 维护它自己的功能。

My agent has quite a few skills and crucially I throw skills away if I don't need them. I for instance gave it a skill to read Pi sessions that other engineers shared, which helps with code review. Or I have a skill to help the agent craft the commit messages and commit behavior I want, and how to update changelogs. These were originally slash commands, but I'm currently migrating them to skills to see if this works equally well. I also have a skill that hopefully helps Pi use uv rather than pip, but I also added a custom extension to intercept calls to pip and python to redirect them to uv instead.

我的 agent 有不少技能,而且关键在于——不需要的我就扔掉。比如给过它一个「读其他工程师分享的 Pi 会话」的技能,code review 时有用;还有一个帮 agent 按我想要的方式写提交信息与提交行为、更新变更日志的技能——它们最初是斜杠命令,我正在迁去技能形态看看效果是否同样好。我还有个希望帮 Pi 用 uv 而不是 pip 的技能,另外加了个自定义扩展拦截对 pip 和 python 的调用、重定向到 uv。

Part of the fascination that working with a minimal agent like Pi gave me is that it makes you live that idea of using software that builds more software. That taken to the extreme is when you remove the UI and output and connect it to your chat. That's what OpenClaw does and given its tremendous growth, I really feel more and more that this is going to become our future in one way or another.

使用 Pi 这样极简 agent 的迷人之处,一部分在于它让你亲历「用造软件的软件过日子」这个理念。把它推到极致:去掉 UI 与输出、接进你的聊天——这就是 OpenClaw 干的事。看着它的爆发式增长,我越来越觉得:**这将以某种方式成为我们的未来。**

回忆挑战

先不看答案自己回忆——讲不出来再回正文找。考的是关系,不是标签。

1OpenClaw(Peter)与 Pi(Mario)风格迥异——「带点疯狂的科幻」vs「非常接地气」——为什么还能共享同一架构?他们的共同信念是什么?

共同信念是「LLM 极擅长写代码与运行代码,所以拥抱这一点」。风格差异体现在产品形态(炫酷的聊天 agent vs 朴素的终端工具),但架构上都把「代码写代码」当作第一性能力:OpenClaw 是 Pi 组件接上通讯渠道、Pi 本体可自扩展——两者的关系是引擎与整车,而不是两种路线。

2Armin 说 Pi 的扩展几乎都是让 agent 自己写的、不用下载社区的——这与「MCP 生态繁荣」是两种世界观。各自的代价与收益是什么?

自扩展的收益:扩展完全贴合自己的工作流(连 UI 都是自己要的样子)、零信任成本(不用审查别人的代码跑在自己机器上)、且「写扩展」本身在训练 agent 对系统的理解;代价是需要一个好 agent 与一点耐心,产出不可移植给他人。MCP 生态的收益:开箱即用、社区共享;代价是上下文开销(工具描述常驻)、跨机器信任审查、以及「工具集由别人定义你的工作流」。Armin 的选择本质是把「下载什么」的决策权也收回自己手里。

3「会话是树」如何解决了「修一个坏工具」的上下文经济问题?对比在单线程会话里直接修会怎样?

单线程里修工具:修复过程的全部读码/试错/工具输出都进主会话上下文,把与原任务无关的垃圾永久留在窗口里。树状会话:从当前点开一条支线,在支线里修工具(上下文消耗留在支线),修完把主会话回卷到分支前——Pi 还会把支线摘要带上,既不丢结论也不背过程。本质是把「上下文」从单本流水账变成可分叉可回收的账本。