Shepherd framework enables AI agents to fork and replay execution states faster than Docker
Researchers from Northeastern University and Stanford University have released Shepherd, an open-source Python runtime substrate designed to address a critical challenge in long-running AI agent systems: the ability to efficiently recover from errors without expensive recomputation.
Traditional approaches to agent error recovery are costly: fixing errors forward increases context size and token consumption, while restarting from scratch requires replaying all previous model and tool interactions. Shepherd solves this by recording agent execution as a Git-like trace of typed events, allowing engineers to fork any past state and resume from there.
The framework records every agent-environment interaction as a typed event, creating a complete execution trace where each interaction functions as a commit. Unlike Git, which tracks only files, Shepherd's commits capture both the agent process and filesystem state through copy-on-write mechanisms. This allows a branch to carry full live state, enabling instant forks to earlier execution points.
Performance is a key advantage: Shepherd forks agent processes and filesystems 5 times faster than Docker containers. More critically, because the prompt prefix up to a branch point remains unchanged, replaying from a fork achieves over 95% prompt cache reuse, dramatically reducing inference costs.
The framework is currently available in early alpha as an MIT-licensed package installable via pip install shepherd-ai. It requires Python 3.11 or later and includes OS-level enforcement on macOS and Linux. The research team also formalized core operations in the Lean proof assistant and provides comprehensive documentation, source code, and experimental data.