Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

357 Commits

Repository files navigation

agentOS

Give agents an operating system as a library.
92x faster cold starts, 47x less memory, 254x cheaper than sandboxes.
Built-in ACP agents: Pi, Claude Code, Codex, and OpenCode

Documentation | Quickstart | Registry | Discord

Why agentOS

  • Runs inside your process: No microVMs to boot, no containers to pull, no nested virtualization. Warm VM creation takes single-digit milliseconds and each VM costs tens of megabytes.
  • Embeds in your backend: Agents call your functions directly via bindings — ordinary JavaScript calls, not another network service. Credentials stay on the host; agents see only inputs and outputs.
  • Granular security: Permissions gate filesystem, network, process, and environment access, with outward-facing capabilities like network egress denied by default. Guest JavaScript runs in V8 isolates and compiled tools run as WebAssembly, all inside one compact runtime.
  • Deploy anywhere: Just an npm package. Run locally with npx rivetkit dev, then deploy to Rivet Cloud for managed infrastructure or self-host on your own.
  • Open source: Apache 2.0 licensed.

agentOS vs Sandbox

agentOS is a lightweight VM that runs inside your process. Sandboxes are full Linux environments. agentOS integrates agents into your backend with bindings and granular permissions. Sandboxes give you a full OS for browsers, native binaries, and dev servers.

You don't have to choose: agentOS works with sandboxes through sandbox mounting, spinning up a full sandbox on demand and mounting the sandbox's file system when the workload needs it.

See agentOS vs Sandbox for a full comparison.

Quick start

npm install @rivet-dev/agentos @agentos-software/pi

Common POSIX utilities (coreutils, sed, grep, gawk, findutils, diffutils, tar, gzip) ship out of the box. Claude Code, Codex, and OpenCode install the same way as Pi.

Create the server:

// server.tsimport{agentOS,setup}from"@rivet-dev/agentos";importpifrom"@agentos-software/pi";constvm=agentOS({software: [pi],});exportconstregistry=setup({use: { vm }});registry.start();

Create the client — any public frontend or another backend:

// client.tsimport{createClient}from"@rivet-dev/agentos/client";importtype{registry}from"./server";constclient=createClient<typeofregistry>({endpoint: "http://localhost:6420",});consthandle=client.vm.getOrCreate("my-agent");// Subscribe to streaming events. The payload is inferred from the event schema.constconn=handle.connect();conn.on("sessionEvent",(event)=>{console.log(event);});// Open a durable session and send a prompt.awaithandle.openSession({agent: "pi",env: {ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!},});awaithandle.prompt({content: [{type: "text",text: "Write a hello world script to /workspace/hello.js"},],});// Read the file the agent createdconstcontent=awaithandle.readFile("/workspace/hello.js");console.log(newTextDecoder().decode(content));

Run both:

# Terminal 1: start the server
npx tsx server.ts
# Terminal 2: run the client
npx tsx client.ts

agentOS can run Node.js and shell scripts inside the VM:

// Node.jsawaithandle.writeFile("/hello.mjs",'import fs from "fs"; fs.writeFileSync("/out.txt", "hi")');awaithandle.exec("node /hello.mjs");// Bashconstresult=awaithandle.exec("cat /out.txt");console.log(result.stdout);// "hi"

@rivet-dev/agentos runs each VM as a Rivet Actor with built-in persistence, sleep/wake, multiplayer, preview URLs, and orchestration. For direct in-process VM control without the actor runtime, use @rivet-dev/agentos-core standalone: AgentOs.create() boots a VM and returns a handle you call directly.

See the Quickstart guide for the full walkthrough. agentOS is in preview and the API is subject to change — questions and issues welcome on Discord.

Benchmarks

All benchmarks compare agentOS against the fastest/cheapest mainstream sandbox providers as of March 30, 2026. Methodology and reproduction steps: Benchmarks.

Cold start

PercentileagentOSFastest Sandbox (E2B)Speedup
p504.8 ms440 ms92x faster
p955.6 ms950 ms170x faster
p996.1 ms3,150 ms516x faster

agentOS: measured on Intel i7-12700KF. Sandbox baseline: E2B, the fastest mainstream sandbox provider as of March 30, 2026.

Memory per instance

WorkloadagentOSCheapest Sandbox (Daytona)Reduction
Full coding agent (Pi + MCP + filesystem)~131 MB~1,024 MB8x smaller
Simple shell command~22 MB~1,024 MB47x smaller

Sandbox baseline: Daytona minimum instance (1 vCPU + 1 GiB RAM), the cheapest mainstream sandbox provider as of March 30, 2026.

Cost per execution-second (self-hosted)

Full coding agent:

Host tieragentOSCheapest Sandbox (Daytona)Difference
AWS ARM$0.00000058/s$0.000018/s32x cheaper
AWS x86$0.00000072/s$0.000018/s26x cheaper
Hetzner ARM$0.000000066/s$0.000018/s281x cheaper
Hetzner x86$0.00000011/s$0.000018/s171x cheaper

Simple shell command:

Host tieragentOSCheapest Sandbox (Daytona)Difference
AWS ARM$0.000000073/s$0.000018/s254x cheaper
AWS x86$0.000000090/s$0.000018/s205x cheaper
Hetzner ARM$0.000000011/s$0.000018/s1738x cheaper
Hetzner x86$0.000000017/s$0.000018/s1061x cheaper

Sandbox baseline: Daytona at $0.0504/vCPU-h + $0.0162/GiB-h (1 vCPU + 1 GiB minimum). Assumes one agent per sandbox and 70% host utilization.

Features

Agents

Infrastructure

  • Execution: Run Bash, Node.js, Python, and registry software inside the VM with real processes, subprocesses, shells, and in-VM servers
  • Mount external storage as a filesystem: S3-compatible storage, Google Drive, host directories, or in-memory mounts, attached at boot or dynamically at runtime
  • Bindings: Define JavaScript functions that agents call as CLI commands inside the VM
  • Cron and webhooks: Schedule tasks with built-in cron jobs, and trigger agents from external webhooks with your own HTTP server
  • Browser (beta): Give agents a cloud browser via Browserbase
  • Sandbox mounting (beta): Pair with full sandboxes (E2B, Daytona, etc.) for heavy workloads like browsers or native compilation

Orchestration

  • Multiplayer: Multiple clients observe and collaborate with the same agent in real time
  • Agent-to-agent: Agents delegate work to other agents through host-defined bindings
  • Workflows: Chain agent tasks into durable workflows with retries, branching, and resumable execution
  • Authentication: Integrate with your existing auth model (API keys, OAuth, JWTs)

Security

  • Granular permissions: Control filesystem, network, process, and environment access, with outward-facing capabilities denied by default
  • Programmatic network control: Allow or deny any outbound connection with per-host rules, and proxy HTTP into VM services with preview URLs
  • Resource limits: Set precise CPU and memory limits per agent
  • VM isolation: Each agent runs in its own VM with no shared state

Architecture

agentOS runs each agent in a fully virtualized VM. A trusted sidecar process owns every VM's kernel — virtual filesystem, process table, pipes, PTYs, and a virtual network stack — and brokers every guest syscall; nothing the guest does touches the host directly: no real host filesystem, no real host sockets, no real host processes. Guest JavaScript runs on native V8 with its full JIT (JavaScript runtime), and compiled tools run as WebAssembly. Many VMs share one sidecar process, so each additional VM costs a V8 isolate plus kernel state, not an OS process. With @rivet-dev/agentos, each VM is a Rivet Actor with durable state.

See the Architecture docs for details.

Registry

Extend agentOS with agents, filesystems, browsers, and software from one registry. Browse the full catalog at the agentOS Registry.

Common POSIX utilities ship out of the box. The registry adds agents (@agentos-software/pi, @agentos-software/claude-code, @agentos-software/codex, @agentos-software/opencode), command packages (git, ripgrep, jq, sqlite3, duckdb, curl, vim, and more), meta-packages (common, build-essential, everything), and integrations like the Browserbase cloud browser. Install any of them from npm and pass them via software: [...].

License

Apache-2.0

About

Give agents an operating system as a library. Runs in your existing backend – no sandboxes, VMs, or SaaS. Powered by WebAssembly & V8 isolates.

Topics

Resources

Stars

4.4k stars

Watchers

12 watching

Forks

Releases

Used by

Contributors

Languages