AI agent sandbox
Use this pattern when an agent needs Linux tools but generated code should not run directly on the host.
For a stricter model-facing tool API, see Agent tool contract.
Scaffold
Section titled “Scaffold”mvmctl init ./agent-tool --preset pythoncd agent-tool$EDITOR flake.nixmvmctl buildKeep the flake pinned. Add only the packages the tool needs.
Run a tool call
Section titled “Run a tool call”mvmctl up . --name agent-toolmvmctl exec agent-tool -- python /work/tool.pyFor one-off calls:
mvmctl run --timeout 20 -- python -c 'print("bounded tool call")'Security checklist
Section titled “Security checklist”- Validate model tool inputs before invoking
mvmctl. - Start without network access unless the tool needs a named endpoint.
- Keep host mounts narrow and read-only where possible.
- Use secret references rather than plaintext command args.
- Redact stdout/stderr before adding it to model context.
- Stop, destroy, or cold-pause intentionally after the task.