AI Agent Durable Pi Durable - spinningideas/resources GitHub Wiki
Pi Durable: The Complete Guide to Earendil's Durable Agent Framework
Pi Durable (@earendil-works/pi-durable) is an open-source, lightweight TypeScript framework for building long-running, crash-resilient, and malleable AI agents. Released alongside Pi 1.0 by Earendil, Pi Durable represents a fundamental architectural departure from conventional ephemeral chatbots and simple transcript-resuming scripts.
In a Pi Durable system, conversations, model turns, tool executions, task ownership trees, and structured application state are committed to persistent transactional storage before anything is rendered to the user. If a process crashes, an operating system reboots, or a network connection drops mid-flight, reopening storage resumes execution precisely where it stopped - without duplicating hazardous real-world side effects.
This definitive guide synthesizes all principles, architectural primitives, setup procedures, and real-world implementations of Pi Durable. It incorporates deep technical insights from Earendil, operational analyses from MindStudio, and video demonstrations from Scott Tolinski (Syntax) and Nathan Disler.
1. Executive Summary & Architectural Philosophy
The Vision: Minimalism and Malleability
Traditional agent frameworks often suffer from dependency bloat, fragile state machines, and leaky abstractions. Pi Durable was built on two core tenets:
- Minimalism: The entire core harness spans only ~15,000 lines of clean, readable TypeScript with zero heavy external dependencies. It relies exclusively on
@earendil-works/pi-aifor universal model routing and@earendil-works/chordfor reactive document synchronization. - Super-Malleability: Agents should not be black boxes. In Pi Durable, running agents, extensions, tools, system prompts, and storage adapters can be hot-reloaded and modified on disk while conversations and background tasks continue running.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TRADITIONAL EPHEMERAL CHATBOT β
β β
β User Input βββΊ [In-Memory Run Loop] βββΊ [Tool Execution] βββΊ [LLM API] β
β β β
β CRASH / RESTART β
β βΌ β
β *TOTAL LOSS* β
β (Mid-flight tool execution lost, queued instructions erased, β
β uncommitted side effects unknown, duplicate charges/bugs) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
VS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PI DURABLE AGENT HARNESS β
β β
β External Signals βββΊ [Client Thin Surfaces] (Web Hub, TUI, Slack, Webhook) β
β β (Watch & Steer via HTTP/WebSocket) β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β PERSISTENT HARNESS (Local / VPS / Edge) β β
β β β β
β β 1. Atomic Commit Line βββΊ Persistent Storage (SQLite / Cloudflare DO)β β
β β 2. Task Ownership Trees (Checkpoint on every turn & step) β β
β β 3. Replay-Safe Tool Protocol (`replay: "safe"` vs Dangerous Interruptβ β
β β 4. Background Compaction (Infinite runtime inside finite context) β β
β β 5. Reactive Typed Documents (Domain state committed with transcript) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β CRASH / REBOOT / DEPLOY β
β βΌ β
β [Instant Resume from Exact Last Checkpoint] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Transcript /resume vs. True Durable Execution
Most developers assume that saving chat transcripts to MongoDB or Redis makes an agent "durable." However, as explained in Earendil's announcement and MindStudio's technical breakdown, transcript history is not run state:
| Dimension | Naive Chat Transcript /resume |
Pi Durable True Execution |
|---|---|---|
| What is Stored | Simple array of completed user and assistant strings | Transactional event journal, checkpoints, task ownership trees, pending submission queues, and typed domain documents |
| Mid-Flight Crashes | Blindly re-runs the entire prompt or fails completely | Identifies interrupted tool calls; re-runs only replay: "safe" tools; passes structured interruption notices to model for unsafe tools |
| Side-Effect Prevention | None (high risk of repeating destructive actions) | Idempotency keys + atomic transactional commits |
| Subagent Lifecycles | Ephemeral in-memory threads destroyed on restart | Hierarchical task trees where subagents are durable tasks with distinct rollback/abort policies |
| Context Overflows | Crashes with provider context_length_exceeded errors |
Non-blocking background compaction summarizes older turns while archiving raw history to disk |
| Client Decoupling | Agent dies when browser tab or terminal closes | Agent lives on the host/edge; multiple clients (TUI, Web Hub, CLI) can attach, disconnect, and steer concurrently |
2. Core Architectural Primitives
Pi Durable organizes agentic systems around seven foundational primitives:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HARNESS ROOT β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β CONVERSATION β β
β β β β
β β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ β β
β β β ENTRIES β β TYPED DOCUMENTS β β β
β β β β’ pi.system (Instructions)β β β’ pi.agent (Model Config) β β β
β β β β’ pi.user (User Prompts) β β β’ pi.live (Active Steps) β β β
β β β β’ pi.assistant (Responses)β β β’ pi.inbox (Queued Tasks) β β β
β β β β’ pi.tool-result (Outputs)β β β’ pi.usage (Token Spend) β β β
β β β β’ pi.reset (Context Marks)β β β’ Custom Domain Documents β β β
β β βββββββββββββββ¬ββββββββββββββ βββββββββββββββ¬ββββββββββββββ β β
β β β β β β
β β ββββββββββββββββββ¬βββββββββββββββββ β β
β β βΌ β β
β β βββββββββββββββββββββββββββββββββ β β
β β β ATOMIC COMMIT LINE (tx) β β β
β β βββββββββββββββββ¬ββββββββββββββββ β β
β β β β β
β β ββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β β
β β β TASK OWNERSHIP TREES β β β
β β β pi.generation (Owns Model Call & Evaluates Tool Invocations)β β β
β β β βββ pi.tool (Durable Task per Invoked Tool) β β β
β β β βββ Custom Subtasks (Phased Checkpointing) β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β STORAGE ADAPTER β β
β β Node SQLite β Cloudflare Durable Objects β IndexedDB β JSONL β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1. The Harness
The Harness is the master orchestrator. It manages open storage, model provider registries, tool definitions, execution environments, and concurrency locks. Nothing is emitted or rendered to the user until its corresponding commit has been written to persistent storage.
2. Conversations
A Conversation represents a durable thread. The method harness.root(context) initializes or opens the primary root conversation. Conversations can be forked to explore alternative reasoning branches without corrupting the main timeline. Conversation handles are lightweight references compared by id.
3. Immutable Entries
Every event in a conversation is an immutable Entry:
pi.system: Base instructions and dynamic prompts.pi.user: Human messages or incoming external webhook payloads.pi.assistant: Model thoughts and generated text.pi.tool-result: Structured outputs returned by tools.pi.reset: A context-boundary entry. The model only reads entries from the most recentpi.resetforward, allowing compaction to prune the active context window without discarding historical data on disk.
4. Atomic Commits (conversation.commit)
State changes occur through atomic transactions. A single commit can simultaneously append new transcript entries, update typed domain documents, and instantiate new tasks:
await conversation.commit(async (tx) => {
tx.append({ kind: "pi.tool-result", toolCallId: "call_123", output: "success" });
tx.doc(taskDoc).update({ status: "completed", finishedAt: Date.now() });
});
Guaranteed Consistency: Either the entire batch writes to storage, or the entire operation rolls back.
5. Typed Documents (defineDoc)
Application domain state lives alongside conversation transcripts in typed JSON documents. Built-in documents include:
pi.agent: Active model provider and parameters.pi.live: Real-time tracker for in-flight generation steps and active tools.pi.inbox: Queue of incoming submissions waiting for processing.pi.usage: Cumulative token counts and API spend tracking. Developers can define custom typed documents (e.g., ticket state, shopping cart, bug diagnosis) using TypeBox schemas.
6. Tasks & Hierarchical Ownership Trees (defineTask)
Long-running workflows are modeled as durable state machines called Tasks. Every task has an owner (either a conversation or a parent task) and transitions through explicit phases:
initial: Task initialized.waiting: Paused waiting for external I/O, child tasks, or human sign-off.terminal: Completed or aborted. The harness executes model calls as built-inpi.generationtasks, which spawn and own childpi.tooltasks. Checkpoints are recorded at every step.
7. Replay Safety & Tool Protocols
When an agent dies mid-execution, re-running unconfirmed tools blindly can cause catastrophic side effects (e.g., duplicate payments or repeated git pushes). Pi Durable requires tool authors to declare replay behavior:
replay: "safe": The tool is strictly idempotent (e.g., reading a file, searching an index). On restart, the harness safely re-executes the tool.- Dangerous / Side-Effecting Tools (Default): Tools without the safe flag return an
interruptedstatus if caught in a crash. The model inspects the interruption notice upon resumption and decides how to recover.
3. Real-World Implementations & Video Breakdowns
Scott Tolinski: The Self-Healing Sentry Coding Agent
- Video Reference: You need to check out Pi Durable
- Presenter: Scott Tolinski (Syntax.fm / @stolinski)
The Breakdown
Scott Tolinski details how he transformed an unpredictable coding assistant into an autonomous, self-healing system that fixes software bugs overnight:
"Last night, my code fixed itself. A Sentry error started my agent while I was asleep. It diagnosed the bug, wrote a reproduction test, patched the source code, ran the test suite, and submitted a pull request - all running through Pi Durable."
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SELF-HEALING SENTRY AGENT WORKFLOW β
β β
β ββββββββββββββββ Webhook ββββββββββββββββββββββββββββββββββββββββ β
β β Sentry Error β ββββββββββββββΊ β Pi Durable Daemon β β
β β Telemetry β β (Wakes up, commits webhook to inbox) β β
β ββββββββββββββββ ββββββββββββββββββββ¬ββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌββββββββββββββββββββ β
β β Isolated Git Worktree β β
β β 1. Git checkout reproduction branch β β
β β 2. Author failing regression test β β
β β 3. Execute patch implementation β β
β ββββββββββββββββββββ¬ββββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌββββββββββββββββββββ β
β β Deterministic Test Runner β β
β β β’ tsc --noEmit (Typecheck) β β
β β β’ vitest run (Verify test passes) β β
β ββββββββββββββββββββ¬ββββββββββββββββββββ β
β β Pass Gate β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββ β
β β GitHub Pull Request Created β β
β β (Ready for human morning review) β β
β ββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Technical Takeaways from Scott's Implementation:
- Eliminating Plumbing Code: Pi Durable eliminated thousands of lines of boilerplate code previously needed for queuing, SQLite serialization, streaming protocols, and retry loops.
- Crash Resilience during Long Runs: Complex diagnostics often take 10 to 20 minutes. If the Node.js process experiences an out-of-memory exception or network timeout during a npm install step, Pi Durable reopens the worktree and resumes execution without re-prompting from scratch.
- Cross-Platform Flexibility: The same Pi Durable agent logic runs locally in Node.js, inside a headless Docker container on a VPS, or in a web browser using client-side IndexedDB.
Nathan Disler: Distributed Proactive Agent Networks (durable-pi)
- Video Reference: Pi Durable PROACTIVE Agents Video Breakdown
- Repository: disler/durable-pi on GitHub
- Presenter: Nathan Disler
The Breakdown
Nathan Disler operationalizes Pi Durable into a distributed, multi-device agent network called Durable Pi. His architecture demonstrates the shift from reactive prompt-response bots to proactive background workers ("works for you, then waits").
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DURABLE PI DISTRIBUTED NETWORK β
β β
β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
β β TERMINAL TUI β β WEB HUB UI β β
β β (just tui attach local) β β (http://localhost:4781) β β
β βββββββββββββββ¬ββββββββββββββ βββββββββββββββββ¬ββββββββββββββββ β
β β β β
β βββββββββββββββββββββ¬ββββββββββββββββββββ β
β β WebSocket / HTTP β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β DURABLE PI DEVICE BACKEND β β
β β (Runs on Port :4780 via Node 24) β β
β β β β
β β β’ Persistent SQLite Store (Local state committed to disk) β β
β β β’ Proactive Watchers (Monitors filesystem, webhooks, cron ticks) β β
β β β’ Multi-Client Sync Engine (Broadcasts live streaming tokens) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Capabilities of Durable Pi:
- Multiplayer Steering: Because the agent's state is committed to SQLite, a developer can observe execution in the Web Hub interface while another team member attaches via a terminal TUI (
just tui attach local) to inject steering instructions without terminating the process. - Proactive Background Loops: The agent does not terminate after answering a query; it enters an event-listening state, continuously monitoring system logs or directories and initiating autonomous triage when anomalies occur.
4. End-to-End Implementation & Code Guides
1. Installation & Environment Setup
Pi Durable requires Node.js 22+ (Node.js 24 recommended). Install the core packages:
npm install @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/chord @sinclair/typebox
2. Initializing Storage & Opening the Harness
The following example demonstrates opening a persistent Node SQLite storage engine with write-ahead logging (WAL) and configuring automatic context compaction:
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import { createModels } from "@earendil-works/pi-ai/models";
import { anthropicProvider } from "@earendil-works/pi-ai/providers/anthropic";
import { openaiProvider } from "@earendil-works/pi-ai/providers/openai";
import { createRegistry, Harness, defineTool } from "@earendil-works/pi-durable";
import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
import { openNodeSqliteStorage } from "@earendil-works/pi-durable/storage/sqlite/node";
import { Type } from "@sinclair/typebox";
const context = BACKGROUND_CONTEXT;
// 1. Configure Model Providers
const models = createModels();
models.setProvider(anthropicProvider());
models.setProvider(openaiProvider());
// 2. Initialize Tool Registry
const registry = createRegistry();
// 3. Define a Safe Tool (Replay-safe)
registry.install({
name: "filesystem_tools",
tools: [
defineTool({
name: "readFile",
description: "Read contents of a file safely",
parameters: Type.Object({
filePath: Type.String(),
}),
replay: "safe", // <--- HARNESS CAN SAFELY RE-RUN THIS ON RESTART
execute: async ({ filePath }) => {
const fs = await import("node:fs/promises");
const content = await fs.readFile(filePath, "utf-8");
return { content: [{ type: "text", text: content }] };
},
}),
defineTool({
name: "applyGitPatch",
description: "Applies a code diff to the local repository",
parameters: Type.Object({
patch: Type.String(),
}),
// Omit replay: "safe" -> Dangerous side effect!
execute: async ({ patch }) => {
// Implementation of git patch
return { content: [{ type: "text", text: "Patch applied successfully" }] };
},
}),
],
});
// 4. Initialize Persistent SQLite Storage
const storage = await openNodeSqliteStorage("./pi_agent_state.sqlite");
// 5. Open the Durable Harness
const harness = await Harness.open(storage, {
models,
registry,
env: ({ cwd }) => new NodeExecutionEnv({ cwd: cwd ?? process.cwd() }),
settings: {
compaction: {
reserveTokens: 16384, // Headroom reserved for model reasoning
backgroundTokens: 32768, // Threshold triggering background compaction
},
},
}, context);
// 6. Connect to Root Conversation
const conversation = await harness.root(context, {
agent: {
model: { provider: "anthropic", modelId: "claude-sonnet-5-5" },
cwd: "./workspace",
},
});
3. Defining Atomic Typed Documents (defineDoc)
Typed documents allow agents to record structured domain artifacts (e.g., ticket state or bug reports) that update in the same atomic transaction as the conversation:
import { defineDoc } from "@earendil-works/pi-durable";
import { Type } from "@sinclair/typebox";
export const IncidentDoc = defineDoc({
name: "incident.tracker",
schema: Type.Object({
ticketId: Type.String(),
severity: Type.Union([Type.Literal("P1"), Type.Literal("P2"), Type.Literal("P3")]),
status: Type.Union([Type.Literal("investigating"), Type.Literal("patching"), Type.Literal("resolved")]),
failingTests: Type.Array(Type.String()),
resolvedAt: Type.Optional(Type.Number()),
}),
});
// Committing typed document updates alongside transcript entries
await conversation.commit(async (tx) => {
tx.doc(IncidentDoc).set({
ticketId: "SENTRY-9042",
severity: "P1",
status: "patching",
failingTests: ["tests/auth.test.ts"],
});
});
4. Complete Code: Autonomous Self-Healing Incident Agent
Below is a full working script illustrating an autonomous self-healing agent inspired by Scott Tolinski's Sentry workflow:
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import { createModels } from "@earendil-works/pi-ai/models";
import { anthropicProvider } from "@earendil-works/pi-ai/providers/anthropic";
import { createRegistry, Harness, defineTool } from "@earendil-works/pi-durable";
import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
import { openNodeSqliteStorage } from "@earendil-works/pi-durable/storage/sqlite/node";
import { Type } from "@sinclair/typebox";
import { execSync } from "node:child_process";
import * as fs from "node:fs/promises";
async function main() {
const context = BACKGROUND_CONTEXT;
const models = createModels();
models.setProvider(anthropicProvider());
const registry = createRegistry();
// Tool 1: Run local test suite (Replay safe)
registry.install({
name: "ci_tools",
tools: [
defineTool({
name: "runTests",
description: "Executes vitest test suite and returns failure logs",
parameters: Type.Object({}),
replay: "safe",
execute: async () => {
try {
const output = execSync("npx vitest run --reporter=json", { encoding: "utf-8" });
return { content: [{ type: "text", text: output }] };
} catch (err: any) {
return { content: [{ type: "text", text: err.stdout || err.message }] };
}
},
}),
defineTool({
name: "writeCodePatch",
description: "Applies a code fix to an existing file",
parameters: Type.Object({
filePath: Type.String(),
newContent: Type.String(),
}),
execute: async ({ filePath, newContent }) => {
await fs.writeFile(filePath, newContent, "utf-8");
return { content: [{ type: "text", text: `Successfully updated ${filePath}` }] };
},
}),
defineTool({
name: "createPullRequest",
description: "Commits changes and opens a pull request via GitHub CLI",
parameters: Type.Object({
branchName: Type.String(),
title: Type.String(),
body: Type.String(),
}),
execute: async ({ branchName, title, body }) => {
execSync(`git checkout -b ${branchName}`);
execSync("git add . && git commit -m 'Autonomous fix generated by Pi Durable'");
execSync(`gh pr create --title "${title}" --body "${body}"`);
return { content: [{ type: "text", text: `PR created on branch ${branchName}` }] };
},
}),
],
});
const storage = await openNodeSqliteStorage("./self_healing_agent.sqlite");
const harness = await Harness.open(storage, {
models,
registry,
env: () => new NodeExecutionEnv({ cwd: process.cwd() }),
}, context);
const conversation = await harness.root(context, {
agent: {
model: { provider: "anthropic", modelId: "claude-sonnet-5-5" },
},
});
// Simulated Sentry Webhook Ingestion
const incomingError = {
id: "ERR-774",
message: "TypeError: Cannot read properties of undefined (reading 'jwtToken')",
stack: "at verifySession (src/auth/session.ts:42:18)",
};
console.log("Submitting Sentry error incident to Pi Durable...");
await conversation.submit({
kind: "pi.user",
text: `A production error was detected by Sentry:
Error: ${incomingError.message}
Stack Trace: ${incomingError.stack}
Investigate the failure, run existing tests to observe the issue, write a patch to handle undefined session tokens safely, verify that tests pass, and open a pull request.`,
});
// Wait for autonomous completion
await conversation.idle(context);
console.log("Self-healing task completed. All state committed to SQLite.");
}
main().catch(console.error);
5. Running the Durable Pi Network (disler/durable-pi)
To run Nathan Disler's distributed Web Hub and Terminal TUI environment:
# 1. Clone the repository
git clone https://github.com/disler/durable-pi.git
cd durable-pi
# 2. Configure Environment
cp .env.example .env
# Edit .env and supply your OPENROUTER_API_KEY or ANTHROPIC_API_KEY
# 3. Setup device network configuration
cp dpi-network.example.yaml dpi-network.yaml
# 4. Install dependencies (Node 24 required)
just install
# 5. Initialize the local device backend
just net up local
# 6. Build the web hub frontend
just hub build
# 7. Start the device backend daemon (serves agent server on port 4780)
just backend run
# 8. In a separate terminal, launch the Web Hub UI (serves at http://localhost:4781)
just hub start
# 9. In another terminal, connect via terminal TUI to inspect and steer
just tui attach local
5. Storage Adapters & Multi-Platform Deployment
Pi Durableβs modular storage interface allows agents to run across varied runtime topologies:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STORAGE DEPLOYMENT TOPOLOGIES β
β β
β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
β β NODE SQLITE ADAPTER β β CLOUDFLARE DURABLE OBJECTS β β
β β Local developer machine, β β Globally distributed edge, β β
β β Linux VPS daemon, Docker β β zero-maintenance serverless β β
β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
β β BROWSER INDEXEDDB β β JSONL / MEMORY STORE β β
β β Client-side execution, β β Ephemeral testing, unit β β
β β mobile apps, offline web β β benchmarks, CI pipelines β β
β βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Node SQLite (
@earendil-works/pi-durable/storage/sqlite/node):- The default for servers, developer laptops, and VPS daemons.
- Fast, local, and self-contained. SQLite keeps active transcripts in memory while leaving historical archives on disk.
- Cloudflare Durable Objects (
@earendil-works/pi-durable/storage/cloudflare):- Runs agents directly on Cloudflareβs global edge network.
- Provides consistent transactional storage at edge locations with automatic state persistence and zero server maintenance.
- Browser IndexedDB / OPFS:
- Enables agents to run client-side on mobile devices, tablets, or browser extensions without an intermediary server.
- Memory / JSONL:
- Lightweight storage designed for fast unit testing and benchmark evaluations.
6. Production Best Practices & Caveats
When deploying Pi Durable in production environments, take note of the following operational realities:
1. SQLite Concurrency & File Locking
- Limitation: The Node SQLite adapter locks the local
.sqlitefile during transactions. Multiple standalone operating system processes cannot write concurrently to the same database file. - Best Practice: Run a single backend daemon process (such as Durable Piβs backend daemon on port 4780) that owns the storage handle, and have thin clients (web hubs, TUIs, CLI tools) connect via WebSocket or HTTP.
2. Durability Tuning for Sudden Power Loss
- By default, SQLite relies on standard OS write caching. To ensure absolute durability against sudden host power loss or kernel panics, configure WAL mode and full synchronization:
PRAGMA journal_mode = WAL; PRAGMA synchronous = FULL;
3. Tool Author Burden for Replay Safety
- Replay safety is not automatic. Developers must audit every custom tool. If a tool writes to disk, calls external payment APIs, or creates Git commits, it must not be marked
replay: "safe"unless idempotent request keys are implemented.
4. Background Compaction Token Boundaries
- Set
reserveTokensto at least 16,384 tokens to give reasoning models sufficient room for thinking blocks. Trigger compaction (backgroundTokens) around 32,768β65,536 tokens so older turns are summarized well before hitting provider context ceilings.
7. Video Resources, Citations & Further Reading
Official Earendil Releases & Technical Articles
- Earendil Engineering: Pi Durable Announcement & Tour - Complete introductory RFC on the architecture of durable agents.
- Earendil Engineering: Pi 1.0 Release Announcement - Principles of minimalism, malleability, and core agent design.
- Earendil Engineering: What is a Harness? - Detailed exploration of storage, execution machinery, and model interfaces.
- Earendil Engineering: How Compaction Works in Pi - Deep dive into non-destructive background summarization.
- Earendil Engineering: Pi Durable on Cloudflare - Running durable agent harnesses on Cloudflare Durable Objects.
- MindStudio Engineering: Pi Durable: What It Is and Why It Matters for Agent Apps - Architectural analysis of transcript persistence vs run state.
Video Demonstrations & Code Walkthroughs
- Scott Tolinski (Syntax): You need to check out Pi Durable
- Key Topic: Building autonomous self-healing coding agents powered by Sentry webhooks, automatic testing, and pull request generation.
- Nathan Disler: Pi Durable PROACTIVE Agents Video Breakdown
- Key Topic: Transitioning from reactive prompt loops to proactive background workers with multi-device TUI and Web Hub steering.
Open-Source Repositories
- Earendil Works Core Monorepo: github.com/earendil-works/pi - Source code for
@earendil-works/pi-durable,@earendil-works/pi-ai, and@earendil-works/chord. - Nathan Disler's Durable Pi Network: github.com/disler/durable-pi - Distributed agent network template with Web Hub and Terminal TUI.