Pi Durable
- ID: 8d8c225d
- 原文链接: https://earendil.com/posts/pi-durable
- 作者: Earendil Engineering
- 日期: 2026-10-01
- 分类: agents
- 来源类型: article
- 标签: agent-harness、durability、checkpointing、framework
- 质量评分: 4/5
- 抓取时间: 2026-10-03 (content-fetcher, opencli web read)
中文导读
与 Pi 1.0 同日发布的实验性框架 Pi Durable,把极简 harness 原则延伸到长时运行 agent:核心是 checkpoint 化任务模型,run 的每一步都是任务,推进前先存 checkpoint,进程死亡后新进程打开同一存储,从未完成任务的上个 checkpoint 继续;被截断的模型请求重发,部分答案标记 aborted 留在 transcript;可安全重跑的工具调用(replay: safe)才重跑,否则告知模型被中断;requestId 保证提交 exactly-once。架构上 harness 打开于存储后端(内置 memory/SQLite/JSONL,不用 Node API,可跑在 Bun 或 Cloudflare Durable Object),一个进程独占存储、其他 client attach;SQLite 模式下内存只保留工作集(活跃 transcript、运行中任务),靠 compaction 让数万条消息的会话也装得下。单 harness 可并发跑多会话,会话可在 transcript 任意点 fork(主频道与线程各跑互不阻塞),每个会话存自己的模型/工具/工作目录。扩展系统提供 system prompt sections、tools、hooks(链式,beforeTool 可改参/阻断,决策存 memo 防重启后重复询问)与自定义任务(所有权树、failFast 等待、abort 自底向上先清理自身副作用);compaction 是后台任务不阻塞会话;应用状态放 typed JSON documents 与 transcript 同一原子提交;registry 可热替换扩展(运行中调用跑旧代码,下一个调用用新代码);所有提交状态皆可被多客户端 watch/steer(multiplayer)。源码约 1.5 万行(含存储后端 3000 行),agent 可整读。
为什么值得关注
长时运行 agent 的持久性难题被拆成任务级 checkpoint、所有权树和 exactly-once 提交三个机制,而不是一个大的 recovery 流程——这套原语对任何做 agent 运行时的人都有参考价值。
English Summary
Pi Durable is an experimental framework shipped alongside Pi 1.0, extending the minimal-harness principles to long-running, durable, malleable agents. Every step of a run is a task that stores a checkpoint before proceeding; after a crash a new process opens the same storage and continues unfinished tasks from their last checkpoints. A cut-off model request is re-sent with the partial answer left in the transcript marked aborted; tool calls rerun only when marked replay-safe, otherwise the model is told it was interrupted; a requestId makes submissions exactly-once. The harness opens over a storage backend (memory, SQLite, JSONL built in; no Node APIs, so it runs on Bun or inside a Cloudflare Durable Object); one process owns the storage and other clients attach. Only the working set stays in memory. One harness runs many conversations concurrently, forkable at any transcript point, each conversation keeping its own model, tools, and working directory. Extensions bundle prompt sections, tools, chained hooks (with memo-stored decisions), and custom tasks organized in an ownership tree with failFast waits and bottom-up abort cleanup. Compaction runs as a background task without stalling the conversation; application state lives in typed JSON documents committed atomically with the transcript; the registry hot-swaps extensions on running agents; every committed state is watchable and steerable by multiple clients. Source is about 15,000 lines including 3,000 of storage backends.
Obsidian 原文摘录(抓取正文头部)
# Pi Durable
> 发布时间: 2026-10-01
> 原文链接: https://earendil.com/posts/pi-durable
---
# Pi Durable
日期:2026年10月01日周四
发件人:Earendil Engineering <[rfc@earendil.com](mailto:rfc@earendil.com)\>
收件人:您
主题:Pi Durable
Today Earendil and the Pi community [shipped Pi 1.0](https://earendil.com/posts/pi-1-0/). This reflects our belief that after countless hours of hardening, maintenance, and active development, Pi is now a solid foundation on which to build. Pi also continues to evolve. Together with Pi 1.0, we are shipping an experimental new package called Pi Durable. Pi Durable was built specifically for long-running, durable, and malleable agents that can run anywhere. We would like you to join in the fun and help us make it the best durable harness there is.
## Why Pi Durable?
Pi the coding agent is built to run on your (remote) machine, inside a terminal, driven by one person. If the process dies, you look at what happened and tell it to continue. That is what Pi 1.0 focuses on and excels at, and that is not changing.
At Earendil, we want to bring this technology to everyone, in whatever form fits their needs best. For that, we need a harness that runs anywhere, can be reached from different surfaces, supports infinitely long conversations, survives catastrophic internal and external failures, and lets multiple humans steer the same agents.
Pi Durable is that harness. It does not replace the Pi coding agent. It is a framework for building any agentic application, coding agents included. It shares not only code with the Pi coding agent, like pi-ai, but also its principles: minimalism and malleability.
It also lets us explore designs in this space without disrupting Pi the coding agent. Lessons we learn building agentic applications on Pi Durable will flow back into Pi the coding agent as they prove themselves valuable.
## What is a harness?
Everybody has their own definition of a harness. We [wrote about this previously](https://earendil.com/posts/what-is-a-harness/), but let us reintroduce the concept of the harness for Pi Durable.
A harness is storage plus the machinery needed to run one or more conversations with large language models in parallel. It provides the tools those models call, and the execution environments the tools run in.
A conversation is an interaction between you and an agent, recorded as a transcript. The agent is the large language model together with its settings, like the thinking level, and the tools it can call.
Tools do their work through an execution environment, which can be your laptop, a remote VM, or an in-memory sandbox. Which tools and which execution environment an agent gets is up to each conversation.
Everything the harness runs, from calling the model to executing a tool, is a task.
Like everything in Pi, Pi Durable is built so your agent can understand it. The entire source code, without tests, is about 15,000 lines, which comes out to about 150,000 tokens with GPT and about 250,000 with Claude. That's the worst case. To build on Pi Durable, your agent rarely needs all of it; the storage backends alone are 3,000 lines it can usually skip.
Now let us give you a little tour of Pi Durable, to illustrate what we built and why we built it.
## Long runs anywhere
We want agents to run for a long time and to be able to run anywhere, where anywhere currently means anywhere there is a JavaScript runtime.
In Pi Durable, a harness opens over a storage backend. Pi Durable ships memory, SQLite, and JSONL storage, plus a conformance suite and benchmarks for your own backend. The SQLite and JSONL storage code uses no Node APIs, so with a small adapter it runs on Bun or inside a Cloudflare Durable Object. The storage interface is small and easy to implement on top of whatever you have, like a key-value store or Postgres. One process owns a storage at a time, and other clients attach to that process.
On SQLite, the harness only keeps the working set in memory: the active transcripts, live tasks, and pending submissions. Everything else stays on disk until it is needed. Active transcripts are naturally bounded by the model's context window, because compaction summarizes older messages before they overflow it. So even a conversation with tens of thousands of messages fits snugly into memory.
Tools that need files or a shell get them from an execution environment. Pi Durable ships a Node execution environment, which gives tools access to your local files. Like storage, the execution environment interface is small and easy to implement, so you can also expose remote execution environments to your tools. That allows the harness to run on one machine while its tools run on another. Your `env` function builds the environment for every tool call, from the conversation's working directory, so each conversation can run in a different place.
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context"; import { createModels } from "@earendil-works/pi-ai/models"; import { openaiProvider } from "@earendil-works/pi-ai/providers/openai"; import { createRegistry, Harness } from "@earendil-works/pi-durable"; import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
## Notes
- Content grounded in an opencli web read fetch of the full article (2026-10-03 (content-fetcher, opencli web read)).
- 中文导读 is the entry's summary_zh (light cleanup from the fetched source); 为什么值得关注 is the entry's one_liner; no claims beyond the fetched source text were added.
- Source file cached at /tmp/aaif_pi_durable.md during the run.