The immortal life of Pi: Running the Pi coding agent on Temporal.

This post details the integration of the Pi coding agent with Temporal Workflows to provide durable execution and automatic recovery across machine failures. It describes how Temporal Workflows act as the execution engine, with each turn of the agent's interaction (model call + tool calls) mapped to Activities. The session file serves as the conversation state, and Git bundles preserve project snapshots. The post highlights the handling of 'unknown outcomes' for tool calls that may have partially executed before a worker failure, and the mechanism for preventing stale attempts from corrupting the session state using a write guard and lease. The core rules for recovery are: transcript as the sole conversation state, `sealStep` as the sole writer of tool results, pre-invocation claims for tools, a write guard rejecting appends from workers that lost their lease, and configurable token/time budgets.
More from the Sandbox Orchestration Harness trail
- AI safety does not stop at the model
- Temporal Agent Harness: An early look at durable agent infrastructure
- Stop failing on the path to production: A better way for agentic platforms
- Temporal Sandbox Orchestration Harness: The missing layer for running agents
- From agent zoo to agent orchestra: The benefits of Temporal as your enterprise agentic control plane