H
pending
Shepherd: Stanford and Northeastern's Git-Like Runtime for Rewinding AI Agents Mid-Run
Grounded / Real
Inflated / Uruttu
Original Content
Stanford researchers did it again.
They built the agent-native version of Git.
When an agent works on a longer task, the run builds up a lot of state, like files it edited, a dev server, a database, installed packages, and the KV cache.
Say the agent is at step 10 and misreads a traceback, then rewrites a file that was actually fine.
Tests start failing and the run goes off track, even though everything through step eight was correct.
By default the agent just tries to fix it, which creates more edits and tool calls, burning tokens and growing the context.
The other option is restarting from step one, which pays for every model and tool call again and re-prefills the context. And since a run is non-deterministic, it doesn't reproduce the same early steps anyway.
Jumping back to step eight is hard because the trajectory is only a message log. It records what the agent said and which tools it called, but not the live state underneath.
Git can version the files, but not the running process or the cache. Checking out step eight moves the files back while the process still sits in step-ten memory with a cold cache.
Shepherd is a runtime layer by Stanford that records the run as a trace of typed events instead of a flat log.
Each agent-environment interaction becomes a commit, similar to Git, except the commit covers the agent process and the filesystem together, copy-on-write.
So a branch carries the actual state and not just the files, and going back is a single call that forks from that commit and continues from there.
The fork is roughly five times faster than docker commit, and because the prompt prefix through step eight is unchanged, over 95% of the KV cache is reused on replay.
Once the run can be forked, a meta-agent can sit on top, watch the trace, and revert as soon as it looks wrong, before the bad write is committed.
Not everything is reversible though.
Files and sandbox changes undo themselves, but a database write needs a matching undo step set up in advance, and something external like a sent email or a real charge can't be undone at all.
On CooperBench, where two agents work on the same codebase, adding a live supervisor took the pair-coding pass rate from 28.8% to 54.7%.
The project is still labeled alpha, and the benefit mostly shows up when a run gets branched a lot over a heavy sandbox state.
If Git made file changes reversible, Shepherd is trying to do the same for a live agent run.
They built the agent-native version of Git.
When an agent works on a longer task, the run builds up a lot of state, like files it edited, a dev server, a database, installed packages, and the KV cache.
Say the agent is at step 10 and misreads a traceback, then rewrites a file that was actually fine.
Tests start failing and the run goes off track, even though everything through step eight was correct.
By default the agent just tries to fix it, which creates more edits and tool calls, burning tokens and growing the context.
The other option is restarting from step one, which pays for every model and tool call again and re-prefills the context. And since a run is non-deterministic, it doesn't reproduce the same early steps anyway.
Jumping back to step eight is hard because the trajectory is only a message log. It records what the agent said and which tools it called, but not the live state underneath.
Git can version the files, but not the running process or the cache. Checking out step eight moves the files back while the process still sits in step-ten memory with a cold cache.
Shepherd is a runtime layer by Stanford that records the run as a trace of typed events instead of a flat log.
Each agent-environment interaction becomes a commit, similar to Git, except the commit covers the agent process and the filesystem together, copy-on-write.
So a branch carries the actual state and not just the files, and going back is a single call that forks from that commit and continues from there.
The fork is roughly five times faster than docker commit, and because the prompt prefix through step eight is unchanged, over 95% of the KV cache is reused on replay.
Once the run can be forked, a meta-agent can sit on top, watch the trace, and revert as soon as it looks wrong, before the bad write is committed.
Not everything is reversible though.
Files and sandbox changes undo themselves, but a database write needs a matching undo step set up in advance, and something external like a sent email or a real charge can't be undone at all.
On CooperBench, where two agents work on the same codebase, adding a live supervisor took the pair-coding pass rate from 28.8% to 54.7%.
The project is still labeled alpha, and the benefit mostly shows up when a run gets branched a lot over a heavy sandbox state.
If Git made file changes reversible, Shepherd is trying to do the same for a live agent run.
Validated Content
pip install shepherd-ai).