AI agents increasingly perform agentic exploration: pursuing multiple solution paths in parallel and committing only the successful one. Because each exploration path may modify files and spawn processes, agents require isolated environments with atomic commit and rollback semantics for both filesystem state and process state. We introduce the branch context, a new OS abstraction that provides: (1) copy-on-write state isolation with independent filesystem views and process groups, (2) a structured lifecycle of fork, explore, and commit/abort, (3) first-commit-wins resolution that automatically invalidates sibling branches, and (4) nestable contexts for hierarchical exploration. We realize branch contexts in Linux through two complementary components. First, BranchFS is a FUSE-based filesystem that gives each branch context an isolated copy-on-write workspace, with O(1) creation, atomic commit to the parent, and automatic sibling invalidation, all without root privileges. BranchFS is open sourced in https://github.com/multikernel/branchfs, along with a Python integration library, BranchContext, that provides ready-to-use agent exploration patterns. Second, branch() is a proposed Linux syscall that spawns processes into branch contexts with reliable termination, kernel-enforced sibling isolation, and first-commit-wins coordination. Preliminary evaluation of BranchFS shows sub-350 us branch creation independent of base filesystem size, and modification-proportional commit overhead (under 1 ms for small changes).
翻译:AI智能体日益执行智能体探索:并行追求多个解决方案路径,并仅提交成功的那一个。由于每条探索路径可能修改文件并衍生进程,智能体需要具备原子提交与回滚语义的隔离环境,该语义需同时涵盖文件系统状态与进程状态。我们引入分支上下文(branch context)这一新的操作系统抽象,其提供:(1)具有独立文件系统视图与进程组的写时复制状态隔离,(2)由分支(fork)、探索(explore)及提交/中止(commit/abort)构成的结构化生命周期,(3)首次提交获胜(first-commit-wins)机制,自动失效同级分支,以及(4)支持分层探索的可嵌套上下文。我们通过两个互补组件在Linux中实现分支上下文。首先,BranchFS是一个基于FUSE的文件系统,为每个分支上下文提供独立的写时复制工作空间,支持O(1)创建、向父分支的原子提交、自动同级分支失效,且无需root权限。BranchFS已开源至https://github.com/multikernel/branchfs,并附带一个Python集成库BranchContext,提供即用的智能体探索模式。其次,branch()是一个提议的Linux系统调用,支持在分支上下文中衍生进程,具备可靠终止、内核强制同级隔离以及首次提交获胜协调机制。BranchFS的初步评估显示,分支创建时间低于350微秒,独立于基础文件系统大小,且提交开销与修改量成正比(小修改低于1毫秒)。