Stanford Researchers Release Shepherd: Git-Like Reversible Execution for AI Agents

Shepherd records every agent step as a commit, enabling instant rollback to any point with 95% computation reuse and automatic meta-agent supervision.

cpaua3 min263

Stanford researchers have open-sourced Shepherd, a runtime substrate that gives AI agents Git-like reversible execution traces. When an agent makes an error, Shepherd rolls back to the last correct step instead of restarting the entire task, reusing up to 95% of prior computations through KV-cache retention. A meta-agent monitors execution and triggers rollbacks automatically without human intervention. The project is available under the MIT license at shepherd-agents/shepherdgithub.com/shepherd-agents/shepherd.

How the reversible trace works

Shepherd records each execution step as a durable commit that captures the workspace files and the state of running processes. The system uses a copy-on-write fork mechanism that the team measures at roughly five times the speed of docker commit. Because the key-value cache from earlier steps is preserved, replaying from a rolled-back point avoids recomputing the majority of work — the repository cites ~95% KV-cache reuse on replay.

Developers can inspect, fork, replay, or revert any run with a single call. The trace remains intact whether a proposed change is accepted, merged onto a workspace that has since moved forward, or discarded.

Meta-agent supervision

A meta-agent sits above the working agent and watches for errors. When it detects a failure, it initiates an immediate rollback to the last known-good commit and resumes execution from there. This supervision loop runs without human input, turning error recovery into an automated part of the agent lifecycle rather than a manual debugging session.

Permission model enforced at the syscall level

Shepherd expresses permissions in the task function signature. A parameter annotated as repo: sp.GitRepo grants read-write access to a repository; May[GitRepo, ReadOnly] restricts the agent to read-only. These grants are compiled into writable roots for the run and enforced by the operating system sandbox — macOS Seatbelt or Linux Landlock inside a privileged container. A write to a read-only path or an ungranted directory is refused at the syscall before it can mutate state. Windows is not supported; the documentation recommends WSL.

Installation and requirements

Shepherd requires Python 3.11 or newer. Install the package from PyPI:

shellscript
pip install shepherd-ai

A quickstart demonstrates the workflow: initialize a workspace, run a demo task that writes a program into a retained output, inspect the changeset, and then select, apply, or discard the proposal. The same machinery works offline with a deterministic provider for keyless testing.

Research backing and reproducibility

The design is described in the paper "Shepherd: Enabling Programmable Meta-Agents via Reversible Agentic Execution Traces" (arXiv:2605.10913). Full experiment code, including meta-agent applications and framework microbenchmarks, lives in the companion repository shepherd-agents/shepherd-experiments, which pins the exact substrate snapshot used for the published numbers.

Related reading

Sources

shepherd-agents/shepherdgithub.com/shepherd-agents/shepherd
Share

Author

cpaua

VibeCode blog admin. Writing about vibe coding, AI and open source.

Related news

Comments

To leave a comment, log in
Loading...

Weekly digest

The best of vibe coding, AI agents and open source — once a week, no spam.