An Agent Runs Some Bash—So First Pick 4 Cores and 8 GB?
Yifan Xu proposes treating a microVM as a Machine, spinning up multiple Sandboxes inside it, and letting a Workspace hold project files. LayerFS follows this approach to separate storage and compute, and handles concurrent commit conflicts.
An Agent wants to run a few lines of Bash, and the platform first pops up a spec choice: 2 cores and 4 GB, or 4 cores and 8 GB? In his article, Yifan Xu says this order may be backwards. Many sandbox vendors have drawn the Sandbox boundary in the wrong place.
Choosing a spec when buying a server is natural. It is not necessarily natural when an Agent executes code. It may just want to find a file, take a look at a change, or run a few lines of Bash. It does not yet know how much work it will do next, but it has to pick a machine for this execution first.
The common architecture behind this is one Sandbox per microVM. A microVM has its own guest kernel, which is good for isolating mutually untrusted workloads. But one-to-one provisioning ties three decisions together: which code can share a kernel, what isolation a given execution needs, and how much CPU and memory it can use.
Yifan Xu's approach is to treat the microVM as a Machine and create multiple Sandboxes inside it. The Machine provides resources, the Sandbox provides the execution environment, and the Workspace holds project files. The three can have their own lifecycles.
He uses Docker as an analogy. A VM has 4 cores and 4 GB, runs Docker Engine inside, and containers use the same pool of CPU and memory on demand. One container has a 2 GB memory limit but actually uses only a few hundred MB, and the rest of the memory can still go to other containers. When the processes in one container finish, the freed memory can go directly to another container compiling in the same VM. The project directory is mounted into the container as a Workspace; when the container finishes, it is destroyed, and the project files remain in the Workspace. Next time, switch to a different container, mount the same Workspace, and continue working.
LayerFS builds Sandboxes in Lima; Docker is only an analogy. The implementation has four parts. Cgroup v2 organizes processes by Sandbox, Workspace, and individual execution, tracks usage, and cleans up the entire process tree when done. Each Sandbox has no fixed RAM quota and uses the memory of the same Lima VM on demand. Executing processes enter an independent network namespace, connect to the VM network via veth, with connectivity managed by nftables, while the LayerFS daemon that accesses the Store stays on the Machine network. Multiple Sandboxes share a read-only image; each Sandbox has its own OverlayFS writable layer; processes and mounts are isolated through Linux namespaces; the Agent runs as a non-root user. The Workspace is mounted by the LayerFS daemon through FUSE and has its own write layer, so project changes can be committed to the Store. Temporary environments are discarded, but commit history remains.
Allocate VMs by trust boundary, and create Sandboxes based on execution needs. Several Agents for the same user can each open a Sandbox in one Lima VM: one searches files, one runs tests, one compiles. They see their own execution environments while sharing the kernel and resource pool of this VM. When two workloads need independent kernel isolation—such as mutually untrusted tenants—put them on different VMs. 4 cores and 4 GB is still useful; it belongs to the Machine.
A commenter summarized this as storage-compute separation, and Yifan Xu replied yes. Another commenter pointed out that once execution environments are separated, concurrent writes to the Workspace deserve more attention: if two Sandboxes modify the same project at the same time, how are conflicts detected on commit? LayerFS's rule is that two Commits changing the same file will be rejected with Conflict, unless a .lww rule says the latest edit wins. Publishing a stale Branch is another matter; it may skip newer main Layers, so main first needs to be merged into the Branch.

LayerFS × DSH is a plugin for DeepSeek Harness. Agents fork Branches in dsh sessions, test in Sandboxes, merge and publish, and the Work and History tabs show each Agent's Branch. The 1.0.0 measurements given in the repository include: fs-bench 5.20 s versus 8.88 s; 157 snapshots at 100.1 MB versus 1,994.6 MB for Btrfs + zstd. The repository also notes that these are release measurements, not a guarantee for any workload. The Store currently runs only in the Disposable profile, lacks crash or power-loss durability, and is not suitable as the only copy of data.
In the future, an Agent should only need to specify three things: what to do in which Workspace, what permissions are needed, and what state should be kept. To search files, it can use a temporary Sandbox, mount the Workspace read-only, and exit when done. When fixing a bug, it can repeatedly edit code and run tests in the same Sandbox, keeping dependencies and services. When the work is done, it commits project changes to the Store. Next time, on a different Machine and with a new Sandbox, it can continue from this project state. CPU and memory are allocated by the runtime based on load: lightweight executions start and stop on demand, compilation and testing consume resources as needed, and when load increases, add machines or queue. When an independent kernel boundary is needed, the runtime places it on another VM.
The ideal entry point for an Agent running Bash may be a Workspace that is already mounted, rather than a machine with a preselected spec. The LayerFS repository is on GitHub, and the original article is on X.
发布时间: 2026-11-25 04:35