Skip to content

An open-source, faster Devin alternative

TypeScript

docs(agent-sessions): feature self-healing runtime; Standard Webhooks; pinning; Preview tag

Igor Zalutski548f491852b5
diff --git a/docs/agent-sessions/agents.mdx b/docs/agent-sessions/agents.mdx
index 1335d358..5e9f251a 100644
--- a/docs/agent-sessions/agents.mdx
+++ b/docs/agent-sessions/agents.mdx
@@ -16,7 +16,7 @@ Pass your Anthropic `key` inline and it's stored as a [credential](/agent-sessio
## Pinned snapshot
-When a session is created it **freezes** the agent's `prompt`, `model`, and `runtime` into the session. Editing the named agent afterwards never changes a running or resumed session — its behavior is pinned for its whole life. Update an agent freely: existing sessions keep what they started with, new sessions pick up the change.
+When a session is created it **freezes** the agent's `prompt`, `model`, `runtime`, and `revision` (a number that bumps on every edit) into the session — and pins the resolved credential too. Editing the named agent afterwards never changes a running or resumed session — its behavior is pinned for its whole life. Update an agent freely: existing sessions keep what they started with, new sessions pick up the change. (Rotating a credential's **key value** is the exception — that flows to running sessions, so a compromised key can be replaced; see [authentication](/agent-sessions/authentication#model-credentials).)
## Model
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdx
index 8c5f1a19..6ca64d64 100644
--- a/docs/agent-sessions/api-reference.mdx
+++ b/docs/agent-sessions/api-reference.mdx
@@ -23,6 +23,7 @@ Base URL `https://api.opencomputer.dev/v3`. Management calls authenticate with y
```
Session = { id, status, head, input_cursor,
agent_snapshot: { prompt_hash, model, runtime, revision },
+ credential_id, // resolved + pinned at create
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 }
@@ -50,7 +51,7 @@ Event = { id, seq, ts, session, actor, type, level, body, refs }
| Method · Path | Purpose |
| --- | --- |
-| `POST /sessions/:id/messages` | Append an input message; wakes the session. Body: `{ text, idempotency_key? }` or `{ envelope }`. Returns `{ seq }`. |
+| `POST /sessions/:id/messages` | Append an input message; wakes the session. Body: `{ text, idempotency_key? }` or `{ envelope }`. `202` → `{ event: { id, seq }, session: { id, status, head } }`. |
## Destinations
diff --git a/docs/agent-sessions/durability.mdx b/docs/agent-sessions/durability.mdx
index 7bdadba3..211a90bd 100644
--- a/docs/agent-sessions/durability.mdx
+++ b/docs/agent-sessions/durability.mdx
@@ -3,6 +3,15 @@ title: "Durability & resume"
description: "What survives a disconnect, an idle period, or a crash — and what doesn't"
---
+A Durable Agent Session is **never lost and always resumable** — that's the promise, and the platform holds it:
+
+- The **event log is durable forever** (the record of everything the agent did).
+- **Disconnect** → reconnect from any cursor, nothing missed.
+- The runtime **crashes or hangs** → we **restart it automatically** and it continues from where it was.
+- The session **idles** → it hibernates (≈ free) and **survives even if its sandbox is reclaimed**.
+
+The only thing not yet covered: resuming **mid-turn** across a sandbox loss (that one turn re-runs) — see [Limits](#limits).
+
## The event log is the source of truth
Every step is appended to the session's log with a monotonic `seq`. The log is durable and ordered; reads and the live stream are served from it. Anything the agent has logged or delivered is safe.
@@ -24,7 +33,15 @@ const res = await fetch(
When a session has nothing to do it goes **idle** and its sandbox **hibernates** — the VM is snapshotted and stopped. You pay storage-only while idle; **active seconds only** show up in usage. The next message (a steer, or the next turn) wakes it, typically sub-second, and it continues with prior context.
-<Note>This mirrors [sandbox hibernation](/sandboxes/timeout): idle ≈ free, fast wake. Sessions manage it for you — you don't set a timeout per turn.</Note>
+<Note>This mirrors [sandbox hibernation](/sandboxes/timeout): idle ≈ free, fast wake. Sessions manage it for you — you don't set a timeout per turn. The runtime's state is also **checkpointed off-box** at each hibernate, so an idle session resumes even if its sandbox is reclaimed.</Note>
+
+## Self-healing runtime
+
+You don't restart anything — the platform does. The runtime keeps its working state (the agent's session journal) on the sandbox, and OpenComputer recovers it for you:
+
+- **Runtime crashes** (process dies, sandbox fine) → we start it again **in the same sandbox**; it continues from its on-box journal, not from scratch.
+- **Runtime hangs** → it's detected (a turn has a max duration) and **restarted in place**.
+- **Sandbox reclaimed while idle** → we recreate it and **restore the last checkpoint**, resuming from the last completed turn.
## Limits
@@ -33,10 +50,11 @@ What's guaranteed today, and what isn't:
| Failure | What happens |
| --- | --- |
| Client disconnects | Reconnect from your cursor; nothing lost. |
-| Session idles | Sandbox hibernates; resumes on the next message. |
-| Runtime crashes mid-turn | Auto re-wakes and continues; in-flight work since the last logged event may repeat (make side effects idempotent). |
-| Sandbox is **lost** (not hibernated) | The session may re-run / re-clone. Only **logged or delivered** outputs are durable. |
+| Session idles | Sandbox hibernates; resumes on the next message (state checkpointed off-box). |
+| Runtime crashes / hangs | **Auto-restarted; continues from the on-box journal** — in-flight work since the last logged event may repeat (make side effects idempotent). |
+| Sandbox lost **while idle** | Recreated and **restored from the last checkpoint**; resumes from the last completed turn. |
+| Sandbox lost **mid-turn** | That one turn **re-runs** from the log. Only **logged / committed / delivered** work product is guaranteed. |
<Warning>
- Sessions don't **yet** do byte-exact recovery after an arbitrary sandbox or model failure — in-flight, unlogged work can be redone. Build idempotent side effects, and treat the event log (and delivered webhooks) as your durable record. Byte-exact resume is coming in a later release.
+ The one edge not yet covered: a sandbox lost **mid-turn** re-runs that turn rather than resuming mid-thought — so in-flight, unlogged work can be redone. Build idempotent side effects, and treat the event log (and delivered webhooks) as your durable record. Byte-exact **mid-turn** resume is coming in a later release.
</Warning>
diff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdx
index 60f41dc7..1f4266d4 100644
--- a/docs/agent-sessions/overview.mdx
+++ b/docs/agent-sessions/overview.mdx
@@ -3,7 +3,15 @@ title: "Durable Agent Sessions"
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.
+Give an agent a prompt and a task; OpenComputer runs it on a **fully managed runtime** 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.
+
+**You never babysit the runtime.** A session is *durable*: we keep your agent running, and recover it for you.
+
+- **Crashes or hangs?** We **restart it automatically** — it continues from where it was, mid-task, not from scratch.
+- **Idle for hours or days?** It hibernates (≈ free) and **survives even if the underlying sandbox is reclaimed** — its state is checkpointed off-box, so it wakes back up intact.
+- **Disconnect?** Reconnect from any cursor — nothing missed.
+
+That managed, self-healing runtime — not just a chat API over a model — is the point.
<Steps>
<Step title="Define an agent (with your key)">
@@ -25,13 +33,13 @@ The non-trivial parts you'd otherwise build — and get subtly wrong — handled
<CardGroup cols={2}>
<Card title="Reliable delivery" icon="paper-plane">
- Outbound messages are delivered at-least-once, retried with backoff, and dead-lettered — nothing silently dropped. Dedupe on `X-OC-Event-ID`.
+ Outbound messages are delivered at-least-once, retried with backoff, and dead-lettered — nothing silently dropped. Signed with [Standard Webhooks](https://www.standardwebhooks.com); dedupe on `webhook-id`.
</Card>
- <Card title="Managed sandbox lifecycle" icon="box">
- Provision, hibernate on idle (storage-only ≈ free), wake in milliseconds, replace an unresponsive sandbox, tear down — none of it your problem.
+ <Card title="Self-healing, managed runtime" icon="heart-pulse">
+ We keep the agent running and recover it: **auto-restart on crash or hang** (it continues from its on-box state), hibernate on idle (≈ free), and **survive sandbox loss while idle** by restoring an off-box checkpoint. Provision, wake, tear down — none of it your problem. See [durability](/agent-sessions/durability).
</Card>
<Card title="Isolated execution" icon="shield-halved">
- The agent's loop runs separately from the sandbox where its file changes and commands execute — the untrusted work is contained, apart from the loop and your model credentials.
+ The agent's loop runs separately from the sandbox where its file changes and commands execute — the untrusted work is contained, and your model key never enters a sandbox at all.
</Card>
<Card title="Durable log & resume" icon="database">
Every step is recorded in a durable event log. Reconnect from any point and the event stream resumes exactly where you left off — no events missed or duplicated.
diff --git a/docs/agent-sessions/quickstart.mdx b/docs/agent-sessions/quickstart.mdx
index 7edc0594..8756bb86 100644
--- a/docs/agent-sessions/quickstart.mdx
+++ b/docs/agent-sessions/quickstart.mdx
@@ -79,7 +79,7 @@ curl https://api.opencomputer.dev/v3/sessions/$ID/destinations \
-d '{ "url": "https://your.app/oc-webhook", "secret": "whsec_…", "level": "user" }'
```
-Deliveries are signed and retried; dedupe by `X-OC-Event-ID`. See [Webhooks](/agent-sessions/webhooks) to verify the signature and inspect deliveries.
+Deliveries are signed ([Standard Webhooks](https://www.standardwebhooks.com)) and retried; dedupe by `webhook-id`. See [Webhooks](/agent-sessions/webhooks) to verify the signature and inspect deliveries.
## Next steps
diff --git a/docs/agent-sessions/sessions.mdx b/docs/agent-sessions/sessions.mdx
index de53c821..dbd90578 100644
--- a/docs/agent-sessions/sessions.mdx
+++ b/docs/agent-sessions/sessions.mdx
@@ -12,7 +12,7 @@ A **session** is the durable unit of an [agent](/agent-sessions/agents) at work:
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.
-<Note>If the runtime crashes mid-turn it auto re-wakes and continues — but in-flight work since the last logged event may repeat, so make side effects idempotent. Details: [durability](/agent-sessions/durability).</Note>
+<Note>The runtime is **managed and self-healing**: if it crashes or hangs we restart it and it continues from its on-box state, and an idle session survives even if its sandbox is reclaimed. In-flight work since the last logged event may repeat, so make side effects idempotent. Details: [durability](/agent-sessions/durability).</Note>
## Lifecycle
diff --git a/docs/agent-sessions/webhooks.mdx b/docs/agent-sessions/webhooks.mdx
index 83b095e4..ecd72aa9 100644
--- a/docs/agent-sessions/webhooks.mdx
+++ b/docs/agent-sessions/webhooks.mdx
@@ -48,27 +48,25 @@ Delivery = { id, destination_id, event_id, status, attempts, last_attempt_at, re
## Delivery contract
- **HTTPS only.** Private, loopback, link-local, and cloud-metadata addresses are refused.
-- **At-least-once.** Retried with exponential backoff; after the max attempts a delivery is **dead-lettered** (inspect and redeliver it above). A duplicate can still arrive — a send that succeeds as the worker dies, or a replayed turn — so **dedupe on `X-OC-Event-ID`**.
-- **Correlation headers.** Every request carries `X-OC-Event-ID`, `X-OC-Delivery-ID`, and `X-OC-Session-ID` (for dedupe and correlation), plus the signature headers below.
-- **Signed.** `X-OC-Signature` = HMAC-SHA256 over `X-OC-Timestamp + "." + rawBody`, keyed by your `secret`. Verify against the **raw request body, before parsing it**. `X-OC-Timestamp` guards replay; the `secret` is write-only — set once, never returned.
+- **At-least-once.** Retried with exponential backoff; after the max attempts a delivery is **dead-lettered** (inspect and redeliver it above). A duplicate can still arrive — a send that succeeds as the worker dies, or a replayed turn — so **dedupe on `webhook-id`** (it equals the event id).
+- **Signed with [Standard Webhooks](https://www.standardwebhooks.com).** Every request carries `webhook-id`, `webhook-timestamp`, and `webhook-signature` — so you can verify with an off-the-shelf library instead of hand-rolling. `webhook-signature` = `v1,<base64(HMAC-SHA256(secret, "{webhook-id}.{webhook-timestamp}.{rawBody}"))>`. Verify against the **raw request body, before parsing it**; `webhook-timestamp` guards replay; your `secret` (`whsec_…`) is write-only — set once, never returned. Plus `X-OC-Delivery-ID` and `X-OC-Session-ID` for correlation.
- A delivery succeeds on HTTP `2xx`.
### Verify a webhook
+Use a [Standard Webhooks](https://www.standardwebhooks.com) library:
+
```js
-import { createHmac, timingSafeEqual } from "node:crypto";
-
-// body = the RAW request body string, read BEFORE JSON.parse
-function verify(req, secret, body) {
- const ts = req.headers["x-oc-timestamp"];
- const got = req.headers["x-oc-signature"];
- if (!ts || !got) return false; // missing headers → reject
- if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; // bad/stale ts → replay guard
- const expected = createHmac("sha256", secret).update(`${ts}.${body}`).digest("hex");
- let a, b;
- try { a = Buffer.from(got, "hex"); b = Buffer.from(expected, "hex"); } // decode hex explicitly
- catch { return false; } // malformed signature
- return a.length === b.length && timingSafeEqual(a, b); // constant-time compare
+import { Webhook } from "standardwebhooks";
+
+// rawBody = the RAW request body string, read BEFORE JSON.parse
+function verify(headers, rawBody, secret) {
+ // throws on a missing/expired/invalid signature
+ return new Webhook(secret).verify(rawBody, {
+ "webhook-id": headers["webhook-id"],
+ "webhook-timestamp": headers["webhook-timestamp"],
+ "webhook-signature": headers["webhook-signature"],
+ });
}
```
diff --git a/docs/docs.json b/docs/docs.json
index a899d78f..1ea46db4 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -60,6 +60,7 @@
},
{
"group": "Durable Agent Sessions",
+ "tag": "Preview",
"pages": [
"agent-sessions/overview",
"agent-sessions/quickstart",