An open-source, faster Devin alternative
TypeScript
docs(agent-sessions): make runtimes multi-provider; add codex
Igor Zalutski996225620d11
diff --git a/docs/agent-sessions/agents.mdx b/docs/agent-sessions/agents.mdxindex 92e930a5..eafa7da0 100644--- a/docs/agent-sessions/agents.mdx+++ b/docs/agent-sessions/agents.mdx@@ -38,7 +38,7 @@ Content-Type: application/json</CodeGroup>-Pass your Anthropic `key` inline and it's stored as a [credential](/agent-sessions/authentication#model-credentials) and attached to the agent — sessions run the model on it. Already have a credential? Reference it with `credential: "cred_…"` instead, or omit both to use your org default. Optionally set default [`limits`](/agent-sessions/sessions#limits) (`tokens`/`turn_seconds`/`turns`) too; sessions inherit them.+Pass your model `key` inline and it's stored as a [credential](/agent-sessions/authentication#model-credentials) and attached to the agent — sessions run the model on it. The provider is taken from `model` (Anthropic for `anthropic/…`, OpenAI for `openai/…`), so the key has to be for that provider. Already have a credential? Reference it with `credential: "cred_…"` instead, or omit both to use your org default for that provider. Optionally set default [`limits`](/agent-sessions/sessions#limits) (`tokens`/`turn_seconds`/`turns`) too; sessions inherit them.<Tip>Keep the org key and model key on your backend. Only return session-scoped client tokens to browsers.</Tip>@@ -48,6 +48,6 @@ When a session is created it **freezes** the agent's `prompt`, `model`, `runtime## Model-`model` is a `provider/model` id (e.g. `anthropic/claude-opus-4-8`); the chosen [runtime](/agent-sessions/runtimes) determines which models are valid. The model runs on [your Anthropic key](/agent-sessions/authentication#model-credentials) (required). Today the only callable runtime is `claude`.+`model` is a `provider/model` id, and its provider must match the [runtime](/agent-sessions/runtimes): `claude` runs `anthropic/…` (e.g. `anthropic/claude-opus-4-8`), `codex` runs `openai/…` (e.g. `openai/gpt-5-codex`). The model runs on [your own key](/agent-sessions/authentication#model-credentials) for that provider (required). A `runtime` / `model` / credential mismatch is rejected when you create or edit the agent, never mid-session.-<Note>Additional model providers, and switching a session's model mid-session, are coming soon.</Note>+<Note>Switching a session's model or runtime mid-session is coming soon; for now, new sessions pick up the agent's current `runtime` and `model`.</Note>diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex 9aea5710..44d846a8 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -53,7 +53,7 @@ const session = await oc.sessions.get("sess_..."); // server, org key</Tabs>-`agent` is **required** (create a saved [agent](#agents) first); a resolvable Anthropic [credential](#credentials) is also required (`422 no_credential` otherwise). `key` gives get-or-create (one session per key); a request-level `Idempotency-Key` header makes a keyless create retry-safe. `input` is the task — a string or a full [envelope](/agent-sessions/messaging#message-envelope). For the managed `claude` runtime, put all task-critical context in the task text. `limits` `{ tokens, turn_seconds, turns }` are **non-monetary** — token budget, per-turn wall-clock, auto-run count; hitting one ends the turn with a matching `last_turn.yield_reason`. Destinations on an idempotent create-replay are ignored — manage them via the [destinations API](#destinations).+`agent` is **required** (create a saved [agent](#agents) first); a resolvable model [credential](#credentials) is also required (`422 no_credential` otherwise). `key` gives get-or-create (one session per key); a request-level `Idempotency-Key` header makes a keyless create retry-safe. `input` is the task — a string or a full [envelope](/agent-sessions/messaging#message-envelope). For the managed runtimes (`claude`, `codex`), put all task-critical context in the task text. `limits` `{ tokens, turn_seconds, turns }` are **non-monetary** — token budget, per-turn wall-clock, auto-run count; hitting one ends the turn with a matching `last_turn.yield_reason`. Destinations on an idempotent create-replay are ignored — manage them via the [destinations API](#destinations).Client tokens accept `scopes?` (subset of `read`, `steer`) and `ttl?` seconds, clamped to 60–86400 (SDK: `ttlSeconds`).@@ -232,7 +232,7 @@ Delivery = {</Tabs>-Create body: `name`, `prompt`, `model`, `runtime?` (`claude`), `key?`, `credential?`, `limits?`. Patch accepts `prompt?`, `model?`, `key?`, `credential?`, and `limits?`.+Create body: `name`, `prompt`, `model`, `runtime?` (`claude` | `codex`), `key?`, `credential?`, `limits?`. Patch accepts `prompt?`, `model?`, `runtime?`, `key?`, `credential?`, and `limits?`. The `runtime` / `model` / credential provider must agree (`claude`↔`anthropic/…`, `codex`↔`openai/…`) — a mismatch is rejected at create or patch.Pass `key` **or** `credential` (or neither → org default). The agent's `limits` are the defaults for its sessions; a session's own `limits` override. Each agent has a monotonic `revision` (bumped on PATCH) that sessions pin in `agent_snapshot.revision`, so you can tell which version produced a run.diff --git a/docs/agent-sessions/authentication.mdx b/docs/agent-sessions/authentication.mdxindex 9aa4f2aa..25417345 100644--- a/docs/agent-sessions/authentication.mdx+++ b/docs/agent-sessions/authentication.mdx@@ -64,7 +64,7 @@ Content-Type: application/jsonBrowser pattern: your backend creates the session with the org key, then hands the `client_token` to the browser, which uses it directly for the SSE stream and steer calls.-<Warning>A client token isn't free to hand out: each `steer` starts a turn, which **consumes tokens on your Anthropic key** for the session it's scoped to. Mint short-lived tokens, and rely on the session's [limits](/agent-sessions/sessions#limits) (`tokens`/`turn_seconds`/`turns`) to cap exposure.</Warning>+<Warning>A client token isn't free to hand out: each `steer` starts a turn, which **consumes tokens on your model key** for the session it's scoped to. Mint short-lived tokens, and rely on the session's [limits](/agent-sessions/sessions#limits) (`tokens`/`turn_seconds`/`turns`) to cap exposure.</Warning>```browser -> your backend: create task@@ -77,9 +77,9 @@ For the SSE stream the browser passes the client token as `?token=` (native `Eve## Model credentials-Sessions run the model on **your own Anthropic key**. It's held in OpenComputer's [secret store](/sandboxes/secrets) — encrypted at rest (AES-256-GCM) and write-only (**never returned** by the API). Crucially, **the real key never enters a sandbox at all**: it's sealed into an opaque token, and a host-side proxy swaps in the real value only on the outbound HTTPS call to `api.anthropic.com` (scoped by an egress allowlist). So it's **never exposed to the model, never in the agent's prompt or code, and never in the VM** — see [Secrets](/sandboxes/secrets). A credential is **required** — a session with no resolvable key fails to start (`422 no_credential`).+Sessions run the model on **your own provider key** — Anthropic for the `claude` [runtime](/agent-sessions/runtimes), OpenAI for `codex`. It's held in OpenComputer's [secret store](/sandboxes/secrets) — encrypted at rest (AES-256-GCM) and write-only (**never returned** by the API). Crucially, **the real key never enters a sandbox at all**: it's sealed into an opaque token, and a host-side proxy swaps in the real value only on the outbound HTTPS call to the model provider (`api.anthropic.com` or `api.openai.com`, scoped by an egress allowlist). So it's **never exposed to the model, never in the agent's prompt or code, and never in the VM** — see [Secrets](/sandboxes/secrets). A credential is **required** — a session with no resolvable key fails to start (`422 no_credential`).-The easiest way to add one is inline when you [create an agent](/agent-sessions/agents) (`"key": "sk-ant-…"`). The standalone resource below is for reusing one key across agents, setting an org default, and rotating/removing keys:+The easiest way to add one is inline when you [create an agent](/agent-sessions/agents) (`"key": "…"`) — the provider is inferred from the agent's `model`. The standalone resource below is for reusing one key across agents, setting an org default, and rotating/removing keys. Set `provider` to `anthropic` or `openai`:<CodeGroup>@@ -119,4 +119,4 @@ Content-Type: application/json**Resolution** per session: the agent's credential → your org default for the provider. (No platform-billed fallback yet — bring a key.)-<Note>Additional model providers, model hot-swap, and platform-billed usage are coming soon — they use this same credential shape, so your setup won't change.</Note>+<Note>Model hot-swap and platform-billed usage are coming soon — they use this same credential shape, so your setup won't change.</Note>diff --git a/docs/agent-sessions/custom-runtimes.mdx b/docs/agent-sessions/custom-runtimes.mdxindex cce227d8..bcfd6b29 100644--- a/docs/agent-sessions/custom-runtimes.mdx+++ b/docs/agent-sessions/custom-runtimes.mdx@@ -4,9 +4,9 @@ title: "Custom runtimes"description: "Package any agent harness as a runtime (coming soon)"----<Note>**Planned.** This page describes planned API shape, not shipped behavior. Today the only callable [runtime](/agent-sessions/runtimes) is `claude`.</Note>+<Note>**Planned.** This page describes planned API shape, not shipped behavior. Today the built-in [runtimes](/agent-sessions/runtimes) are `claude` and `codex`; bringing your own is on the roadmap.</Note>-A custom runtime is a container image for your agent harness. Once registered, select it per agent with `runtime: "<name>"`; sessions, events, steering, and webhooks work the same way.+A custom runtime is a container image for your own agent harness — anything beyond the built-in `claude` and `codex` runtimes. Once registered, select it per agent with `runtime: "<name>"`; sessions, events, steering, and webhooks work the same way.## Runtime invocationdiff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdxindex 251302ef..cda6bef0 100644--- a/docs/agent-sessions/overview.mdx+++ b/docs/agent-sessions/overview.mdx@@ -35,7 +35,7 @@ Give an agent a prompt and a task; OpenComputer runs it on a managed runtime and<Steps><Step title="Define an agent">- Create a reusable `{ name, model, prompt, runtime }` from your backend. Pass your Anthropic `key` inline, or reference a saved [credential](/agent-sessions/authentication#model-credentials). ([Agents](/agent-sessions/agents))+ Create a reusable `{ name, model, prompt, runtime }` from your backend — `runtime: "claude"` (Anthropic models) or `"codex"` (OpenAI models). Pass your model `key` inline, or reference a saved [credential](/agent-sessions/authentication#model-credentials). ([Agents](/agent-sessions/agents))</Step><Step title="Start a session">Start a session with `{ agent, input }`. The agent starts immediately and returns a browser-safe `client_token`.diff --git a/docs/agent-sessions/quickstart.mdx b/docs/agent-sessions/quickstart.mdxindex a2117dca..4cdfaa9b 100644--- a/docs/agent-sessions/quickstart.mdx+++ b/docs/agent-sessions/quickstart.mdx@@ -17,7 +17,7 @@ OPENCOMPUTER_API_KEY=osb_...ANTHROPIC_API_KEY=sk-ant-...```-<Tip>Grab your OpenComputer API key from [app.opencomputer.dev](https://app.opencomputer.dev). Sessions run the model on your Anthropic key.</Tip>+<Tip>Grab your OpenComputer API key from [app.opencomputer.dev](https://app.opencomputer.dev). Sessions run the model on your own provider key — Anthropic for the default `claude` runtime.</Tip>## 1. Create an agent@@ -63,10 +63,12 @@ Response:{ "id": "agt_...", "name": "quickstart-coder", "revision": 1 }```-<Note>Your Anthropic `key` is held in OpenComputer's [secret store](/sandboxes/secrets) (encrypted, write-only) and **never enters the sandbox**. The agent runs with a placeholder; an **egress proxy substitutes the real key in-flight** on the outbound call to Anthropic — so neither the model nor your agent's code ever sees it. Reuse one key across agents via a [credential](/agent-sessions/authentication#model-credentials).</Note>+<Note>Your model `key` is held in OpenComputer's [secret store](/sandboxes/secrets) (encrypted, write-only) and **never enters the sandbox**. The agent runs with a placeholder; an **egress proxy substitutes the real key in-flight** on the outbound call to the model provider — so neither the model nor your agent's code ever sees it. Reuse one key across agents via a [credential](/agent-sessions/authentication#model-credentials).</Note><Tip>`POST /agents` is idempotent by agent name, so it is fine to call this during application startup.</Tip>+<Tip>Prefer OpenAI? Set `runtime: "codex"` and `model: "openai/gpt-5-codex"` with an OpenAI `key` — every other step in this guide is identical. See [Runtimes](/agent-sessions/runtimes).</Tip>+## 2. Start a sessionA session starts work immediately and returns a browser-safe `client_token` for that one session.@@ -189,7 +191,7 @@ Response:## Production checklist-- Keep the org API key and Anthropic key server-side.+- Keep the org API key and your model key server-side.- Add app auth before minting or returning a `client_token`.- Set `limits` on the agent or session.- Use `idempotency_key` for every user action you might retry.@@ -203,7 +205,7 @@ Response:Event shape, levels, cursors, and resume behavior.</Card><Card title="Runtime tools" icon="toolbox" href="/agent-sessions/runtime-tools">- The tools the managed Claude runtime can use.+ The tools a runtime can use in the sandbox.</Card><Card title="Example app" icon="github" href="https://github.com/diggerhq/oc-sessions-demos">Fork a complete app-builder implementation.diff --git a/docs/agent-sessions/runtime-tools.mdx b/docs/agent-sessions/runtime-tools.mdxindex d14548c5..0e425965 100644--- a/docs/agent-sessions/runtime-tools.mdx+++ b/docs/agent-sessions/runtime-tools.mdx@@ -1,10 +1,10 @@---mode: "wide"-title: "Claude runtime tools"-description: "The tools the claude runtime can use — what to rely on when you write prompts"+title: "Runtime tools"+description: "The tools a runtime can use — what to rely on when you write prompts"----When you write a prompt for the `claude` [runtime](/agent-sessions/runtimes), it's useful to know exactly what the agent can do. Every side effect runs through a fixed set of tools against the session's **sandbox** — the agent has no direct filesystem, shell, or network of its own. The built-in local tools are disabled; only these remote tools are available.+When you write a prompt for a [runtime](/agent-sessions/runtimes) (`claude` or `codex`), it's useful to know exactly what the agent can do. Both runtimes act through the same fixed set of tools against the session's **sandbox** — the agent has no direct filesystem, shell, or network of its own. The runtime's built-in local tools are disabled; only these remote tools are available.## Sandbox toolsdiff --git a/docs/agent-sessions/runtimes.mdx b/docs/agent-sessions/runtimes.mdxindex 58c8e076..612b0758 100644--- a/docs/agent-sessions/runtimes.mdx+++ b/docs/agent-sessions/runtimes.mdx@@ -1,14 +1,21 @@---mode: "wide"title: "Runtimes"-description: "The engine that runs your agent — claude today, more soon"+description: "The engine that runs your agent — claude or codex, picked per agent"----A **runtime** is the engine that executes the agent loop. You pick one per agent via `runtime`; it defaults to `claude`. The runtime **image** is stateless and interchangeable; the **running instance** keeps its session state on the sandbox, and OpenComputer manages and recovers it for you (see [Supervision and recovery](#supervision-and-recovery)).+A **runtime** is the engine that executes the agent loop. You pick one per agent with `runtime`; it defaults to `claude`. The runtime image is stateless and interchangeable, and the model it runs is separate configuration — so an agent is just a runtime, a `provider/model`, and a matching [credential](/agent-sessions/authentication#model-credentials).-## `claude` — available today+| Runtime | Models | Credential |+| --- | --- | --- |+| `claude` | `anthropic/…` (e.g. `anthropic/claude-opus-4-8`) | Anthropic key |+| `codex` | `openai/…` (e.g. `openai/gpt-5-codex`) | OpenAI key |-The managed Claude agent loop. It works in a sandbox through remote tools, streams its steps into the session as events, and runs Claude models on your [Anthropic key](/agent-sessions/authentication#model-credentials).+Sessions, [events](/agent-sessions/events), [steering](/agent-sessions/messaging), [tools](/agent-sessions/runtime-tools), and [webhooks](/agent-sessions/webhooks) work the same way whatever runtime you pick — switching is a one-line `runtime` change.++## `claude`++The managed Claude agent loop (Claude Agent SDK / Claude Code). It works in a sandbox through remote tools, streams its steps into the session as events, and runs Claude models on your [Anthropic key](/agent-sessions/authentication#model-credentials).```httpPOST https://api.opencomputer.dev/v3/agents@@ -20,25 +27,57 @@ Content-Type: application/json"runtime": "claude","model": "anthropic/claude-opus-4-8","prompt": "Review code in the sandbox. Run tests. Explain risks.",- "credential": "cred_..."+ "key": "sk-ant-..."+}+```++## `codex`++The managed Codex agent loop (OpenAI Codex SDK). It runs OpenAI models on your [OpenAI key](/agent-sessions/authentication#model-credentials), and drives the same sandbox tools and event stream as `claude` — only the engine and the provider change.++```http+POST https://api.opencomputer.dev/v3/agents+Authorization: Bearer $OPENCOMPUTER_API_KEY+Content-Type: application/json++{+ "name": "reviewer",+ "runtime": "codex",+ "model": "openai/gpt-5-codex",+ "prompt": "Review code in the sandbox. Run tests. Explain risks.",+ "key": "sk-..."}```+The runtime, model, and credential have to agree: `runtime: "codex"` needs an `openai/…` model and an OpenAI key, and `runtime: "claude"` needs an `anthropic/…` model and an Anthropic key. A mismatch is rejected when you create the agent, with a clear error — so a session never starts on a broken pairing. See [model credentials](/agent-sessions/authentication#model-credentials).++## How runtimes work++The model is configuration, not part of the runtime image. Each runtime drives one provider — `claude` drives Anthropic, `codex` drives OpenAI — and you choose the exact `provider/model` and the key it runs on. Because the model is config, the rest of your integration is identical across runtimes; the runtime is the one thing that changes.++A runtime also **starts fast**: the engine is prepared ahead of time and baked into the image, so a new or recreated session doesn't wait on a per-session download before its first step.+### Brain and hands sandboxesThe runtime runs the agent loop in its **own per-session sandbox** (the *brain*). The agent's file and shell tools don't run there — they run in a **separate sandbox** (the *hands*) that the brain drives through remote tools, so the model has no local disk or network of its own: the sandbox is the only surface it can act through. The brain carries the [sealed model key](/agent-sessions/authentication#model-credentials) (egress-allowlisted to the model API, swapped in by a host proxy so the key never enters the VM); the hands sandbox holds no secrets at all.-Each **turn is one bounded run**, invoke-style — it:+### Each turn is one bounded run++A turn is one bounded, invoke-style run — it:1. reads the new input from the [event log](/agent-sessions/events) at the cursor,-2. drives the Claude Agent SDK loop,+2. drives the runtime's agent loop,3. **streams every step back as events** over the authenticated events API,4. performs side effects only through the remote [sandbox tools](/agent-sessions/runtime-tools) (`bash` / `read` / `write` / `ls`, plus `say` / `ask`), and5. **exits when it has nothing left to do** — it yields rather than busy-waits, so time spent waiting costs no compute.Across turns it continues an on-box **journal**; the durable record is the event log *plus* that journal, which the platform checkpoints at each boundary and restores on recovery (see [Failure behavior](#failure-behavior)).-### Recovery+### Pinned per session++When a session starts it pins the runtime and version it began on (alongside the rest of the [agent snapshot](/agent-sessions/agents#session-pinned-config)). Changing the agent's `runtime` afterwards never affects a running or resumed session — new sessions pick up the change; in-flight ones keep what they started with.++## Supervision and recoverySessions are fully managed — you never restart anything yourself:@@ -64,9 +103,9 @@ What's guaranteed today, and what isn't:Work since the last journaled step may repeat, so **make side effects idempotent** and treat the event log (and delivered webhooks) as the durable record. Uncommitted hands-sandbox files are not restored after sandbox loss — commit or push to keep them. Byte-exact **mid-turn** resume is coming in a later release.-## Planned runtimes+## What's coming-<Note>The runtimes below are not yet callable. When one is available, you select it by setting `runtime` to its name — nothing else changes.</Note>+More engines are on the way, each picked the same one-line way — your setup won't change:-- **`codex`, `opencode`** — prebuilt, multi-provider runtimes.-- **Custom (bring your own image)** — package any agent harness as a runtime. See [Custom runtimes](/agent-sessions/custom-runtimes) for the planned API shape.+- **More prebuilt runtimes and providers** — additional managed engines, selected by setting `runtime` to its name.+- **Custom runtimes** — package any agent harness as a runtime image and run it on the same sessions, events, and recovery as the built-ins. See [Custom runtimes](/agent-sessions/custom-runtimes) in Labs for the shape this takes.diff --git a/docs/agent-sessions/sessions.mdx b/docs/agent-sessions/sessions.mdxindex a0ccedc6..5148c5db 100644--- a/docs/agent-sessions/sessions.mdx+++ b/docs/agent-sessions/sessions.mdx@@ -8,7 +8,7 @@ A **session** is the durable unit of an [agent](/agent-sessions/agents) at work:## Session flow-1. You create a session from an [agent](/agent-sessions/agents) (and an [Anthropic credential](/agent-sessions/authentication#model-credentials) — both required). The session starts immediately.+1. You create a session from an [agent](/agent-sessions/agents) (and a [model credential](/agent-sessions/authentication#model-credentials) — both required). The session starts immediately.2. The [runtime](/agent-sessions/runtimes) executes the agent in a sandbox, appending [events](/agent-sessions/events) to the log as it works.3. With nothing left to do, the session goes **idle** and the sandbox **hibernates**.4. A [steer](/agent-sessions/messaging) message wakes it; it resumes with its prior context. Repeat.