An open-source, faster Devin alternative
TypeScript
docs: the stopping status, how a cancelled turn settled, and command timeouts
Igor Zalutskib1d1d27ee27b
diff --git a/docs/agents/api.mdx b/docs/agents/api.mdxindex c97efd2e..6f3b2079 100644--- a/docs/agents/api.mdx+++ b/docs/agents/api.mdx@@ -110,7 +110,7 @@ insufficient_credits`.| `id`, `agentId`, `deploymentId` | The session and the deployment it pins || `projectId` | The project the agent belongs to || `environment` | `development` or `production`, when the request named one |-| `status` | `new`, `connecting`, `idle`, `running`, `waiting_runtime`, `suspending`, `suspended`, `resuming`, `failed` or `ended` |+| `status` | `new`, `connecting`, `idle`, `running`, `stopping`, `waiting_runtime`, `suspending`, `suspended`, `resuming`, `failed` or `ended` || `source` | The `source` given at creation || `labels`, `labelsUpdatedAt` | Your metadata, and when it last changed; see [Labels](#labels) || `memory` | Bindings with `resource`, `scope`, `id`, `access` and `writable`; present when the session was created with bindings |@@ -188,8 +188,14 @@ revocation was not acknowledged; retry, orended session returns it unchanged.`POST /sessions/<id>/interrupt` stops the running turn without spending a-model turn. The turn settles as `cancelled` with reason `interrupted`, the-runtime is told to stop, and the next queued turn starts. An idle session is+model turn. The response shows the session as `stopping` with the turn still+`running`: the model loop is stopped, and every command the turn had started+on its computer is stopped before the turn settles. The turn then settles as+`cancelled` with reason `interrupted`, the session returns to `idle` and the+next queued turn starts. A command that cannot be confirmed stopped is+resolved by replacing the computer, and the turn settles once the+replacement is confirmed; the turn's `turn.cancelled` event records how the+stop settled ([Session events](/agents/events#turns)). An idle session isreturned unchanged.## Turnsdiff --git a/docs/agents/events.mdx b/docs/agents/events.mdxindex 83bca79d..c4cd68ac 100644--- a/docs/agents/events.mdx+++ b/docs/agents/events.mdx@@ -43,10 +43,15 @@ unknown type as informational and keep reading.| Type | When | `data` || --- | --- | --- || `session.created` | The session exists. Always the first event. | `agentId`, `deploymentId` |-| `session.status_changed` | The session moved between `new`, `connecting`, `idle`, `running`, `waiting_runtime`, `suspending`, `suspended`, `resuming`, `failed` and `ended` | `from`, `to` |+| `session.status_changed` | The session moved between `new`, `connecting`, `idle`, `running`, `stopping`, `waiting_runtime`, `suspending`, `suspended`, `resuming`, `failed` and `ended` | `from`, `to` || `session.ended` | The owner ended the session. Queued and running turns were cancelled and memory writes revoked. | none || `session.failed` | The session cannot continue | `code`, `message`: a [public failure](#public-failures) |+`stopping` follows an [interrupt](/agents/api#end-and-interrupt) or an+interrupt-mode turn: the session stays there until the stopped turn's+commands are confirmed stopped or its computer is replaced, then `idle`+follows and the next turn starts.+### Turns| Type | When | `data` |@@ -58,7 +63,7 @@ unknown type as informational and keep reading.| `turn.started` | The runtime began the turn | none || `turn.completed` | The turn finished and the session is idle again | none || `turn.failed` | The turn stopped with an error | `code`, `message`, and `model` or `tool` when named: a [public failure](#public-failures) |-| `turn.cancelled` | The turn was stopped by an interrupt | `reason`: `interrupted`; `replacementTurnId` when an interrupt-mode turn replaced it |+| `turn.cancelled` | The turn was stopped by an interrupt, once the work it had started was stopped | `reason`: `interrupted`; `replacementTurnId` when an interrupt-mode turn replaced it; `settledAfterMs`: how long after the interrupt the turn settled; `operationsSettled`: how many commands were stopped; `computerTerminated`: `true` when a command could not be confirmed stopped and the computer was replaced |#### Public failuresdiff --git a/docs/agents/tools.mdx b/docs/agents/tools.mdxindex 440e2983..a0afc0e1 100644--- a/docs/agents/tools.mdx+++ b/docs/agents/tools.mdx@@ -283,6 +283,21 @@ person agreed to, whether or not the session that proposed it still exists.A tool that waits needs a conversation to ask in. Called from the playground,a schedule or a webhook, there is nobody to ask, and the call fails saying so.+## Computer commands++Every session runs on its own computer, and the model runs commands on it+through the built-in `shell` tool. A command runs in the session's workspace+and takes `command` and an optional `timeoutSeconds`: 120 by default, at+most 1800, and never more than the computer's remaining lifetime allows; a+value out of range fails the call before anything runs. A command is not+started on a computer that cannot host it for its full timeout; a fresh+computer is used instead.++When the timeout passes, the command and every process it started are+stopped, and the call fails as a tool error the model sees: it names the+command and the timeout and carries the output so far. The turn continues,+and files the command wrote before it was stopped remain.+## Tools versus skills and MCP- A tool executes TypeScript you own.diff --git a/sdks/typescript/src/managed-agents/types.ts b/sdks/typescript/src/managed-agents/types.tsindex 03d856f2..54795ab2 100644--- a/sdks/typescript/src/managed-agents/types.ts+++ b/sdks/typescript/src/managed-agents/types.ts@@ -260,7 +260,19 @@ export type SessionEvent =| (EventBase & { type: "turn.started"; data: Record<string, never> })| (EventBase & { type: "turn.completed"; data: Record<string, never> })| (EventBase & { type: "turn.failed"; data: Failure })- | (EventBase & { type: "turn.cancelled"; data: { reason: "interrupted" | (string & {}); replacementTurnId?: string } })+ | (EventBase & {+ type: "turn.cancelled";+ data: {+ reason: "interrupted" | (string & {});+ replacementTurnId?: string;+ /** How long after the interrupt the turn settled, once the commands it had started were stopped (per design 1c07584, backend in flight). */+ settledAfterMs?: number;+ /** How many commands were stopped for the turn to settle. */+ operationsSettled?: number;+ /** `true` when a command could not be confirmed stopped and the computer was replaced. */+ computerTerminated?: boolean;+ };+ })| (EventBase & { type: "message.delta"; data: { text: string } })| (EventBase & { type: "message.completed"; data: { text: string } })| (EventBase & { type: "reasoning.delta"; data: { text: string } })