An open-source, faster Devin alternative
TypeScript
docs: bring Background Agents section alongside Durable Agent Sessions (cross-check)
Igor Zalutskicf080b82c0df
diff --git a/docs/background-agents/agents.mdx b/docs/background-agents/agents.mdxnew file mode 100644index 00000000..c653a5b9--- /dev/null+++ b/docs/background-agents/agents.mdx@@ -0,0 +1,103 @@+---+title: "Agents"+description: "From a single prompt to a versioned agent defined as code"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++An agent is configuration, not compute: what it knows (prompt, skills), what+drives it (runtime, model), what wakes it (triggers), what it may do+(policies), and a connection scoping which repos it acts on. Sessions+reference an agent; the agent itself never runs.++An agent is **not bound to a repo or a workspace**. Its connection defines the+*candidate set* of repos it may act on; each session+[resolves](/background-agents/workspaces#resolution-and-sharing) which one(s) to+work in at runtime — from the trigger, the conversation, an optional `repo`+default on the agent, or by asking. This is why one agent can serve issues in+several repos, or hold a chat where it picks the repo from what you ask.++## Start as a prompt++```bash+oc agent create fixer \+ --model anthropic/claude-opus-4-8 \+ --prompt "You fix bugs labeled 'agent' in acme/web." \+ --trigger github:issue.labeled:agent+```++```bash+curl -X POST https://api.opencomputer.dev/v2/agents \+ -H "Authorization: Bearer $OC_API_KEY" \+ -d '{+ "name": "fixer",+ "runtime": { "image": "claude", "model": "anthropic/claude-opus-4-8" },+ "prompt": "You fix bugs labeled agent in acme/web.",+ "triggers": [{ "type": "github", "on": "issue.labeled:agent" }]+ }'+```++## Grow into a repo++When one prompt isn't enough, the agent becomes a directory:++```+my-agent/+ opencomputer.toml # name, runtime, model, triggers, policies, connection+ prompt.md+ skills/+ testing.md # conventions the agent loads when relevant+ deploys.md+ mcp.json # MCP servers the agent may use+```++```bash+oc agent deploy+```++Keep it in git, review changes as PRs, deploy from CI. The directory and the+API are two views of the same object; GitHub is not required.++```toml+# opencomputer.toml+name = "fixer"++[runtime]+image = "claude"+model = "anthropic/claude-opus-4-8"++[[triggers]]+type = "github"+on = "issue.labeled:agent"++[policies]+budget.per_session_usd = 5+```++## Versions++Every change — config update, deploy, model switch — is a new immutable+version:++```bash+oc agent versions fixer+oc agent diff fixer v3 v4+oc agent rollback fixer v3+```++Sessions pin the version they started with; updates apply to new sessions+only.++## Policies++- **Deliveries** — draft PRs only by default; protected branches are never+ pushed; target repos can be restricted.+- **Actors** — who can trigger work and wake sessions; your organization's+ members by default.+- **Budget** — per-session and per-month caps.+- **Models** — restrict allowed providers.+- **Network** — sandbox egress is allowlist-based.++Organization policies are ceilings: an agent can be stricter, not looser.+Policies live in the versioned config, so every change is a visible diff.diff --git a/docs/background-agents/api.mdx b/docs/background-agents/api.mdxnew file mode 100644index 00000000..0ac9621e--- /dev/null+++ b/docs/background-agents/api.mdx@@ -0,0 +1,145 @@+---+title: "API Reference"+description: "The Background Agents REST surface"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+endpoints below are still rolling out.</Note>++Base URL `https://api.opencomputer.dev`; authenticate with+`Authorization: Bearer $OC_API_KEY`. The CLI is a wrapper over these calls.++## Agents++```http+POST /v2/agents # create — can be as little as {name, connection, runtime, prompt}+GET /v2/agents # list+GET /v2/agents/:id+PATCH /v2/agents/:id # any config change creates a new version+GET /v2/agents/:id/versions+POST /v2/agents/:id/versions # deploy a bundle (what `oc agent deploy` calls)+```++```json+{+ "name": "fixer",+ "connection": "github:acme",+ "runtime": { "image": "claude", "model": "anthropic/claude-opus-4-8" },+ "prompt": "You fix bugs labeled 'agent' in acme/web.",+ "triggers": [+ { "type": "github", "on": "issue.labeled:agent",+ "route": { "key": "issue.{number}", "mode": "reuse" } }+ ],+ "policies": { "budget": { "per_session_usd": 5 } }+}+```++## Workspaces++Keyed by the repo(s) they prepare, not by agent — a session+[resolves](/background-agents/workspaces#resolution-and-sharing) which repo(s)+to work in (from the trigger, the conversation, a default, or by asking) and+matches a workspace covering that repo and ref.++```http+POST /v2/workspaces # { name, recipe: {repos: [{repo, ref?}], setup[], warm[]}, refresh, pool }+GET /v2/workspaces?repo=&ref= # list / resolve by repo and ref+GET /v2/workspaces/:id # recipe, pool status, latest build+GET /v2/workspaces/:id/builds # immutable lineage+POST /v2/workspaces/:id/builds # build now+```++## Sessions++```http+POST /v2/sessions # { agent, input?, key? } — start explicitly+GET /v2/sessions?agent=&status= # list / filter+GET /v2/sessions/:id # status, pins, sandbox info, usage+PATCH /v2/sessions/:id # { model_override } — this session only, audited+GET /v2/sessions/:id/events # ?after=<cursor>&stream=sse&level=user+POST /v2/sessions/:id/events # raw append (low-level): [{ kind: "message", body: "..." }]+POST /v2/sessions/:id/archive+```++`status` is `active | dormant | awaiting_input | archived` (`awaiting_input` =+the agent emitted an `ask` and yielded).++Session object (abridged):++```json+{+ "id": "s_8f2…",+ "status": "dormant",+ "pins": {+ "agent_version": 4,+ "workspace_build": 14,+ "runtime": "claude@sha256:…",+ "model": { "requested": "anthropic/claude-opus-4-8", "served": "anthropic/claude-opus-4-8" }+ },+ "sandbox": { "state": "hibernated", "preview_urls": [] },+ "usage": { "active_seconds": 672, "tokens": { "in": 184211, "out": 9302 }, "usd": 0.47 }+}+```++Event envelope — every event carries a `level`+([visibility class](/background-agents/observability#levels)):++```json+{+ "id": "evt_01…",+ "ts": "2026-06-12T09:31:04Z",+ "actor": "platform",+ "kind": "delivery",+ "level": "user",+ "target": "chan_…",+ "body": { "type": "pr.open", "repo": "acme/web", "number": 413, "as": "maria" },+ "refs": [{ "type": "github_pr", "number": 413 }]+}+```++Kinds: `message`, `say`, `action`, `ask`, `delivery`, `status`, `timer`,+`exec.completed`, `error`. Levels: `internal | progress | user`, derived at+append from `(actor, kind)` with an optional override. `target` (optional) names+a [channel binding](#messaging) to deliver an event to a specific thread.++## Messaging++The two-way surface a chat UI is built on — send messages in, render the stream+out, bind external threads (see [Channels](/background-agents/channels)):++```http+POST /v2/sessions/:id/messages # a steer (in): { text, actor?, idem_key? }+GET /v2/sessions/:id/messages?after=… # conversation history (replay a UI)+POST /v2/sessions/:id/channels # bind a thread: { provider, thread_ref, role[] }+GET /v2/sessions/:id/channels # list bindings+```++`POST /messages` is the ergonomic steer (one inbound message); `POST /events`+is the low-level raw append underneath it. Channel `role[]` is+`conversation | delivery`.++<Note>**Preview** — `POST /v2/sessions/:id/interrupt` (mid-turn interrupt+steering) is designed but not built in v0. Steers are consumed at the next turn+boundary; see [Sessions](/background-agents/sessions#preview-mid-turn-interrupt).</Note>++## Connections & models++```http+POST /v2/connections # { type: "github" | "github_user" | "slack" | "anthropic" | "openai" | "openrouter", ... }+GET /v2/connections+GET /v2/models # aggregated catalog from connected providers+```++The `slack` connection (per-workspace OAuth, token held platform-side) powers+the [Slack channel](/background-agents/channels). In v0 it is+platform-configured for a single workspace; self-serve `oc connect slack` is+Preview.++## Observability++```http+GET /v2/sessions/:id/turns+GET /v2/sessions/:id/turns/:tid/trace+GET /v2/sessions/:id/logs?turn=+GET /v2/sessions/:id/model-calls?turn=+```diff --git a/docs/background-agents/channels.mdx b/docs/background-agents/channels.mdxnew file mode 100644index 00000000..a8ee3716--- /dev/null+++ b/docs/background-agents/channels.mdx@@ -0,0 +1,111 @@+---+title: "Channels"+description: "Two-way conversation — talk to an agent in Slack, watch it work, steer it"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out. Slack is the first channel and is+live in v0 (single, platform-configured workspace — see [State](#state)).</Note>++A session is not just a record you read after the fact — it is a two-way+thread you can talk to. A **channel** connects that thread to a place people+already work: a Slack thread, a GitHub PR. The same session can be reached+from several places at once; you never have to declare it "a Slack agent" or+"a GitHub agent."++Target experience: *"@agent the build's failing — take a look"* in a Slack+thread. The agent replies in-thread, narrates what it's doing, asks when it+needs a decision, opens a draft PR — and a comment on that PR is just another+message into the **same** session.++## Slack as a channel++A Slack-triggered agent declares one trigger — that is the whole thing. The+agent that declares the Slack trigger *is* the Slack agent:++```toml+# opencomputer.toml+name = "slack-helper"++[runtime]+image = "claude"+model = "anthropic/claude-opus-4-8"++[[triggers]]+type = "slack" # an @mention starts or continues a thread-session+on = "mention"++[connection]+github = "diggerhq" # the repos it may act on (it resolves which from the chat)+```++`@mention` it in a channel and it starts a session bound to that Slack thread;+replies in the thread continue the same session. The agent resolves which repo+to work in from the conversation (see [Workspaces](/background-agents/workspaces#resolution-and-sharing)),+investigates in a sandbox, and opens a draft PR — reporting back in the thread+throughout. The full example is [`slack-helper`](/background-agents/quickstart).++## How it flows++- **Ingress.** Slack delivers the mention/reply to the platform's `/gw/slack`+ endpoint; it is verified, de-duplicated by Slack's event id, and appended to+ the session's timeline as a **steer** (an inbound message — see+ [Conversation](/background-agents/sessions#conversation)).+- **Routing.** A **channel binding** ties the session to the Slack+ `channel + thread_ts`. The platform finds the session by that binding (or+ creates one), so every later reply lands on the same thread.+- **Projection.** The platform's **outbox** posts the agent's outbound events+ back to the thread — durably and idempotently, retrying through any provider+ blip. What gets shown is controlled by event+ [level](/background-agents/observability#levels): `user` messages and `ask`+ questions post as replies; `progress` narration can be coalesced into a+ single live "working…" message.++The agent never calls Slack itself. It only appends events; the platform+projects them. The same machinery serves any provider — GitHub is the other+instance of this contract today.++## Bindings are additive — no forced surface++A session has a *set* of bindings, added over its life — never a fixed type:++- A Slack-born session that opens a PR gains a **delivery** binding to that PR;+ the PR links back to the same session.+- A session can be surfaced in more than one place — the model does not force a+ choice between "Slack" and "GitHub."++Routing follows event level: conversation (`user`/`progress`) goes to+conversation bindings, work product (`delivery`) goes to delivery targets. An+event may name a specific binding to override (e.g. answer on the PR rather+than in Slack).++<Note>**Preview** — a GitHub PR comment flowing back into a chat-born session+as *conversation* is designed but not built in v0: today PR comments wake the+session that opened the PR (delivery), and Slack is the conversation channel.+The binding model above is built so this is a later addition, not a redesign.</Note>++## Build your own surface++Slack is one consumer of a small public API — the same surface a custom UI is+built on (see the [API](/background-agents/api#messaging)):++```http+POST /v2/sessions/:id/messages # send a message in (a steer)+GET /v2/sessions/:id/events?stream=sse&level=user # render the thread out+POST /v2/sessions/:id/channels # bind a thread { provider, thread_ref, role[] }+```++Post messages in, render the event stream at the level you want, optionally+bind a thread so the platform projects for you. Building a chat UI on a session+is an afternoon.++## State++- **v0 (live):** Slack ingress + projection, additive bindings, the outbox,+ `ask`/answer, and cheap-visible resilience (kill the sandbox mid-thread and+ the conversation resumes, nothing dropped). Single workspace,+ **platform-configured** for the demo.+- **Preview / planned:** `oc connect slack` self-serve OAuth and multiple Slack+ workspaces; PR-comment-as-conversation into a chat-born session; channels+ beyond Slack (Discord, email, web); recovering messages sent while the+ platform was down by reconciling against channel history.diff --git a/docs/background-agents/how-it-works.mdx b/docs/background-agents/how-it-works.mdxnew file mode 100644index 00000000..452bfc12--- /dev/null+++ b/docs/background-agents/how-it-works.mdx@@ -0,0 +1,86 @@+---+title: "How it works"+description: "The moving parts, how they interact, and why they're split this way"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++<Frame>+ <img src="/images/background-agents-architecture.svg" alt="Background Agents architecture: triggers feed a durable session timeline; a disposable runtime reads and appends to it, calls models through the gateway, and acts in a disposable sandbox; deliveries carry results back to GitHub" />+</Frame>++## The moving parts++| Part | What it is | Durability | Responsibility |+|---|---|---|---|+| Session timeline | Append-only event record in the platform | **Durable** — it *is* the session | Holds everything that happened; wakes the runtime when new events arrive |+| Runtime | A VM running the agent loop | Disposable | Read timeline → call model → decide → act. Holds no state, no credentials |+| Model gateway *(Preview)* | Proxy between runtimes and providers | **Durable** (its records) | As designed: applies the configured model per call, holds provider keys, meters tokens, records every request and response as they stream — encrypted, used only to resume the session, never exposed unless capture is opted in. Not built in v0 |+| Sandbox | A VM booted from the workspace's latest build | Disposable (snapshotted periodically) | Where the agent acts: commands, edits, tests. One per session, never shared |+| Connectors & outbox | Platform-side GitHub/Slack integration | **Durable** (delivery state) | Carry events out — open PRs and post comments, project the agent's messages into Slack/PR threads — at-least-once and idempotent, attributed to the requesting user. Also bring inbound messages in as steers |++## How a task flows++1. Someone labels an issue. The trigger event is stored on a session's+ timeline (new session, or the existing one for that issue).+2. The platform starts a runtime and attaches the session's sandbox.+3. The runtime reads the timeline from where it left off and calls the+ model — through the gateway, which substitutes the configured model and+ records the exchange.+4. The agent acts in the sandbox; each action is appended to the timeline+ as it happens.+5. To open a PR, the runtime appends a delivery request; a connector+ performs it and records the PR number.+6. Nothing left to do: the runtime exits, the sandbox sleeps. The session is+ dormant — just the record, no machines; storage only.+7. A comment on the PR routes back to this session (step 5 recorded the PR),+ and the cycle repeats with full context.++## Two-way flow++The timeline is a bus in both directions, not just an output log:++- **In.** Any inbound message — a Slack reply, a PR comment, an API call — is a+ **steer**: appended to the timeline (de-duplicated by the provider's event id)+ and consumed at the next turn. A **channel binding** ties the session to an+ external thread (a Slack `thread_ts`, a PR number) so follow-ups land on the+ same session. Bindings are additive — a session is never typed by surface.+- **Out.** The agent speaks with `say` (a message) and `ask` (a question that+ pauses the turn until answered). The **outbox** projects these — and+ deliveries — to the bound channels, at-least-once and idempotent, so a+ replayed turn after a crash never double-posts and a provider blip never drops+ a message. The agent only appends events; it never calls Slack or GitHub+ itself.++See [Channels](/background-agents/channels) and the+[conversation model](/background-agents/sessions#conversation).++## Why it's split this way++Both machines are disposable because no state lives in them — it has already+left by the time it could be lost:++- events are stored as they are produced (step 4);+- the conversation is recorded at the gateway (step 3) — provider APIs carry+ the full context on every call, so the latest recorded exchange is the+ agent's complete working memory *(gateway recording is Preview; see the+ note above)*;+- sandbox files are snapshotted periodically while work is in progress.++What this buys (gateway-dependent points are Preview, not built in v0):++- **Crash-proof.** Kill either machine mid-task and the session resumes where+ it was on fresh machines. As designed, even a kill mid-model-call recovers:+ the in-flight response is still recorded at the gateway, and not re-billed.+- **Free dormancy.** Waiting detaches both machines; a session can sleep for+ months for ~storage cost and wake in seconds.+- **Model switching as configuration.** As designed, the gateway applies+ model config on each request — no restart. Within a provider, a change is+ effective on the next call; switching providers is effective on the next+ turn, when the runtime reconnects. Keys never enter the machines.+- **Risk isolation.** The sandbox runs arbitrary code, so it's per-session+ and replaceable; the loop carries neither that risk nor that lifecycle. A+ one-hour build in the sandbox doesn't keep a loop machine running.+- **Safe upgrades.** Sessions pin their agent version, workspace build, and+ runtime at start; changes apply to new sessions.diff --git a/docs/background-agents/models.mdx b/docs/background-agents/models.mdxnew file mode 100644index 00000000..e61c5c3e--- /dev/null+++ b/docs/background-agents/models.mdx@@ -0,0 +1,69 @@+---+title: "Models"+description: "Provider-prefixed IDs, switched as configuration"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++The model is configuration on the agent — not part of code or a runtime+image. A change takes effect on the next model call — the next turn, when+switching providers; nothing restarts.++<Note>**Preview** — the hot-swap and metering behavior on this page runs through+the model gateway, which is **not enabled in v0** (see the+[overview](/background-agents/overview)). Today the `claude` runtime calls the+provider directly with a configured key; model addressing and per-agent+configuration are real, but live rewrite, cross-provider flips, and gateway+metering are the designed behavior.</Note>++## Addressing++Provider-prefixed, provider-native IDs:++```+anthropic/claude-opus-4-8+openai/gpt-5.x+openrouter/qwen-3-coder+```++OpenComputer adds no model names of its own. Bare IDs are accepted when+unambiguous.++```bash+oc model list # every model available through your connected providers+```++## Switching++```bash+oc agent update fixer --model openai/gpt-5.x # new agent version+oc session set <id> --model openai/gpt-5.x # one session, in flight+```++Agent-level changes are versions; session-level overrides appear as `status`+events on the timeline; usage records the model that served each call.+Switching to a different provider requires a [runtime](/background-agents/runtimes)+that drives it (the planned `opencode` drives all — Preview).++## Provider keys++```bash+oc connect anthropic --api-key sk-ant-...+oc connect openai --api-key sk-...+oc connect openrouter --api-key sk-or-...+```++Bring your own keys per provider, or use platform billing where available.+One OpenRouter key opens its full multi-lab catalog.++As designed, keys never enter agent machines: model traffic flows through+OpenComputer's model gateway, which holds the keys, enforces the configured+model, and meters tokens per session. The gateway is a Preview capability —+see the [overview](/background-agents/overview).++## Restricting++Organizations can restrict allowed providers+([policies](/background-agents/agents#policies)); agent data goes only to+providers you allow.diff --git a/docs/background-agents/observability.mdx b/docs/background-agents/observability.mdxnew file mode 100644index 00000000..2e5a343b--- /dev/null+++ b/docs/background-agents/observability.mdx@@ -0,0 +1,98 @@+---+title: "Observability"+description: "Timeline, turns, model calls, machine output — all correlated"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++Background agents work unattended; everything they do is recorded and+correlated. From any point on a session's timeline you can drill down to the+model calls and commands behind it.++## Timeline++The durable record: [events](/background-agents/sessions#events) for every+message, action, question, delivery, and error.++```bash+oc session attach <id> # live+oc session events <id> --after <cursor> # history, paginated+```++```bash+curl "https://api.opencomputer.dev/v2/sessions/$ID/events?stream=sse" \+ -H "Authorization: Bearer $OC_API_KEY"+```++## Levels++Every event carries a **level** — a visibility class — and the stream carries+**everything**, full fidelity. You filter; the platform never decides for you+what to show your users.++| Level | What | Example |+|---|---|---|+| `internal` | Platform/runtime mechanics, raw tool I/O | `action` (a tool call), model-call marks |+| `progress` | The play-by-play — "watch it work" | agent narration, `status` ("cloned repo", "running tests") |+| `user` | What an end-user sees by default | the agent's `say`, `ask`, and `delivery` ("opened PR #42") |++The stream filters by a **minimum** level — `?level=user` is just the+conversation; `?level=progress` adds narration; `?level=internal` is everything+(the debug view). Default is full fidelity.++```bash+oc session attach <id> --level user+```++```bash+curl "https://api.opencomputer.dev/v2/sessions/$ID/events?stream=sse&level=progress" \+ -H "Authorization: Bearer $OC_API_KEY"+```++This is how a [channel](/background-agents/channels) decides what to surface: a+Slack thread renders `user`/`progress`, a debugging view renders `internal`+too — from the one stream.++## Turns++A turn is one stretch of activity (wake → work → sleep):++```bash+oc session turns <id>+# t_7 2m41s anthropic/claude-opus-4-8 31.2k tok $0.41 yielded: delivered PR #413+oc session trace <id> t_7 # spans: model calls, commands, deliveries, timings+oc session logs <id> --turn t_7 # raw runtime output+oc session model-calls <id> # per call: provider, model served, tokens, latency+```++Command output appears on the timeline as `action` events, truncated inline+with full output downloadable.++## Cost++```bash+oc session get <id> # usage: active_seconds, tokens, usd+```++Metered per session and per turn. Dormant time is absent because it isn't+billed.++## Model traffic privacy++By default, model-call metadata (model, tokens, latency, cost) is recorded;+prompt and response contents are not exposed. Payload capture is opt-in per+agent (`capture_model_io`) and surfaces in `oc session model-calls --full`.++<Note>**Preview** — payload capture runs through the model gateway, which is not+enabled in v0 (see the [overview](/background-agents/overview)). Until then,+only metadata is available; the `capture_model_io` opt-in and `--full` payloads+are the designed behavior.</Note>++## Debugging++1. `oc session attach` — what did it do and say?+2. `oc session trace` — where did time and tokens go?+3. `oc session shell` — open the machine.+4. `oc session state download` — export the working context to reproduce+ the run locally in the same harness.diff --git a/docs/background-agents/overview.mdx b/docs/background-agents/overview.mdxnew file mode 100644index 00000000..34386e85--- /dev/null+++ b/docs/background-agents/overview.mdx@@ -0,0 +1,69 @@+---+title: "Background Agents"+description: "Event-triggered agents with durable sessions, on managed compute"+---++<Note>+**Preview.** Background Agents is in active development. This section+describes the product as designed; capabilities are rolling out in stages and+not all are generally available yet. Commands are shown in the target grammar+`oc agent …`; today they ship under the `oc-agents` CLI (e.g. `oc-agents agent+deploy`), because the `oc agent …` namespace currently belongs to+[Hosted Agents](/agents-api/overview). The runtime that ships today is+`claude`; the gateway-dependent capabilities (model hot-swap, payload capture)+and prepared workspaces are flagged Preview where they appear.+</Note>++A background agent works unattended: an issue gets labeled, the agent fixes+it in a fresh machine and opens a draft PR. A comment on that PR a day later+wakes the same agent with full context. You pay for the minutes it worked.++Background Agents runs everything around the agent loop: event ingestion,+session state, machine preparation, delivery back to GitHub, metering. The+model — or the entire harness — is a configuration change.++## Concepts++| Concept | What it is |+|---|---|+| [Agent](/background-agents/agents) | Definition: prompt, skills, model, triggers, policies, and a connection. Versioned. Not bound to a repo or workspace; via its connection it acts across many repos. |+| [Session](/background-agents/sessions) | One thread of work: a durable event timeline. Active while working, dormant otherwise; dormant holds no compute. |+| [Workspace](/background-agents/workspaces) | A prepared environment for one or more repos, rebuilt on every push — dependencies installed, build warm. Not tied to an agent. |+| [Trigger](/background-agents/triggers) | GitHub events or a Slack @mention, routed to the right session. |+| [Channel](/background-agents/channels) | A two-way thread the session talks in — Slack today, a GitHub PR. Bindings are additive; a session is never typed by surface. |+| [Connection](/background-agents/triggers#connections) | The GitHub App install, Slack workspace, and model provider keys. |+| [Runtime](/background-agents/runtimes) | The loop that drives a session. Its model is separate configuration. |++## How it works++A session is a durable timeline of events. While there is work, two machines+attach: a **runtime** (the loop) and a **sandbox** (the machine it acts in);+they detach when the work pauses. All state — events, the model+conversation, files — leaves the machines as it is produced, so either can+die at any point and the session resumes where it was. Details:+[How it works](/background-agents/how-it-works).++## Relation to sandboxes++Sessions work inside ordinary [sandboxes](/sandboxes/overview), booted from+the workspace's latest build and managed for you. `oc session shell <id>`+opens the actual machine. For full control of the loop and the machine, use+the [Agent SDK](/agents/overview) instead. [Hosted+Agents](/agents-api/overview) remains the surface for chat-style agents on+managed cores and channels; Background Agents is for event-triggered,+unattended work.++## Properties++- Sessions start in seconds, because the workspace rebuilt itself on the+ last push.+- Models are addressed `provider/model` and switched with one command —+ effective on the next call within a provider, on the next turn across+ providers. Bring your own keys, including OpenRouter.+- Agents hold no tokens. The platform opens PRs and posts comments on their+ behalf, attributed to the requesting user.+- Sessions are two-way. Talk to an agent in a Slack thread, watch it work, and+ steer it; it asks when it needs a decision. See+ [Channels](/background-agents/channels).++[Quickstart →](/background-agents/quickstart)diff --git a/docs/background-agents/quickstart.mdx b/docs/background-agents/quickstart.mdxnew file mode 100644index 00000000..36dae9f0--- /dev/null+++ b/docs/background-agents/quickstart.mdx@@ -0,0 +1,122 @@+---+title: "Quickstart"+description: "A working background agent in three commands"+---++After this page, labeling a GitHub issue `agent` produces a draft PR, and+commenting on that PR wakes the same agent to follow up.++<Note>**Preview** — see the [overview](/background-agents/overview); some steps+below are still rolling out.</Note>++## 1. Connect GitHub++```bash+oc connect github+```++Installs the OpenComputer GitHub App on your org. No app registration,+webhook setup, or secrets. To have PRs open **as you** rather than as the App+on your behalf, also run `oc connect github --as-user`.++## 2. Create a workspace (optional, Preview)++```bash+oc workspace create web \+ --repo github.com/acme/web \+ --setup "pnpm i && pnpm build"+```++A workspace prepares a repo ahead of time: the first build clones it, runs+setup, and snapshots the result, then rebuilds on every push so sessions+start from a ready machine matching the latest code. `oc workspace builds+web` lists the builds. **In v0 this step is not built yet** — skip it and the+session clones the repo on demand.++## 3. Create the agent++```bash+oc agent create fixer \+ --model anthropic/claude-opus-4-8 \+ --prompt "You fix bugs labeled 'agent' in acme/web. Keep diffs minimal. Run the affected tests before pushing." \+ --trigger github:issue.labeled:agent+```++## Use it++Label an issue `agent`. A session starts within seconds:++```bash+oc session list --agent fixer+oc session attach <session-id> # live events; Ctrl-C detaches, the agent keeps working+```++A draft PR opens, attributed to the person who labeled the issue — as them if+they ran `oc connect github --as-user`, otherwise opened by the App on their+behalf. The session goes dormant; `oc session get <id>` shows `usage.active_seconds` — dormant time+uses no compute.++Comment on the PR: *"also update the changelog."* The session wakes with its+full context, pushes a commit, and sleeps again. The thread persists; a+comment weeks later wakes the same context.++## Change the model++```bash+oc agent update fixer --model openai/gpt-5.x+```++Effective when the agent next wakes — switching providers means the runtime+reconnects; a change within the same provider applies on the very next model+call. Same prompt and triggers. Each change is a new agent+version — `oc agent rollback fixer v1` reverts.++## Or: talk to it in Slack++An agent can be conversational instead of (or as well as) issue-triggered.+Declare a Slack trigger and it becomes a teammate you @mention in a thread:++```toml+# opencomputer.toml+name = "slack-helper"++[runtime]+image = "claude"+model = "anthropic/claude-opus-4-8"++[[triggers]]+type = "slack"+on = "mention"++[connection]+github = "diggerhq" # the repos it may act on; it resolves which from the chat+```++```bash+oc connect slack # install the OpenComputer Slack app (Preview — see below)+oc agent deploy ./slack-helper+```++`/invite` it to a channel and @mention it:++```+you @slack-helper parseDuration in oc-agent-demo-target mis-parses "1.5h" — fix it?+bot On it — pulling oc-agent-demo-target…+bot Found it: the regex silently drops "1.". Throw on bad input, or support fractions?+you throw+bot Done — tests pass. 📦 Opened PR #42+```++It works out *which* repo from the conversation, investigates in a sandbox,+**asks** when it needs a decision (and pauses, free, until you reply), and opens+a draft PR — narrating in-thread the whole time. Full walkthrough:+[Channels](/background-agents/channels).++<Note>**Preview** — in v0 the Slack app is platform-configured for a single demo+workspace; self-serve `oc connect slack` is planned.</Note>++## Next++- [Agents as code](/background-agents/agents)+- [Sessions and dormancy](/background-agents/sessions)+- [Workspace freshness and warm pools](/background-agents/workspaces)diff --git a/docs/background-agents/runtimes.mdx b/docs/background-agents/runtimes.mdxnew file mode 100644index 00000000..5ea01dde--- /dev/null+++ b/docs/background-agents/runtimes.mdx@@ -0,0 +1,68 @@+---+title: "Runtimes"+description: "The loop that drives a session, selected like a base image"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++The runtime is the agent loop: it reads the session, calls the model, and+acts in the session's machine. You select it; OpenComputer operates it.++```toml+[runtime]+image = "claude"+model = "anthropic/claude-opus-4-8"+```++```bash+oc runtime list+# claude Claude Code / Agent SDK harness (default)+# codex Preview — not built yet+# opencode Preview — multi-provider harness, not built yet+```++## Semantics++- **Versioned like a deployment.** Tags move, digests pin; each session+ records the digest it runs, so runtime upgrades never affect in-flight+ sessions.+- **The model is not part of the runtime** — it's+ [configuration](/background-agents/models). Runtimes declare which+ providers they can drive; switching *across* providers needs an image that+ drives the target (the planned `opencode` drives all — Preview).+- **Stateless and disposable.** Session state — conversation, timeline,+ sandbox files — lives outside the runtime. If a runtime's machine dies+ mid-task, the session continues on a fresh one; the timeline shows an+ `error` event and a short pause.+- **No credentials.** By design, model keys stay in the gateway (a Preview+ capability) and delivery tokens in the platform.++## Behavior++- **No busy-waiting.** Waiting — on a person, a long build, the clock —+ makes the session dormant instead of burning compute.+- **Asks yield.** When the agent needs a decision it emits an `ask` and the+ turn yields; the session goes `awaiting_input` and holds no compute until a+ reply arrives (`oc session send`).+- **Budget-aware.** Runtimes wind down near the session's budget cap; the+ platform enforces the cap regardless.++## Tools the runtime provides++The agent works through a small set of platform tools — building an agent is+mostly a prompt that uses them well:++- **`say`** / **`ask`** — speak to the human; the agent's raw reasoning is never+ shown, only `say`/`ask`. `ask` pauses the turn until answered (see+ [Conversation](/background-agents/sessions#conversation)).+- **`use_repo`** — pick a repo to work in from the ones the connection covers,+ and switch or open more+ ([resolution](/background-agents/workspaces#resolution-and-sharing)).+- **`deliver`** — open or update a draft PR; the platform pushes it as the+ human, so no git tokens enter the sandbox.+- **`bash` / `read` / `write` / `ls`** — the session's sandbox.++<Note>**Preview** — additional platform images (`codex`, `opencode`) and+publishing your own loop (`oc runtime push`) use the same registry and contract,+but are not built in v0; `claude` is the runtime that ships today.</Note>diff --git a/docs/background-agents/sessions.mdx b/docs/background-agents/sessions.mdxnew file mode 100644index 00000000..aeb318ee--- /dev/null+++ b/docs/background-agents/sessions.mdx@@ -0,0 +1,125 @@+---+title: "Sessions"+description: "Durable threads of work; dormant sessions hold no compute"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++A session is one thread of an agent's work: one issue, one PR, one ongoing+conversation. It is an append-only **event timeline**, durable independently+of any machine. Compute attaches when there is work and detaches when there+isn't.++## Lifecycle++```+active ◄──► dormant ──► archived (retention policy)+ │+ └──► awaiting_input (waiting on a human answer)+```++- **active** — a runtime is working; billing runs.+- **dormant** — nothing to do. No compute attached; storage only. A+ session can stay dormant for months and wake in seconds.+- **awaiting_input** — the agent asked a question (`ask`) and is waiting. The+ turn has yielded, so no compute is attached; a reply wakes it.+- Sessions are never forcibly ended; archival is a retention policy you set.++Machine failures, deploys, and restarts do not lose session state. Kill the+sandbox mid-thread and the session resumes — a dead-but-connectable machine is+recreated and re-cloned, and the pushed branch plus the event timeline are the+durable copy of the work; nothing in the conversation is dropped. *(As+designed, the conversation also resumes byte-exact from the gateway's recorded+exchange — a [Preview](/background-agents/overview) capability, not built in v0;+the cheap-visible resume above is what ships today.)*++## Starting and routing++Sessions start from triggers, or explicitly:++```bash+oc session start fixer "migrate the date helpers to Temporal"+```++Triggers route by **routing key** — by default one session per GitHub+issue. Follow-ups find their session: a comment on a PR resumes the session+that opened it. One agent runs many concurrent sessions.++## Conversation++A session is two-way. The agent has two ways to reach a human, and only these+two are shown — its raw internal reasoning is never surfaced:++- **`say`** — a deliberate message to the human: progress, a finding, an+ answer. The frontend chooses how much to surface (see+ [levels](/background-agents/observability#levels)).+- **`ask`** — a question that **pauses the turn**. The agent appends the+ question and yields; the session goes **`awaiting_input`** and holds no+ compute while it waits. A reply wakes it with the answer already in context,+ and it continues. This is what makes it a conversation, not a fire-and-forget+ command.++Any inbound message — a Slack reply, a PR comment, a direct API call — is a+**steer**: it is appended to the timeline and picked up at the next turn. (A+steer adjusts the *next* turn; mid-turn interruption is+[Preview](#preview-mid-turn-interrupt).) Channels project `say`/`ask` and+progress out to where people are watching — see+[Channels](/background-agents/channels).++## Events++Every event carries an actor, a `kind`, and a **`level`** —+`internal | progress | user` — a visibility class so a consumer can show as+much or as little as it wants (see+[Observability](/background-agents/observability#levels)).++| Kind | Level | Meaning |+|---|---|---|+| `message` | progress | A human or trigger said something; or agent narration |+| `say` | user | The agent's deliberate user-facing message |+| `action` | internal | The agent ran a command or edited files in its sandbox |+| `ask` | user | The agent needs a human decision; the session goes `awaiting_input` until answered |+| `delivery` | user | An outward action performed for the agent — PR opened, comment posted |+| `status` | progress | Lifecycle and configuration changes |+| `timer` | — | A scheduled wake fired |+| `exec.completed` | — | A long-running command the agent was waiting on finished |+| `error` | user | A failure, with retry context |++```bash+oc session attach <id> # live stream; detaching doesn't stop the agent+oc session send <id> "use the staging DB for repro" # a steer, in+```++```bash+curl "https://api.opencomputer.dev/v2/sessions/$ID/events?stream=sse" \+ -H "Authorization: Bearer $OC_API_KEY"+```++## The sandbox underneath++Each session works in its own [sandbox](/sandboxes/overview), booted from+the workspace's latest build, managed for you:++```bash+oc session get <id> # status, pins, sandbox state, preview URLs, usage+oc session shell <id> # open the actual machine+```++`pins` records what the session runs on — agent version, workspace build,+runtime — so in-flight work is unaffected by updates and runs are+reproducible.++## Cost++You pay for attached compute and model tokens while the session is active+(`usage.active_seconds`). A session that worked 11 minutes across two days+bills 11 minutes of compute; dormant time costs only the storage of the+timeline and snapshots.++## Preview: mid-turn interrupt++A steer is consumed at the next turn boundary — it adjusts the *next* turn, not+the one in flight. Interrupting a turn already running (a steer that redirects+work mid-task) is designed but not built in v0. To steer in v0, send the+message; it is applied when the current turn yields.diff --git a/docs/background-agents/triggers.mdx b/docs/background-agents/triggers.mdxnew file mode 100644index 00000000..bf86a5d9--- /dev/null+++ b/docs/background-agents/triggers.mdx@@ -0,0 +1,86 @@+---+title: "Triggers & Connections"+description: "Events in, results out"+---++<Note>**Preview** — see the [overview](/background-agents/overview); some+capabilities below are still rolling out.</Note>++Triggers bring events to your agent; deliveries carry its work back out.+Both run through **connections** — integrations OpenComputer operates.++## Connections++```bash+oc connect github # install the OpenComputer GitHub App on your org+oc connect github --as-user # optional personal grant: deliveries act as you+```++Installing the App is the entire GitHub integration — no app registration,+webhook configuration, or secrets. Model provider keys are also connections;+see [Models](/background-agents/models).++A **Slack** connection (per-workspace OAuth, token held platform-side) powers+the Slack conversation [channel](/background-agents/channels).++```bash+oc connect slack # install the OpenComputer Slack app to your workspace+```++<Note>**Preview** — in v0 the Slack app is **platform-configured** for a single+demo workspace; self-serve `oc connect slack` and multiple workspaces are+planned. See the [overview](/background-agents/overview).</Note>++## Triggers++Declared on the agent:++```toml+[[triggers]]+type = "github"+on = "issue.labeled:agent"+```++Supported GitHub events include issue labels and PR/issue comments. Events are+acknowledged instantly, then routed:++- **Routing keys** group events into sessions — by default one session per+ issue.+- A comment on a PR the agent opened resumes the session that opened it.++Only members of your organization can trigger an agent or wake a session —+labels and comments from anyone else are ignored. Configurable per agent+([policies](/background-agents/agents#policies)).++### Slack++A `slack` trigger makes the agent conversational — an `@mention` starts or+continues a thread-session:++```toml+[[triggers]]+type = "slack"+on = "mention"+```++The agent that declares this trigger *is* the Slack agent: mentions and thread+replies route to it as steers, and it talks back in the thread. See+[Channels](/background-agents/channels) for the full two-way model and+[`slack-helper`](/background-agents/quickstart) for a complete example.++<Note>**Preview** — `cron` and `http`/email triggers are planned, not built in+v0.</Note>++## Deliveries++Agents hold no GitHub tokens. To open a PR or post a comment, the agent+requests a **delivery** and the platform performs it:++- With a personal grant, the PR is opened **as the person who triggered the+ work** — review attribution and permissions behave as if they pushed it.+- Without a grant, the App opens it with *"on behalf of @user"* attribution.+- Defaults: draft PRs only, never to protected branches+ ([policies](/background-agents/agents#policies)).++Every delivery appears on the session timeline, and the PR links back to its+session.diff --git a/docs/background-agents/workspaces.mdx b/docs/background-agents/workspaces.mdxnew file mode 100644index 00000000..aa82a977--- /dev/null+++ b/docs/background-agents/workspaces.mdx@@ -0,0 +1,99 @@+---+title: "Workspaces"+description: "Prepared environments for one or more repos, rebuilt on every push"+---++<Note>**Preview** — workspaces are not built in v0 yet. Today a session clones+its repo on demand; the prepared-environment model below describes the+designed behavior. See the [overview](/background-agents/overview).</Note>++Cloning, installing, and building take minutes. A workspace does that work+ahead of time — on every push — and snapshots the result, so sessions boot+into a ready machine in seconds.++A workspace is a first-class resource, not an agent attribute: it prepares+**one or more repos** (each at an optional ref or branch) and is shared by+every agent and session that lands on those repos.++```bash+oc workspace create web \+ --repo github.com/acme/web \+ --setup "pnpm i && pnpm build" \+ --warm "pnpm test --filter smoke" \+ --pool 1+```++## Recipe++- **repo** — one or more repos, cloned via your GitHub connection (read+ access). Each may pin an optional ref or branch; pass `--repo` again to+ span several repos in one environment.+- **setup** — install, build, generate.+- **warm** *(optional)* — run once to heat caches, e.g. a smoke test.++## Builds++The workspace rebuilds on every push to the default branch — clone, setup,+warm, snapshot — so the latest build matches the latest code. `--refresh+30m` switches to interval rebuilds instead: useful at commit volumes where+per-push builds would pile up, or to pick up floating dependencies on a+quiet repo. Builds form an immutable lineage:++```bash+oc workspace builds web+# #14 4 minutes ago main@9f3c21 ok 6m12s+# #13 34 minutes ago main@8e1d09 ok 6m05s+```++Sessions boot from the latest successful build and pin it. A failed build+never becomes latest.++Builds run on ordinary sandboxes and bill as build minutes. On-push refresh+costs nothing while the repo is quiet; `--refresh 30m` runs ~48 builds a day+whether or not anything changed.++`--pool N` keeps N machines pre-booted from the latest build, removing even+the boot seconds for busy agents.++## Resolution and sharing++A session is **not bound to a repo** — it *resolves* which repo(s) to work in,+from one of several sources:++- the **triggering event** (a labeled issue's repo) — one source, not the only+ one;+- the **conversation** — a chat-born session has no triggering repo, so the+ agent picks one from the repos its connection covers (see below);+- a **configured default** on the agent;+- or it **asks** the human.++Resolution can be **lazy** (deferred until first needed) and **re-resolvable**:+a session can switch repos mid-thread, or open several at once — each is checked+out as its own directory inside the session's single sandbox.++The agent drives this at runtime with a **`use_repo`** tool: it lists the repos+its [connection](/background-agents/triggers#connections) scopes, checks one+out, and calls again to switch or to add a second checkout. Where a prepared+workspace covers the resolved repo/ref, the session boots from its latest build+(fast); otherwise it **clones on demand**.++Workspaces are not 1:1 with a repo: a repo can have more than one (e.g. per+branch), and a single workspace can span multiple repos. Any workspace covering+a session's repo/ref is shared by every agent and session that lands there,+independent of which agent runs.++## During a session++The workspace defines the machine at session start; after that the session's+sandbox evolves freely. Work in progress is protected independently — if a+session's machine is lost, it is restored with its recent state, not rebuilt+from the workspace (see [Sessions](/background-agents/sessions)).++## API++```bash+POST /v2/workspaces # create (recipe, refresh, pool)+GET /v2/workspaces/:id # recipe, pool status, latest build+GET /v2/workspaces/:id/builds # lineage+POST /v2/workspaces/:id/builds # build now+```diff --git a/docs/docs.json b/docs/docs.jsonindex dd9cc008..3a9803a8 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -71,6 +71,24 @@"agent-sessions/api-reference"]},+ {+ "group": "Background Agents",+ "tag": "Preview",+ "pages": [+ "background-agents/overview",+ "background-agents/quickstart",+ "background-agents/how-it-works",+ "background-agents/agents",+ "background-agents/sessions",+ "background-agents/workspaces",+ "background-agents/triggers",+ "background-agents/channels",+ "background-agents/models",+ "background-agents/runtimes",+ "background-agents/observability",+ "background-agents/api"+ ]+ },{"group": "Reserved Capacity","pages": [diff --git a/docs/images/background-agents-architecture.svg b/docs/images/background-agents-architecture.svgnew file mode 100644index 00000000..eb7d1ae6--- /dev/null+++ b/docs/images/background-agents-architecture.svg@@ -0,0 +1,112 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 560" font-family="ui-sans-serif, system-ui, sans-serif">+ <defs>+ <marker id="ah" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto">+ <path d="M0.6 0.8 L7.4 4 L0.6 7.2 Z" fill="#9a9a9a"/>+ </marker>+ <marker id="ahs" viewBox="0 0 8 8" refX="1" refY="4" markerWidth="7" markerHeight="7" orient="auto">+ <path d="M7.4 0.8 L0.6 4 L7.4 7.2 Z" fill="#9a9a9a"/>+ </marker>+ </defs>++ <!-- canvas -->+ <rect x="0.5" y="0.5" width="959" height="559" rx="12" fill="#ffffff" stroke="#e5e5e5" stroke-width="1"/>++ <!-- ============ LEFT: Triggers ============ -->+ <text x="44" y="189" font-size="10" letter-spacing="1.5" fill="#6b6b6b">TRIGGERS</text>++ <rect x="40" y="201" width="116" height="30" rx="15" fill="#ffffff" stroke="#d4d4d4"/>+ <text x="98" y="220" font-size="12" fill="#131311" text-anchor="middle">issue labeled</text>++ <rect x="40" y="243" width="116" height="30" rx="15" fill="#ffffff" stroke="#d4d4d4"/>+ <text x="98" y="262" font-size="12" fill="#131311" text-anchor="middle">PR comment</text>++ <rect x="40" y="285" width="116" height="30" rx="15" fill="#ffffff" stroke="#d4d4d4"/>+ <text x="98" y="304" font-size="12" fill="#131311" text-anchor="middle">API / CLI</text>++ <line x1="160" y1="216" x2="183" y2="216" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>+ <line x1="160" y1="258" x2="183" y2="258" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>+ <line x1="160" y1="300" x2="183" y2="300" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>++ <!-- ============ CENTER: Session (durable) ============ -->+ <rect x="190" y="140" width="190" height="236" rx="10" fill="#f4f4f2" stroke="#d4d4d4"/>+ <text x="204" y="166" font-size="14" font-weight="600" fill="#131311">Session</text>+ <text x="204" y="183" font-size="11" fill="#6b6b6b">durable timeline</text>++ <!-- event rows -->+ <rect x="204" y="196" width="162" height="28" rx="6" fill="#f0eff7" stroke="#cfcee4"/>+ <circle cx="220" cy="210" r="3" fill="#7c7aae"/>+ <text x="232" y="214" font-size="12" fill="#131311">message</text>++ <rect x="204" y="232" width="162" height="28" rx="6" fill="#f0eff7" stroke="#cfcee4"/>+ <circle cx="220" cy="246" r="3" fill="#7c7aae"/>+ <text x="232" y="250" font-size="12" fill="#131311">action</text>++ <rect x="204" y="268" width="162" height="28" rx="6" fill="#f0eff7" stroke="#cfcee4"/>+ <circle cx="220" cy="282" r="3" fill="#7c7aae"/>+ <text x="232" y="286" font-size="12" fill="#131311">delivery</text>++ <!-- next append slot -->+ <rect x="204" y="304" width="162" height="28" rx="6" fill="none" stroke="#cfcee4" stroke-dasharray="4 4" opacity="0.8"/>++ <text x="285" y="350" font-size="11" fill="#6b6b6b" text-anchor="middle">append-only</text>+ <text x="285" y="366" font-size="11" fill="#6b6b6b" text-anchor="middle">stored as events happen</text>++ <!-- Session <-> Runtime -->+ <line x1="388" y1="172" x2="452" y2="172" stroke="#9a9a9a" stroke-width="1.25" marker-start="url(#ahs)" marker-end="url(#ah)"/>+ <text x="420" y="160" font-size="10" fill="#6b6b6b" text-anchor="middle">reads / appends</text>++ <!-- ============ RIGHT TOP: Runtime (disposable, star) ============ -->+ <rect x="460" y="56" width="250" height="160" rx="12" fill="#ffffff" stroke="#8a8a8a" stroke-width="2" stroke-dasharray="7 5"/>+ <text x="478" y="92" font-size="18" font-weight="700" fill="#131311">Runtime<tspan font-size="13" font-weight="400" fill="#6b6b6b"> — the brains</tspan></text>+ <text x="478" y="126" font-size="12" fill="#131311">plans and decides every step</text>+ <text x="478" y="148" font-size="11" fill="#6b6b6b">stateless · holds no credentials</text>+ <text x="478" y="168" font-size="11" fill="#6b6b6b">talks to models via the gateway</text>++ <!-- Runtime -> Gateway -->+ <line x1="714" y1="110" x2="736" y2="110" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>++ <!-- ============ RIGHT: Model gateway (durable, supporting) ============ -->+ <rect x="744" y="66" width="176" height="100" rx="8" fill="#f4f4f2" stroke="#d4d4d4"/>+ <text x="758" y="88" font-size="12" font-weight="600" fill="#4a4a4a">Model gateway</text>+ <text x="758" y="105" font-size="10" fill="#6b6b6b">applies the configured model</text>+ <text x="758" y="120" font-size="10" fill="#7c7aae">records requests + responses</text>+ <text x="758" y="135" font-size="10" fill="#6b6b6b">holds provider keys</text>+ <text x="758" y="153" font-size="9" fill="#9a9a9a">Anthropic · OpenAI · OpenRouter</text>++ <!-- Runtime -> Sandbox -->+ <line x1="585" y1="220" x2="585" y2="266" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>+ <text x="573" y="247" font-size="11" fill="#6b6b6b" text-anchor="end">acts: commands · edits · tests</text>++ <!-- ============ RIGHT BOTTOM: Sandbox (disposable, star) ============ -->+ <rect x="460" y="272" width="250" height="160" rx="12" fill="#ffffff" stroke="#8a8a8a" stroke-width="2" stroke-dasharray="7 5"/>+ <text x="478" y="308" font-size="18" font-weight="700" fill="#131311">Sandbox<tspan font-size="13" font-weight="400" fill="#6b6b6b"> — the hands</tspan></text>+ <text x="478" y="342" font-size="12" fill="#131311">where the work actually happens</text>+ <text x="478" y="364" font-size="11" fill="#6b6b6b">booted from workspace build</text>+ <text x="478" y="384" font-size="11" fill="#6b6b6b">disposable · rebuilt on demand</text>++ <!-- Sandbox -> snapshots (durable) -->+ <line x1="714" y1="346" x2="752" y2="346" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>+ <rect x="758" y="332" width="150" height="28" rx="6" fill="#f0eff7" stroke="#b9b8d6"/>+ <text x="833" y="350" font-size="11" fill="#131311" text-anchor="middle">snapshots (periodic)</text>++ <!-- Delivery: the runtime emits a delivery EVENT onto the session; a+ platform connector performs the GitHub write. The sandbox never writes+ to GitHub (no write token in the sandbox). -->+ <line x1="285" y1="376" x2="285" y2="402" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>+ <text x="297" y="394" font-size="10" fill="#6b6b6b">delivery event</text>++ <rect x="210" y="404" width="150" height="30" rx="8" fill="#ffffff" stroke="#d4d4d4"/>+ <text x="285" y="423" font-size="11" fill="#131311" text-anchor="middle">platform connector</text>++ <line x1="285" y1="434" x2="285" y2="462" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>++ <rect x="207" y="468" width="156" height="30" rx="15" fill="#ffffff" stroke="#d4d4d4"/>+ <text x="285" y="487" font-size="12" fill="#131311" text-anchor="middle">draft PR · as @user</text>++ <!-- ============ Legend ============ -->+ <rect x="44" y="518" width="22" height="14" rx="4" fill="#f0eff7" stroke="#7c7aae"/>+ <text x="74" y="529" font-size="11" fill="#6b6b6b">durable (survives anything)</text>++ <rect x="252" y="518" width="22" height="14" rx="4" fill="#ffffff" stroke="#8a8a8a" stroke-width="1.5" stroke-dasharray="3 3"/>+ <text x="282" y="529" font-size="11" fill="#6b6b6b">disposable (replaceable any moment)</text>+</svg>