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. 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).
翻译:人工智能智能体越来越多地执行智能体探索:并行探索多个解决路径,并仅提交成功的路径。由于每条探索路径都可能修改文件并生成进程,智能体需要具备文件系统状态和进程状态原子提交与回滚语义的隔离环境。我们引入了分支上下文这一新的操作系统抽象,它提供:(1) 具有独立文件系统视图和进程组的写时复制状态隔离,(2) 包含分支、探索、提交/中止的结构化生命周期,(3) 自动使兄弟分支失效的先提交者胜出解决机制,以及(4) 支持分层探索的可嵌套上下文。我们在Linux中通过两个互补组件实现了分支上下文。首先,BranchFS是一个基于FUSE的文件系统,它为每个分支上下文提供一个隔离的写时复制工作空间,具备O(1)创建时间、向父分支的原子提交以及自动兄弟分支失效功能,且无需root权限。BranchFS已在https://github.com/multikernel/branchfs开源。其次,branch()是一个拟议的Linux系统调用,可将进程生成到分支上下文中,并提供可靠的终止、内核强制的兄弟分支隔离以及先提交者胜出的协调机制。对BranchFS的初步评估显示,分支创建时间低于350微秒且与基础文件系统大小无关,提交开销与修改量成正比(对于小修改低于1毫秒)。