Shepherd:一个为元智能体提供形式化执行追踪的运行时基板
Shepherd提出了一种函数式编程模型,将元智能体对目标智能体的操作形式化为函数,其核心操作在Lean中实现。该系统将所有智能体-环境交互记录为类似Git的类型化执行追踪,支持对任意历史状态进行分支与重放。其分支智能体进程及文件系统的速度比Docker快5倍,重放时提示缓存复用率超过95%。应用案例表明,其实时监督可将结对编程通过率从28.8%提升至54.7%;反事实元优化在四个基准测试中最高超出基线11个百分点,同时减少高达58%的挂钟时间;在Tree-RL训练中,于选定轮次进行分支展开将性能从34.2%提高至39.4%。该系统已开源。
We introduce Shepherd, a functional programming model that formalizes meta-agent operations on target agents as functions, with core operations mechanized in Lean. Shepherd records every agent-environment interaction as a typed event in a Git-like execution trace, enabling any past state to be forked and replayed. The system forks the agent process and its filesystem 5times faster than Docker, achieving >95% prompt-cache reuse on replay. We demonstrate the model through three applications. First, in runtime intervention, a live supervisor increases pair coding pass rates from 28.8% to 54.7% on CooperBench. Second, in counterfactual meta-optimization, branching exploration outperforms baselines across four benchmarks by up to 11 points while reducing wall-clock time by up to 58%. Third, in Tree-RL training, forking rollouts at selected turns improves TerminalBench-2 performance from 34.2% to 39.4%. These results establish Shepherd as an efficient infrastructure for programming meta-agents. We open-source the system to support future research.