Skip to main content

Start a run

A run executes a script with a toolset, or a version of a workflow, for one end user.
string
The TypeScript source: one ES module whose default export is the entry point. Or give workflow instead.
string
The toolset the script imports from rewind:tools.
string
Instead of a script: "triage" for the workflow’s latest version, "triage@9f2c4e1a07b3" for one version. The input is checked against its input schema.
unknown
default:"{}"
The argument of main: any JSON value.
Duration
Wait up to this long for the run to end. The run is returned as it is then: ended, or still active with what it waits for. Without it, the call returns once the run is created, before it ran.
string
A request repeated with the same key returns the run the first one started, instead of starting another.
Record<string, string>
Your metadata: the agent, the conversation, the environment. Labels filter runs in the API and the dashboard, scope list_runs, keys and tokens limited to labels, and webhook subscriptions. The script never sees them.
string
The W3C trace context of the caller, typically the LLM call that wrote the script: the run appears under it in your traces. tracestate too.
Duration
default:"30d"
The run’s time to live: it is cancelled at its deadline. Bounded by the end user’s maxTtl.
boolean
default:"true"
Type-check the script before starting it. A refused script throws RewindApiError with the slug invalid-script and its diagnostics. A workflow’s script is not checked again.
Credentials
The run’s own credentials, used instead of its namespace’s and its toolset’s.

Read a run

Values (input, output, tool arguments and results) are payloads: { digest, bytes, preview, value }. A value larger than 256 KiB is left out; read it with rewind.payloads.get(digest).

Follow a run live

events is an async iterator over the run’s journal entries as they are committed. A dropped connection resumes after the last entry received.

The trace, for a model or a human

trace returns the run as a model reads it: each event with its line, its outcome and its timing.

Search runs

Runs are searched with the query language, the same as the dashboard’s query bar and the CLI.
Filters also exist as parameters: status, labels, tool, script, error, workflow, startedBy, parent, quarantined. A query that cannot be read is refused with invalid-query, and the error says where the term at fault is.

Cancel a run

Every pending await of the script rejects with CancelledError, and the script gets one activation to clean up.

Fork a run with a corrected script

A fork reuses the parent’s recorded results while the corrected script makes the same calls, then continues live: the calls already made are not made again. This is what the agent tool retry_run does.
The fork has its own id and TTL, and its parent’s seed, input, toolset and namespace. The fork’s parent names the run it came from.

Export a run

Quarantine and deletion

A run whose replay diverged from its journal, or whose activations failed 5 times in a row, is quarantined (run.quarantine says why). It is not failed: fix the cause, then release it, or give it up.