
My Code Fixes Itself Now
AI Summary
The speaker introduces "PI durable," a library enabling robust, self-healing software agents. These agents can fix software, run in a browser or on an Android phone, and initiate tasks autonomously, even on a cheap photo frame.
Current agent usage often involves constant human supervision, restarting processes after stalls or crashes. However, agents are now running longer, performing complex tasks like submitting pull requests, researching, or accessing bank accounts. They increasingly start autonomously via triggers or webhooks. If such an agent crashes during a critical, non-repeatable action (e.g., sending an email or pull request), it needs to be "durable" – resumable, knowing its exact last step to avoid redoing actions.
Building agents typically involves repetitive code for message storage, work queues, UI streaming, user steering, conversation forking, approval waits, retries, and state synchronization. Debugging failures in such custom setups is time-consuming and brittle. The speaker previously built a custom agent that was a "pain," but switching to PI durable allowed them to delete 8,000 lines of custom code and achieve a superior system.
PI durable is a library from the Arendelle team, also behind "Pi," an extensible agent harness used by OpenClaw and many developers. PI durable specifically helps build durable agents like coding agents, support bots, or Slackbots. It works by saving all agent activity—what was said, tool calls, waiting states—into persistent storage. If the process dies, a new one can open the file and resume exactly where it left off. Any connected client (phone, browser, Slack) sees the same agent state.
Crucially, tools within PI durable specify if they are "safe to run again" after a crash. A search, for instance, might be rerun for fresh data, but sending an email should not be repeated. PI durable essentially uses a database file to store conversation history, tool calls, pending approvals, and deployment status. This comprehensive state allows agents to pick up work precisely where they stopped, or even finish tasks while the user is away.
Unlike rigid workflow engines, PI durable allows the agent to decide its next steps and available tool calls, leveraging the agent's intelligence. This design offers several benefits:
1. **Any client is a terminal:** Phones, terminals, or computers can interact with a durable agent, steer it, and continue work on the same process with full history.
2. **Multiplayer functionality:** Multiple users can access and collaborate on an agent, even steering it simultaneously.
3. **Dynamic modification:** Agents can be changed while running, simplifying steering and the creation of forking or sub-agents.
4. **Persistent state:** Waiting for approvals, timers, or other states are consistent for all users.
PI durable runs anywhere JavaScript runs. It can operate entirely in a browser using IndexedDB (as demonstrated by Armen), on a Mac Mini with Node.js and SQLite (the speaker's setup), or in durable objects like Cloudflare's or Deno's "celld." It's model-agnostic, supporting OpenAI, local models, or others, preventing vendor lock-in.
The speaker demonstrates a self-healing software setup using PI durable:
1. A software bug triggers a Sentry error.
2. A webhook from Sentry, via a Cloudflare tunnel, activates the agent.
3. The agent analyzes the bug, determines if it's fixable, and begins root cause analysis using Sentry's Seer agent.
4. The user can observe, stop, and resume the agent at any point.
5. After root cause analysis, the agent works on a fix, tests it, and creates a pull request (PR).
6. The PR is visible on GitHub, detailing changes and checks.
7. The user can review and merge the PR.
8. The agent then marks the issue as resolved in Sentry and the internal system, creating an audit trail.
9. The user can message the agent directly within the context of that specific run, asking questions or providing feedback on the fix without starting a new conversation.
This is just one example; the speaker's entire system, including documents, chats, and to-dos, runs on PI durable agents. The setup is more robust and less buggy than custom solutions. Durable agents are gaining traction, with Open Code 2 supporting library-based server or durable object deployment, and Cloudflare's agent SDK integrating PI durable. Even Deno's celld (now a Cloudflare acquisition) allows running durable objects locally. Mario, PI's creator, built a multiplayer agent app on PI durable that runs directly on his Android phone, with only model calls going to the network.
The speaker strongly advises making agents durable. While custom solutions are possible, PI durable offers these capabilities "for free." The project's example folder provides verifiable examples for reload/restart, tool overrides, compaction, and child tasks. The speaker offers a prompt for existing agent systems to integrate PI durable and encourages investigation for anyone building agents. He also hints at further explorations with durable agents in document editors, Creative Labs, and the Syntax team Slackbot.