Agents that mostly sit idle waste money on always-on machines. This shows mapping one agent session to one Durable Object so it hibernates when idle and wakes on requests or alarms, with state kept in SQLite.
Key takeaways · AI-distilled
Earendil's sample maps one Pi Durable SessionOne conversation or piece of work as a harness keeps it: a record of messages, tool calls and observations that can be saved and resumed.Full definition → to one Cloudflare Durable Object addressed by session ID, using its SQLite-backed storage for session data, hibernation while idle, and its alarm to wake for pending work.
To avoid duplicate conversations after a dropped WebSocket, the HarnessThe software that sends a model its context, recognizes tool calls, runs or refuses them, returns results and keeps the record.Full definition → stores a receipt with the request ID in the same commit that creates the conversation, and clients resend unconfirmed messages under the same request ID so nothing runs twice.
Pi can track any number of deadlines but a Durable Object has one alarm, so each wake rebuilds the alarm from Pi's tasks, taking the earliest deadline plus a short recovery alarm for in-progress work; the handler is idempotent because alarms run at least once.
A search_history tool delegates RetrievalSelecting evidence relevant to the current request.Full definition → to a multi-agentUsing several AI agents on one problem — splitting work in parallel, checking each other, or filling different roles like planner and reviewer.Full definition → conversation owned by the tool task; the parent receives only the final answer, and the subagent cannot search its own or earlier search conversations, so generated results do not become evidence.
The search tool is marked replay-safe: if the Durable Object is evicted mid-call, Pi reruns it on the next start, and the task finds the child conversation it already created instead of reporting an interruption.
Terms in this piece · Glossary
Session — One conversation or piece of work as a harness keeps it: a record of messages, tool calls and observations that can be saved and resumed.
multi-agent — Using several AI agents on one problem — splitting work in parallel, checking each other, or filling different roles like planner and reviewer.
Harness — The software that sends a model its context, recognizes tool calls, runs or refuses them, returns results and keeps the record.
Retrieval — Selecting evidence relevant to the current request.