An open-source, faster Devin alternative
TypeScript
docs(agent-sessions): BYO-key required, no monetary surface, key sugar, secrecy, future-proofing
Igor Zalutskie44d2b415bb7
diff --git a/docs/agent-sessions/agents.mdx b/docs/agent-sessions/agents.mdxindex fff01ed9..1335d358 100644--- a/docs/agent-sessions/agents.mdx+++ b/docs/agent-sessions/agents.mdx@@ -3,16 +3,16 @@ title: "Agents"description: "The reusable definition of what runs"----An **agent** is a first-class, reusable definition of *what* runs — a `name`, a `prompt` (its instructions), a `model`, and a [`runtime`](/agent-sessions/runtimes). Create one and start many [sessions](/agent-sessions/sessions) from it.+An **agent** is a first-class, reusable definition of *what* runs — a `name`, a `prompt` (its instructions), a `model`, and a [`runtime`](/agent-sessions/runtimes). Every [session](/agent-sessions/sessions) runs on an agent, so create one first, then start as many sessions on it as you like.```bashcurl https://api.opencomputer.dev/v3/agents \-H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \-d '{ "name": "reviewer", "model": "anthropic/claude-opus-4-8",- "prompt": "You review code.", "runtime": "claude" }'+ "prompt": "You review code.", "runtime": "claude", "key": "sk-ant-…" }'```-For a one-off, skip the agent and inline `prompt`, `model`, and `runtime` when you [start a session](/agent-sessions/sessions) — same result, no named record.+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.## Pinned snapshot@@ -20,6 +20,6 @@ When a session is created it **freezes** the agent's `prompt`, `model`, and `run## 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. Usage is billed to your OpenComputer account, or to [your own provider key](/agent-sessions/authentication#model-credentials-byo-key). Today the only callable runtime is `claude`.+`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`.<Note>Additional model providers, and switching a session's model mid-session, are coming soon.</Note>diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex 4e2b4b16..8c5f1a19 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -9,7 +9,7 @@ Base URL `https://api.opencomputer.dev/v3`. Management calls authenticate with y| Method · Path | Purpose || --- | --- |-| `POST /sessions` | Start a session. Body: `agent?`, `prompt?`, `model?`, `runtime?`, `input`, `key?`, `webhook?`, `destinations?[]`, `max_usd?`, `max_turn_seconds?`, `max_turns?`. Returns `{ session, client_token }`. |+| `POST /sessions` | Start a session. Body: `agent` (required), `input`, `key?`, `webhook?`, `destinations?[]`, `limits?: { tokens?, turn_seconds?, turns? }`. Returns `{ session, client_token }`. || `GET /sessions/:id` | Fetch a session. || `GET /sessions?status=&agent=&key=&after=&before=&limit=` | List sessions (filtered, paginated). || `POST /sessions/:id/archive` | Cancel any active turn, then close (read-only). |@@ -18,14 +18,14 @@ Base URL `https://api.opencomputer.dev/v3`. Management calls authenticate with y| `GET /sessions/:id/turns` · `GET …/turns/:turnId` | Per-turn history: timing, usage, error. || `POST /sessions/:id/client-tokens` | Mint a client token. Body: `scopes?`, `ttl?`. |-Provide `agent` (a saved agent id) **or** inline `prompt` + `model` + `runtime`. `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#the-envelope) (structured context rides `input.refs`: `repo`/`branch`/`commit`/`issue`/…). The bounds `max_usd` / `max_turn_seconds` / `max_turns` cap spend, per-turn wall-clock, and auto-runs; hitting one ends the turn with a matching `last_turn.yield_reason`.+`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#the-envelope) (structured context rides `input.refs`: `repo`/`branch`/`commit`/`issue`/…). `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).```-Session = { id, status, head, cursor,- agent_snapshot: { prompt_hash, model, runtime },- last_turn: { state, yield_reason?, turn_id, started_at, completed_at?, result_event_id?, error?, budget_exceeded? },- usage: { active_seconds, usd, cap_usd?, tokens? },- limits: { max_usd?, max_turn_seconds?, max_turns? }, key?, created_at }+Session = { id, status, head, input_cursor,+ agent_snapshot: { prompt_hash, model, runtime, revision },+ last_turn: { state, yield_reason?, turn_id, started_at, completed_at?, result_event_id?, error? },+ usage: { active_seconds, tokens? },+ limits: { tokens?, turn_seconds?, turns? }, key?, created_at }````yield_reason` (`completed | needs_input | error | budget_exceeded | deadline_exceeded | max_turns | canceled`) is the machine-readable "why the turn ended" — `needs_input` means the agent asked a question; answer it by [steering](#steer).@@ -34,16 +34,16 @@ Session = { id, status, head, cursor,| Method · Path | Purpose || --- | --- |-| `GET /sessions/:id/events?after=<seq>&level=<lvl>&kind=&type=&turn_id=&limit=<n>` | Read events since a cursor (filter by `kind`, `body.type`, or `turn_id`). |+| `GET /sessions/:id/events?after=<seq>&level=<lvl>&type=&turn_id=&limit=<n>` | Read events since a cursor (filter by `type` exact or `prefix.*`, or `turn_id`). || `GET /sessions/:id/events?after=<seq>&level=<lvl>&stream=sse` | Live SSE stream from a cursor. || `GET /sessions/:id/events/:eventId` | Fetch one event (resolve `result_event_id`). |-| `GET /sessions/:id/events/:eventId/content` | Fetch a blob-backed body (large outputs/artifacts). |-| `GET /sessions/:id/messages?after=<seq>&limit=<n>` | User-message history (alias for `level=user` + `kind=message`). |+| `GET /sessions/:id/events/:eventId/content` | Fetch a blob-backed body (large outputs). |+| `GET /sessions/:id/messages?after=<seq>&limit=<n>` | User-message history (alias for `level=user` + `type=*.message`). |-`after` resumes from a `seq`; `level` is a **visibility threshold** — `user` returns only user-facing events, `progress` adds work updates, `internal` adds everything (see [levels](/agent-sessions/events#levels)). Switch on [`body.type`](/agent-sessions/events#event-shape), don't parse prose.+`after` resumes from a `seq`; `level` is a **visibility threshold** — `user` returns only user-facing events, `progress` adds work updates, `internal` adds everything (see [levels](/agent-sessions/events#levels)). Switch on [`type`](/agent-sessions/events#event-shape), don't parse prose.```-Event = { id, seq, ts, session, actor, kind, level, body, refs, operation_key? }+Event = { id, seq, ts, session, actor, type, level, body, refs }```## Steer@@ -56,9 +56,9 @@ Event = { id, seq, ts, session, actor, kind, level, body, refs, operation_key? }| Method · Path | Purpose || --- | --- |-| `POST /sessions/:id/destinations` | Register a webhook. Body: `url`, `secret?`, `level?` (`user`), `kinds?[]`, `include_raw?` (`false`), `enabled?` (`true`). |+| `POST /sessions/:id/destinations` | Register a webhook. Body: `url`, `secret?`, `level?` (`user`), `types?[]` (event-type filter; exact or `prefix.*`), `include_raw?` (`false`), `enabled?` (`true`). || `GET /sessions/:id/destinations` · `GET …/:did` | List / fetch. |-| `PATCH /sessions/:id/destinations/:did` | Pause/resume (`enabled`), retune `level`/`kinds`, rotate `secret`. |+| `PATCH /sessions/:id/destinations/:did` | Pause/resume (`enabled`), retune `level`/`types`, rotate `secret`. || `DELETE /sessions/:id/destinations/:did` | Remove. |## Deliveries@@ -72,7 +72,7 @@ Event = { id, seq, ts, session, actor, kind, level, body, refs, operation_key? }See [Webhooks](/agent-sessions/webhooks#delivery-contract) for the signing and delivery contract.```-Destination = { id, url, level, kinds, include_raw, enabled, created_at }+Destination = { id, url, level, types, include_raw, enabled, created_at }Delivery = { id, destination_id, event_id, status, attempts, last_attempt_at, response_code?, error? }```@@ -80,15 +80,17 @@ Delivery = { id, destination_id, event_id, status, attempts, last_attempt_at,| Method · Path | Purpose || --- | --- |-| `POST /agents` | Create a reusable agent. Body: `name`, `prompt`, `model`, `runtime?` (`claude`). Idempotent by `(owner, name)`. |+| `POST /agents` | Create a reusable agent. Body: `name`, `prompt`, `model`, `runtime?` (`claude`), `key?` (Anthropic key — creates + attaches a [credential](#credentials)), `credential?` (reference an existing one), `limits?: { tokens?, turn_seconds?, turns? }`. Idempotent by `(owner, name)`. || `GET /agents/:id` · `GET /agents` | Fetch / list. |-| `PATCH /agents/:id` | Update `prompt?` / `model?`. Never affects existing sessions (snapshots are pinned). |+| `PATCH /agents/:id` | Update `prompt?` / `model?` / `key?` (rotate) / `credential?` / `limits?`. Never affects existing sessions (snapshots are pinned). |++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.## Credentials| Method · Path | Purpose || --- | --- |-| `POST /credentials` | Add a provider key. Body: `provider`, `key`, `name?`. Key is write-only. |+| `POST /credentials` | Add a provider key (Anthropic). Body: `provider`, `key`, `name?`. Key is write-only. **Required** — sessions run on your key (no platform billing yet). || `GET /credentials` · `DELETE /credentials/:id` | List / remove. || `PUT /credentials/default` | Set the org default for a provider. Body: `provider`, `credential`. |diff --git a/docs/agent-sessions/authentication.mdx b/docs/agent-sessions/authentication.mdxindex ed7b6703..1806783b 100644--- a/docs/agent-sessions/authentication.mdx+++ b/docs/agent-sessions/authentication.mdx@@ -30,7 +30,7 @@ curl https://api.opencomputer.dev/v3/sessions/$ID/client-tokens \The 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 can **spend**: each `steer` starts a turn, which incurs model cost on the session it's scoped to. Mint short-lived tokens, and rely on the session's [bounds](/agent-sessions/sessions#bounds) (`max_usd`/`max_turn_seconds`/`max_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 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>```browser ──(create task)──▶ your backend ──(org key)──▶ POST /v3/sessions@@ -40,9 +40,11 @@ browser ──(client_token)──▶ GET …/events (SSE) · POST …/messagesFor the SSE stream the browser passes the client token as `?token=` (native `EventSource` can't set an `Authorization` header); other calls use the `Authorization` header normally.-## Model credentials (BYO key)+## Model credentials-Model usage is **billed to your OpenComputer account** by default — zero setup, metered, capped per session. To run on **your own** provider key instead, add a **credential**. It's stored in our secret store (encrypted, write-only, never returned) — you never manage a raw secret store yourself.+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`).++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:```bashcurl https://api.opencomputer.dev/v3/credentials \@@ -56,6 +58,6 @@ curl -X PUT https://api.opencomputer.dev/v3/credentials/default \-d '{ "provider": "anthropic", "credential": "cred_…" }'```-**Resolution** per session: the agent's credential → your org default for the model's provider → platform billing.+**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 and model hot-swap are coming soon — they use this same credential shape, so your setup won't change.</Note>+<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>diff --git a/docs/agent-sessions/events.mdx b/docs/agent-sessions/events.mdxindex 79ee06c5..fb91d51f 100644--- a/docs/agent-sessions/events.mdx+++ b/docs/agent-sessions/events.mdx@@ -8,13 +8,13 @@ Every step a session takes is an **event**, appended to the log in order. The lo```json{ "id": "evt_…", "seq": 12, "ts": "…", "session": "sess_…","actor": { "id": "agent", "type": "agent" },- "kind": "message", "level": "user",- "body": { "type": "agent.message", "text": "3 tests fail in auth.spec.ts", "final": true },+ "type": "agent.message", "level": "user",+ "body": { "text": "3 tests fail in auth.spec.ts" },"refs": {} }```- **`id`** — the event's own unique id (`evt_…`). The client idempotency key for steering is separate (deduped per session — see [steering](/agent-sessions/messaging)).-- **`kind`** — `message` (content), `status` (lifecycle), or `error`.+- **`type`** — the one discriminator: a namespaced string (`agent.message`, `turn.completed`, …). See below.- **`actor`** — who produced it: `{ id, display?, type: "human" | "agent" | "system" }`.- **`level`** — visibility; see below.- **`body` / `refs`** — payload and related ids.@@ -23,21 +23,23 @@ Inbound and outbound messages share one [envelope](/agent-sessions/messaging#the## Event shape-The three `kind`s stay small; the **stable contract is `body.type`** — switch on it, **don't parse prose.** Unknown types render fine from their `text`/`summary`, so new ones are additive.+The stable contract is the top-level **`type`** — **switch on it, don't parse prose.** Unknown types render fine from their `text`/`summary`, so new ones are additive. (There's no separate `kind`; coarse buckets are just `type` prefixes like `turn.*` or `agent.*`.)-| `kind` · `body.type` | `body` shape | Use it for |+| `type` | `body` shape | Use it for || --- | --- | --- |-| `message` · `agent.message` | `{ text, final? }` | agent output; the result is the `final` one (= `last_turn.result_event_id`) |-| `message` · `user.message` | `{ text }` | a steer you sent |-| `status` · `turn.started` | `{ turn_id }` | a turn began |-| `status` · `turn.completed` | `{ turn_id, yield_reason, result_event_id? }` | **the "done" signal — await this** |-| `status` · `tool.call` | `{ tool, args_summary }` | the agent invoked a tool |-| `status` · `exec.completed` | `{ command, exit_code, summary, content_ref?, bytes? }` | a finished command |-| `error` · `error.*` | `{ code, message, retriable? }` | a failure |+| `agent.message` | `{ text }` | agent output (the result is whichever one `turn.completed` points to) |+| `user.message` | `{ text }` | a steer you sent |+| `turn.started` | `{ turn_id, input_from_seq, input_to_seq }` | a turn began, consuming input events in `[from,to]` |+| `turn.completed` | `{ turn_id, yield_reason, result_event_id? }` | **the "done" signal — await this** |+| `tool.call` | `{ tool, args_summary }` | the agent invoked a tool |+| `exec.completed` | `{ command, exit_code, summary, content_ref?, bytes? }` | a finished command |+| `error.runtime` · `error.model` · `error.task` | `{ code, message, retriable? }` | a failure |-**Coming soon** (already shaped, additive): `test.results`, `diff`/`patch`, `artifact`, `pr.result`, `preview.url`.+**Coming soon** (already shaped, additive): `test.results`, `diff`/`patch`, `pr.result`, `preview.url`, `action.required` (agent needs an approval / tool result).-**Artifacts & large output.** Any event may carry `refs.artifacts[]` = `[{ name, content_ref | url, content_type, bytes }]`, and a large `body` is offloaded to a `content_ref`. Fetch the bytes with `GET /sessions/:id/events/:eventId/content` — that's how you render diffs, command logs, generated files, screenshots, and reports.+**Correlate a steer to its turn.** Steers coalesce — one turn can pick up several — so [`POST /messages`](/agent-sessions/messaging) returns the *event* `seq`, not a turn. The turn that consumes your steer emits `turn.started` with `input_from_seq ≤ your_seq ≤ input_to_seq`; await its `turn.completed`, then `GET …/events?turn_id=` for everything it produced.++**Large output.** A large `body` is offloaded to a `content_ref`; fetch the bytes with `GET /sessions/:id/events/:eventId/content` (e.g. full `exec.completed` output). Richer **artifacts** (named files, diffs, screenshots, reports) ride a forward `refs.artifacts[]`, with a first-class artifacts API **coming soon**. `refs` also carries optional correlation/evidence keys (`trace_id`, `sources[]`).## Levels@@ -57,10 +59,10 @@ Filtering is **cumulative** — `user` is the narrowest, `internal` is everythinSo a customer-facing chat asks for `user`; an agent-activity view asks for `progress`; debugging your agent asks for `internal`.-## seq, cursor, head+## seq, head, input_cursor-- **`seq`** — a monotonic id assigned to each event; the cursor space.+- **`seq`** — a monotonic id assigned to each event.- **`head`** — the highest `seq` in the session.-- **`cursor`** — how far a reader (or the runtime) has consumed.+- **`input_cursor`** — how far the *runtime* has consumed (a session field). As a **reader** you don't track this — you just pass `after=<seq>`.Read or stream with `after=<seq>` and you get everything since that point. This is how **resume** works: reconnect with the last `seq` you saw — you miss nothing and get no duplicates. In the browser, native `EventSource` does this automatically — each event's `seq` is the SSE `id`, so it resumes via `Last-Event-ID` on reconnect (see the [quickstart](/agent-sessions/quickstart)).diff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdxindex feb7336c..60f41dc7 100644--- a/docs/agent-sessions/overview.mdx+++ b/docs/agent-sessions/overview.mdx@@ -6,11 +6,11 @@ description: "Define an agent, then run resumable, steerable sessions"Give an agent a prompt and a task; OpenComputer runs it on a managed runtime in a sandbox and records **every step as a durable, streamable, resumable session**. Watch it work live, drop your connection and reconnect right where you left off, let it idle and the sandbox hibernates (≈ free), then steer it with a message or get notified by webhook.<Steps>- <Step title="Define an agent">- A reusable `{ name, model, prompt, runtime }` — `POST /v3/agents`. ([Agents](/agent-sessions/agents))+ <Step title="Define an agent (with your key)">+ A reusable `{ name, model, prompt, runtime }` — `POST /v3/agents`. Pass your Anthropic `key` inline (sessions run on your own key); it's stored as a [credential](/agent-sessions/authentication#model-credentials). ([Agents](/agent-sessions/agents))</Step><Step title="Start a session">- `POST /v3/sessions { agent, input }` and the agent starts working immediately; you get back the session and a browser-safe `client_token`. *(Or inline `{ prompt, model, runtime, input }` for a one-off, without a reusable agent.)*+ `POST /v3/sessions { agent, input }` and the agent starts working immediately; you get back the session and a browser-safe `client_token`.</Step><Step title="Watch, steer, get notified">Stream `GET …/events?stream=sse` — reconnect from any cursor to [resume](/agent-sessions/events). `POST …/messages` to [steer](/agent-sessions/messaging), and register a [webhook](/agent-sessions/webhooks) to have output pushed to you.diff --git a/docs/agent-sessions/quickstart.mdx b/docs/agent-sessions/quickstart.mdxindex e057f05a..7edc0594 100644--- a/docs/agent-sessions/quickstart.mdx+++ b/docs/agent-sessions/quickstart.mdx@@ -11,42 +11,55 @@ export OPENCOMPUTER_API_KEY=your-api-key<Tip>Grab your API key from [app.opencomputer.dev](https://app.opencomputer.dev).</Tip>-## 1. Start a session+## 1. Create an agent (with your Anthropic key)-One call starts a session. Pass a `model`, a `prompt` (the instructions), and `input` (the task) — plus an optional `webhook` to receive every event from the start.+An [agent](/agent-sessions/agents) is the reusable "what" — a name, a prompt, and a model. Sessions run the model on **your** Anthropic key, so pass it inline with `key`. It's held in OpenComputer's [secret store](/sandboxes/secrets) (encrypted, write-only); the **real key never enters the sandbox** — it's sealed, and a host proxy reveals it only on the outbound call to Anthropic, so it's never exposed to the model or the agent's code.++```bash+curl https://api.opencomputer.dev/v3/agents \+ -H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \+ -d '{ "name": "coder", "prompt": "You are a coding assistant.",+ "model": "anthropic/claude-opus-4-8", "key": "sk-ant-…" }'+# → { "id": "agt_…", "name": "coder", … }+```++<Tip>Reusing one key across agents? Add it once via [`POST /credentials`](/agent-sessions/authentication#model-credentials), set it as your default, and skip `key` here.</Tip>++## 2. Start a session++Start a session on the agent with a task. Add an optional `webhook` to receive every event from the start.```bashcurl https://api.opencomputer.dev/v3/sessions \-H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \- -d '{ "model": "anthropic/claude-opus-4-8", "runtime": "claude",- "prompt": "You are a coding assistant.",+ -d '{ "agent": "agt_…","input": "Write a Python script that prints the first 20 primes, run it, and report the output.","webhook": "https://your.app/oc-webhook" }'``````jsonc{- "session": { "id": "sess_abc", "status": "queued", "head": 0, "cursor": 0 },+ "session": { "id": "sess_abc", "status": "queued", "head": 0, "input_cursor": 0 },"client_token": "ct_…" // session-scoped; safe to hand to a browser (read + steer)}```-<Note>Defining the agent inline like this is sugar for one-off sessions. To reuse an agent across sessions, [create one](/agent-sessions/agents) and start sessions with `{ "agent": "agt_…", "input": … }`.</Note>+<Note>Reuse the agent across as many sessions as you like. To bound a run, pass `limits: { tokens?, turn_seconds?, turns? }` on the agent or the session.</Note>-## 2. Stream it live+## 3. Stream it live-Open an `EventSource` with the `client_token` from step 1. It rides the query string — browsers can't set headers on `EventSource`, so the scoped client token goes in the URL (never your API key). `level=user` shows only what an end user should see (see [levels](/agent-sessions/events#levels)).+Open an `EventSource` with the `client_token` from the create call. It rides the query string — browsers can't set headers on `EventSource`, so the scoped client token goes in the URL (never your API key). `level=user` shows only what an end user should see (see [levels](/agent-sessions/events#levels)).```jsconst es = new EventSource(`https://api.opencomputer.dev/v3/sessions/${id}/events?stream=sse&level=user&token=${clientToken}`);-es.onmessage = (e) => render(JSON.parse(e.data)); // each event: { seq, actor, kind, level, body, … }+es.onmessage = (e) => render(JSON.parse(e.data)); // each event: { seq, actor, type, level, body, … }```**Resume is automatic.** Each event carries its `seq` as the SSE event `id`, so on a dropped connection `EventSource` reconnects and resends `Last-Event-ID` — you pick up exactly where you left off, no bookkeeping. (Pass `after=<seq>` on the URL to start from a specific point.)-## 3. Steer it+## 4. Steer itSend a follow-up at any time. The session wakes and continues with its prior context.@@ -56,7 +69,7 @@ curl https://api.opencomputer.dev/v3/sessions/$ID/messages \-d '{ "text": "also check the CI config", "idempotency_key": "nudge-1" }'```-## 4. Manage destinations (optional)+## 5. Manage destinations (optional)You already passed a `webhook` at create. Add or manage more destinations later — each receives events from when it's created (earlier events aren't backfilled yet).diff --git a/docs/agent-sessions/runtime-tools.mdx b/docs/agent-sessions/runtime-tools.mdxindex 1ab60536..1e1ace84 100644--- a/docs/agent-sessions/runtime-tools.mdx+++ b/docs/agent-sessions/runtime-tools.mdx@@ -13,9 +13,11 @@ When you write a prompt for the `claude` [runtime](/agent-sessions/runtimes), it| `read` | Read a file from the sandbox. || `write` | Write a file to the sandbox. || `ls` | List a directory in the sandbox. |-| `use_repo` | Clone/check out a repository into the workspace to work on it. |+| `use_repo` | Check out a **public** git repository into the workspace. (Private-repo access — connections, repo catalog, scoped tokens — is coming soon; for launch, point it at a public URL or `git clone` via `bash`.) |-These map to events you can stream: a `bash` run surfaces as a `status` · `exec.completed` event (`{ command, exit_code, summary }`), with large output available via [`content_ref`](/agent-sessions/events#event-shape).+These map to events you can stream: a `bash` run surfaces as an [`exec.completed`](/agent-sessions/events#event-shape) event (`{ command, exit_code, summary }`), with large output available via `content_ref`.++<Note>**Network:** the sandbox has **open outbound internet** by default (so `git clone`, package installs, and API calls just work), with private, loopback, link-local, and cloud-metadata addresses blocked. Per-agent egress allowlists are coming.</Note>## Talking to the user@@ -33,6 +35,6 @@ These map to events you can stream: a `bash` run surfaces as a `status` · `exec## Writing good prompts- Tell the agent to do all work in the sandbox via `bash`/`read`/`write` — it can't touch your machine.-- To work on a repo, point it at one (`use_repo`, or `bash` + `git clone` for a public repo); pass the target in [`input.refs`](/agent-sessions/messaging) (`repo`, `branch`, `commit`) rather than burying it in prose.+- To work on a repo, point it at a **public** one (`use_repo`, or `bash` + `git clone`); pass the target in [`input.refs`](/agent-sessions/messaging) (`repo`, `branch`, `commit`) rather than burying it in prose. (Private-repo connections are coming soon.)- Have it `say` a clear final result — that's what `GET /sessions/:id/result` returns.- Have it `ask` only when it genuinely needs a decision; otherwise it should proceed.diff --git a/docs/agent-sessions/runtimes.mdx b/docs/agent-sessions/runtimes.mdxindex d175882f..a1b7204a 100644--- a/docs/agent-sessions/runtimes.mdx+++ b/docs/agent-sessions/runtimes.mdx@@ -7,7 +7,7 @@ A **runtime** is the stateless engine that executes the agent loop. You pick one## `claude` — available today-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 — billed to your OpenComputer account, or on your [own key](/agent-sessions/authentication#model-credentials-byo-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).```bashcurl https://api.opencomputer.dev/v3/agents \diff --git a/docs/agent-sessions/sessions.mdx b/docs/agent-sessions/sessions.mdxindex 5f452561..de53c821 100644--- a/docs/agent-sessions/sessions.mdx+++ b/docs/agent-sessions/sessions.mdx@@ -7,7 +7,7 @@ A **session** is the durable unit of an [agent](/agent-sessions/agents) at work:## How a session works-1. You create a session from an agent (or an inline prompt + model). The session starts immediately.+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.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** (see [durability](/agent-sessions/durability)).4. A [steer](/agent-sessions/messaging) message wakes it; it resumes with its prior context. Repeat.@@ -20,29 +20,34 @@ A **session** is the durable unit of an [agent](/agent-sessions/agents) at work:| --- | --- || `queued` | Scheduled; a turn hasn't started running yet. || `running` | A turn is executing. |-| `idle` | Quiescent and steerable; the sandbox is hibernated. |+| `awaiting_input` | A turn ended asking you a question — steerable; reply to continue. |+| `idle` | Done for now; quiescent and steerable; the sandbox is hibernated. || `failed` | The session errored out. || `archived` | Closed; read-only. |-A session also carries `last_turn = { state, yield_reason?, turn_id, started_at, completed_at?, result_event_id?, error?, budget_exceeded? }` and `usage` (`active_seconds`, `usd`). The **`yield_reason`** tells you *why* the last turn ended — `completed`, `needs_input` (the agent asked a question; answer by [steering](/agent-sessions/messaging)), `budget_exceeded` / `deadline_exceeded` / `max_turns` (a [bound](#bounds) tripped), or `canceled`.+A session also carries `last_turn = { state, yield_reason?, turn_id, started_at, completed_at?, result_event_id?, error? }` and `usage` (`active_seconds`, `tokens` — observed only). The **`yield_reason`** tells you *why* the last turn ended — `completed`, `needs_input` (the agent asked a question — the session is now `awaiting_input`; answer by [steering](/agent-sessions/messaging)), `budget_exceeded` / `deadline_exceeded` / `max_turns` (a [limit](#limits) tripped), or `canceled`.## Get the result-Don't sniff prose for "is it done." Await the **`status` · `turn.completed`** event (on the [stream](/agent-sessions/events) or a [webhook](/agent-sessions/webhooks)), then fetch the answer:+Don't sniff prose for "is it done." Await the **`turn.completed`** event (on the [stream](/agent-sessions/events) or a [webhook](/agent-sessions/webhooks)), then fetch the answer:```bashcurl https://api.opencomputer.dev/v3/sessions/$ID/result \-H "Authorization: Bearer $OPENCOMPUTER_API_KEY"# → { "last_turn": { "state": "ok", "yield_reason": "completed", "result_event_id": "evt_…" },-# "result": { "kind": "message", "body": { "type": "agent.message", "text": "…", "final": true } } }+# "result": { "type": "agent.message", "level": "user", "body": { "text": "…" } } }```-## Bounds+## Limits-Cap a session at create (or default it on the [agent](/agent-sessions/agents)): `max_usd`, `max_turn_seconds` (per-turn wall-clock), `max_turns`. Hitting one ends the turn with the matching `yield_reason`.+Cap a session at create (or default it on the [agent](/agent-sessions/agents)) with `limits: { tokens, turn_seconds, turns }` — a token budget, per-turn wall-clock, and auto-run count. These are **non-monetary** (no dollar caps — we don't bill model usage yet; you run on your own key). Hitting one ends the turn with the matching `yield_reason`. (`usage` is observed-only.)## Stop a session-`POST /sessions/:id/cancel` cooperatively stops the active turn and stops billing; `POST /sessions/:id/archive` cancels any active turn, then closes the session read-only.+`POST /sessions/:id/cancel` **requests** a cooperative stop: the turn ends at its next checkpoint, so an in-flight model call may run to its timeout — billing for that turn stops when it actually exits, not the instant you call. `POST /sessions/:id/archive` cancels any active turn, then closes the session read-only.-<Note>Blocking on input mid-turn (formal `ask` / awaiting-input) is coming soon. Today the agent signals it needs input via `yield_reason: "needs_input"`, and you reply by [steering](/agent-sessions/messaging) — fire-and-continue.</Note>+**`archive` is not delete** — the session's log is retained, just read-only. Hard delete (`DELETE /sessions/:id`) and export are coming soon.++<Note>Blocking on input *mid-turn* (the formal `ask` loop) is coming soon. Today the agent signals it needs input by ending the turn with `yield_reason: "needs_input"` (status `awaiting_input`); you reply by [steering](/agent-sessions/messaging).</Note>++<Note>**No cross-session memory (yet).** Each session starts fresh from the agent's prompt + that session's `input` — a durable log is *session history*, not memory the agent carries between sessions. A dedicated memory surface is on the roadmap.</Note>diff --git a/docs/agent-sessions/webhooks.mdx b/docs/agent-sessions/webhooks.mdxindex cd2acd61..83b095e4 100644--- a/docs/agent-sessions/webhooks.mdx+++ b/docs/agent-sessions/webhooks.mdx@@ -13,17 +13,16 @@ curl https://api.opencomputer.dev/v3/sessions/$ID/destinations \-d '{ "url": "https://your.app/oc-webhook","secret": "whsec_…","level": "user",- "kinds": ["message"],"include_raw": false }'```-`level` is the visibility threshold (`user` default, or `progress`); `kinds` is an optional allow-list (default: all); `include_raw: false` strips `raw` from the delivered envelope.+`level` is the visibility threshold (`user` default, or `progress`); `types` is an optional event-type allow-list (default: all — which **includes the terminal `turn.completed`**); `include_raw: false` strips `raw` from the delivered envelope. To get only completions, set `types: ["turn.completed"]`.| Method · Path | Purpose || --- | --- || `POST /sessions/:id/destinations` | Register a destination. || `GET /sessions/:id/destinations` · `GET …/:did` | List / fetch. |-| `PATCH /sessions/:id/destinations/:did` | Pause or resume (`enabled`), retune `level`/`kinds`, or rotate `secret`. |+| `PATCH /sessions/:id/destinations/:did` | Pause or resume (`enabled`), retune `level`/`types`, or rotate `secret`. || `DELETE /sessions/:id/destinations/:did` | Remove. |A destination receives events appended **after** it's created. To capture a whole session, pass `webhook` in `POST /v3/sessions` so it's registered before the agent produces output. (Replaying earlier events with `backfill_from_seq` is coming soon.)