Rivet agentOSBeta

In-process VMs from Rivet agentOS (embedded mode). No credentials, no Docker daemon, no cloud account. Streaming exec with stdin and signals, a PTY, a stateful code interpreter for Python, JavaScript and TypeScript, and filesystem snapshots, via @rivet-dev/agentos-core.

Use the agentOS adapter when you want a sandbox without any infrastructure. AgentOs.create() boots a VM inside your Node process in about a second: a WebAssembly + V8 userland on a lightweight kernel. It is not a real Linux kernel, so it suits shell scripts, Node and Python code, and agent tool calls rather than arbitrary native binaries.

Installation

@rivet-dev/agentos-core is an optional peer dependency of sbox-sdk, imported lazily the first time you create a sandbox.

pnpm add sbox-sdk @rivet-dev/agentos-core
RequirementValue
agentOS0.4.x (@rivet-dev/agentos-core)
Node>= 22
PlatformmacOS or Linux (glibc), x64 or arm64. Windows isn't supported.

Rivet ships native sidecar binaries only for those platforms. In agentOS 0.4.x the embedded runtime lives in @rivet-dev/agentos-core; @rivet-dev/agentos 0.4.x is only the client for hosted actors. agentOS 0.5 is expected to rename the embedded package to @rivet-dev/agentos.

No credentials are needed.

Usage

import { createSandboxClient } from "sbox-sdk";
import { agentos } from "sbox-sdk/agentos";

const client = createSandboxClient({ provider: agentos() });

const sandbox = await client.create({
  env: { NODE_ENV: "development" },
  network: { mode: "allow-all" }, // the default blocks most outbound traffic
});

const res = await sandbox.commands.run("echo $HOME && node -v", {
  cwd: "/tmp",
});
console.log(res.stdout, res.exitCode);

const ctx = await sandbox.code!.createContext({ language: "python" });
await sandbox.code!.runCode("x = 41", { context: ctx });
const out = await sandbox.code!.runCode("print(x + 1)", { context: ctx });

const snap = await sandbox.snapshots!.create({ name: "after-setup" });
const copy = await client.create({ fromSnapshot: snap });

await client.dispose(); // disposes every VM this provider created

Guest environment

ItemValue
Useragentos (uid 1000), HOME=/home/agentos
cwd/workspace by default; /tmp is writable
Toolsbash 5.2, sh, coreutils, grep, sed, awk, find, tar, gzip, base64, node, npm, npx, python/python3
Not heregit (add software: [{ registry: "git" }]), curl, wget, apt; arbitrary native binaries can't run

Options

Prop

Type

OptionDescription
softwareExtra agentOS software: registry names like { registry: "git" }, local .aospkg paths, or descriptors.
defaultSoftwareInstall the default set (sh/bash, coreutils and standard CLI tools). Defaults to true.
mountsagentOS mount configs, for example hostDirMount(...) or nodeModulesMount(...) from @rivet-dev/agentos-core.
limitsagentOS runtime limits.
permissionsBase agentOS permission tree. spec.network replaces its network scope.
vmAny other AgentOs.create() option, for example sidecar, database or rootFilesystem.
snapshotMaxBytesSize cap for one filesystem snapshot. Defaults to 256 MiB.

Commands

Commands run as sh -c in the VM. cwd and env are passed natively per command, exit codes are real, stdout and stderr stream separately, and stdin and signals work. timeoutMs is enforced by the adapter: it kills the process and rejects with Timeout.

env and env-mode secrets (inline values) from the spec are applied to every command, spawn and terminal.

Code interpreter

sandbox.code.runCode() supports python, javascript and typescript through agentOS language runtimes. code.createContext() returns a persistent agentOS execution context, so globals survive between calls. JavaScript contexts run as CommonJS, so top-level var and function bindings persist.

PTY

sandbox.pty.create() opens an agentOS terminal (vm.terminal) running bash by default. The guest has no termios: stty reports that terminal control is unsupported. resize() is forwarded, but programs may not see the new size.

Network

With no network in the spec, agentOS's default applies: all outbound traffic is blocked except agentOS's own service allowlist (model-provider endpoints). Pass network: { mode: "allow-all" } to open it.

spec.network is honored at creation and mapped onto agentOS permission rules:

PolicyagentOS permissions
allow-allallow; deny.domains become deny rules
block-alldeny
allow-listdefault deny, plus dns://<domain> and tcp://<domain>:* allow rules
CIDRsrejected with Validation
injectrejected with Validation

Wildcards such as *.github.com match subdomains, not the apex. Loopback and listening stay allowed. The egressControl capability is still unsupported, because agentOS 0.4 can't change a running VM's permissions, so sandbox.network.setEgressPolicy() isn't available.

Ports

There are no previews. Servers in the guest listen on VM-local ports that are never bound on the host, and agentOS has no public URLs. Reach them through the escape hatch. agentOS routes host requests only to a listener in a process it spawned directly, so start the server with raw().process.spawn() rather than commands.spawn() (which runs it as a child of sh -c):

const vm = sandbox.raw();
const server = await vm.process.spawn("node", [
  "-e",
  "require('http').createServer((q, s) => s.end('hi')).listen(3000)",
]);
const res = await vm.fetch(3000, new Request("http://vm/"));
// or: await vm.network.httpRequest({ port: 3000, path: "/" });
await vm.process.kill(server.pid);

Other processes in the guest can reach any listener over loopback (http://127.0.0.1:3000).

Snapshots and forks

snapshots.create() exports the VM's filesystem (vm.filesystem.export()) and holds it in memory in the provider instance. create({ fromSnapshot }) boots a new VM with the snapshot as its root lower layer. There is no in-place restore and no memory snapshot. fork({ count }) is emulated as one snapshot plus count boots.

Lifecycle

VMs live only as long as your Node process and the provider instance. list(), connect() and getOrCreate() see only VMs created by this provider instance, which is why list is emulated. There is no pause, stop or TTL. client.dispose() disposes every VM the provider created.

Capabilities

CapabilityLevelNotes
background / streaming / killProcessnativesh -c in the VM; signals delivered natively
stdinnative
ptynativeagentOS terminals; no termios
filesUploadnative
codeInterpreter / statefulKernelnativepython, javascript, typescript; persistent contexts
snapshotnativefilesystem only, held in memory by the provider
forkemulatedsnapshot + N boots
listemulatedVMs from this provider instance only
filesWatchunsupportedagentOS has no inotify
exposePort / privatePreview / proxiedFetchunsupporteduse sandbox.raw().fetch(port, request)
egressControlunsupportedpolicy is fixed at creation via spec.network
sshunsupported
volumes / templateBuildunsupporteduse the mounts and software options
stop / pause / setTimeoutunsupportedVMs end with the process or destroy()
gpu / region / secretsVault / metricsunsupported

Flags: exitCodeNative: true, perCommandEnvCwd: true, preservesDiskOnStop: false, preservesMemoryOnPause: false, previewModel: "none", idempotency: "exact".

Create contract

  • Idempotency is exact. VMs live in the provider instance's own registry, and a create is recorded under its idempotency key as soon as it starts. A retry with the same key gets the same VM, even when it races the first attempt or the create was named. A failed AgentOs.create() disposes its VM before rejecting, so a retry never leaves one behind. Keys don't outlive the provider instance, and neither do VMs.
  • Only disk is mapped. resources.diskMB is approximate: it becomes the runtime's maxFilesystemBytes cap, not a provisioned disk. agentOS has no VM sizes, so vcpus, memoryMB, shmMB and gpu/gpuCount are rejected. Tune runtime caps (cpuCount, WASM memory, V8 heap) with the limits option instead.
  • No TTL or idle policy. lifecycle.idleTimeoutMs and lifecycle.maxAgeMs (and the deprecated ttlMs) are rejected. VMs end with destroy(), client.dispose() or the process.
  • Limits. maxPorts is 0: guest servers stay VM-local, so any spec.ports throws Validation. Metadata is held in memory with no cap.
  • Sizes. None are declared. spec.size expands through the default ladder, which sets vcpus and memoryMB, so every preset throws Validation. Use resources.diskMB alone.

No field is ignored, so strictSpec changes nothing here.

How the spec maps

sboxagentOS
fromSnapshotsnapshot as the root lower layer
env, env-mode secretsenv on every command, spawn and terminal
networkpermission rules (see Network)
resources.diskMBlimits.resources.maxFilesystemBytes
template / templateRef, volumes, region, ports, lifecycle / TTL, other resources, gpurejected with Validation
exec user, egress secrets / injectrejected with Validation

Live tests

The live conformance run needs no environment variables. It runs when Node >= 22 is used on a supported platform:

SBOX_LIVE=agentos pnpm --filter sbox-sdk test:live

Known limitations

  • Not a real Linux kernel. Arbitrary native binaries can't run, and there is no package manager.
  • No ports or previews. See Ports.
  • Egress can't change after creation. Set network in the spec.
  • No in-place snapshot restore. Boot a new VM with fromSnapshot. Snapshots live in the provider instance's memory.
  • VMs don't outlive the process. No pause, stop, TTL or reconnecting from another process.
  • No file watching, GPUs, SSH or metrics.
  • Hosted-actor mode isn't covered yet. createAgentOsClient() from @rivet-dev/agentos is a planned follow-up.

On this page