shiftlabs Start free
Menu Runs and steps

Runs and steps

A run is one execution of a workflow, on the version that was current when it arrived. Each step runs once and keeps its result, so a run can sleep, wait and resume.

What starts a run

Each run records its origin. Filter by it with GET /v1/runs?origin=, or by Started by on the Runs screen.

  • trigger

    A delivery to a trigger URL, or a replay or test event on the trigger. See Deploy and triggers. GET /v1/runs/:id gives the trigger's name as trigger_name, null until it has one.

  • api · dashboard · mcp

    POST /v1/workflows/:workflow/runs with an API key or shiftlabs run, Run now in the dashboard, or MCP's run_workflow.

  • schedule

    A schedule's tick.

  • workflow

    step.start or step.call in another run.

  • agent

    An agent's workflow tool.

  • rerun

    A re-run of an earlier run, with its version and payload, or on its workflow's current version, or with another payload. A payload is kept 14 days, so an older run's re-run gets 410. That holds for a Pro run still running after 14 days too: its code still has the payload, but a re-run and its /payload get 410. A run still waiting to start keeps its payload until it starts.

  • resume

    A failed run resumed from one of its steps, with its payload, on its version or its workflow's current one: the steps before that one return what they returned in the failed run.

  • continue

    A keyed run's next run, which the run before it started as it continued as new, with the state it handed on as its payload, on its workflow's current version.

origin_ref says who: an email or API key id, the parent run, the schedule's name, the agent and its conversation, or the run that continued as new. A run stays on the version that was current when it arrived, even after a redeploy or a release.

Statuses

A run is queued, then running, sleeping or waiting, until it ends completed, failed, cancelled or terminated. Someone can pause it in between.

  • queued

    Not started yet. queued_reason is concurrency while it waits for its workflow's concurrency, or paused while its workflow is paused.

  • running

    Its code is running.

  • sleeping

    In a step.sleep, or waiting for an agent or another run. sleeping_until gives a sleep's end.

  • waiting

    Waiting for an approval or an event. waiting_for names it: { kind, name, since, until }, where kind is approval or event and until is when it times out. GET /v1/runs?status=waiting lists these runs.

  • paused

    Someone paused it, and it holds where it is until they unpause it. paused_by says who.

  • completed

    The function returned. GET /v1/runs/:id shows what it returned as instance.output, as soon as the run reads completed, for as long as the run is kept, 35 days after it ended. See Output.

  • failed

    A step ran out of retries, a FatalError was thrown, code outside a step threw, or the run reached a limit. error says why. Where it reads errored, error_message in GET /v1/runs gives the message the code threw, its first 1 KiB, and instance.error.message in GET /v1/runs/:id all of it. failed_step in GET /v1/runs/:id names the step it threw from, {step, occurrence, kind}, while its step results are kept for resume; it's null when code outside a step threw. When the function threw, its completed steps with an undo are undone first.

  • cancelled · terminated

    Someone stopped it. See Stop a run. A started run that is cancelled first runs its workflow's onCancel, and with undo its undo handlers. Until that cleanup ends, the cancel answers cancelling, stop_requested is cancel, and cleanup_at says when the cleanup began, null when none ran.

Output

What a completed run returned is instance.output in GET /v1/runs/:id, the run's page in the dashboard, runs.get in the clients and MCP's get_run. q finds a run by text in it.

  • Workflows holds a run's output for 7 days after the run ends. shiftlabs also keeps a copy with the run, 35 days after the end, so q can search it and the run reads back with its output after Workflows has let it go.
  • That copy is the output's JSON with readable secrets replaced by [redacted], up to 64 KiB. Of a longer output it keeps the first 64 KiB, cut at a character. Once only that copy is left, or for a moment as the run ends, the run reads instance.outputTruncated, {bytes, text}, in place of instance.output: the whole output's size as JSON, and the start of its JSON. The dashboard shows it marked as cut. Return what you'll need later in full under 64 KiB, or store it yourself.
  • A workspace keeps up to 16 MiB of these copies, counting 64 bytes a run on top of each copy: about 60,000 runs that return a couple of hundred bytes. Past that the oldest go first, and such a run is no longer found by its output and reads back with it only while Workflows still has it.

Steps

A step is a named unit of work. step.run runs its function once and stores the result. Each time the run resumes, after a sleep, a wait or a retry, your function starts again from the top: each step returns its stored result, and code outside steps runs again. In the refund-check example, the charge is fetched once, and after the 10-minute sleep the run gets it from storage.

Rules that keep runs correct

  • Put side effects inside steps: requests that change something, and anything that reads the clock or a random number.
  • A resumed run answers each step from storage by its name and how often the run has called that name. Code that calls other steps on a resume runs them again. Test a workflow catches it.
  • state works only inside step.run. See State.
  • step.idempotencyKey(name) is the same on every retry and resume of the run. See Idempotency keys.

Retries and timeouts

A step that throws is tried again, on the same version. Without retries, it gets 5 more tries, 10 seconds apart and doubling. When the tries run out, step.run throws the last error, and uncaught, it fails the run.

  • FatalError

    Fails the step and the run at once, with no more tries.

  • timeout

    An attempt that runs past it fails. Default 10 minutes.

  • Counting

    Each try counts toward the run's steps, so a retry is one more step; the wait before it isn't one. In a run started before 3 November 2026, a step.run counts once however often it is retried. The guide Rate limits and retries retries another API's 429.

  • Retry now

    While a step waits to try again, Retry now on the run's page, or POST /v1/runs/:id/retry, starts its next try at once.

Limits on a run

The limits below are the same on Free and Pro unless they say otherwise. See Limits for every value.

  • A run must end within 168 hours (7 days) of arriving on Free, and 720 hours (30 days) on Pro. Past that, it fails, also while it sleeps, with an error that starts limit runLifetimeHours=168 on Free. A Pro run that arrived before Pro's lifetime went to 30 days keeps 168 hours. A run's page shows when its lifetime ends while it runs, and GET /v1/runs/:id returns it as lifetime_ends_at.
  • A run executes at most 100 steps on Free and 1,000 on Pro. A step answered from storage, a retry, a sleep or a wait doesn't count.
  • The engine dispatches a run at most 50 times: to start it, and each time it resumes.
  • Each dispatch gets 2,000 ms of CPU time, and a run 10 seconds in all on Free, 60 on Pro.

Find runs

Narrow the list by when runs were queued, find one by its id or by text, and filter on tags: the business keys your workflow gives each run, such as a customer or an order.

  • Status

    GET /v1/runs?status=failed&status=terminated lists the runs in any of the statuses given: repeat status for each. A run that ended any other way than completed, cancelled or terminated lists as failed. An unknown status answers 400.

  • Time range

    GET /v1/runs?since=&until= takes runs queued at or after since and before until, each in milliseconds or ISO 8601. Bulk cancel and re-run, the export and shiftlabs runs --since 24h take them too.

  • Search keys

    workflow({ search: { customer: "customer.id" } }) tags every run with the value at that path of its payload when it arrives: a string, a number or true/false; anything else gives no tag. Up to 10 keys a version, checked when you deploy. A re-run keeps the original's version, so its tags too. See Tags.

  • step.tag

    await step.tag({ stage: "shipped" }) adds tags as the run goes, outside step.run; a newer value replaces an older one. A resumed run's repeated calls write nothing. Not a step, so it doesn't count toward a run's steps.

  • Tag filters

    GET /v1/runs?tag.customer=cus_42 lists the runs carrying every tag given, up to 10. Bulk cancel and re-run take "tags": {"customer": "cus_42"}. Each run lists its tags.

  • Keys

    GET /v1/runs?workflow=&key= lists a keyed workflow's runs of one key, as do shiftlabs runs --workflow <name> --key <key> and MCP's list_runs. Each run lists its key, null for a run without one.

  • Search

    q finds a run whose id starts with it, at any age once it has 8 characters of the id, or text in its error, such as the message its code threw, its output as JSON (the first 64 KiB, while it's kept), its tags and, for a developer or admin, its payload, when that is at most 96 KiB as JSON. Case is ignored.

  • Search pages

    A page searches the runs after its cursor, newest first, in windows: 5,000 runs for text, fewer once their outputs and payloads add up to 8 MiB, or 1,000 runs carrying the first tag.

  • Short pages

    A filtered page fills from up to 4 windows, then stops. When it stops short of limit, even empty, it answers "partial": true with nextBefore set: the next page carries on from the last run looked at. nextBefore is null only when no more runs match. "scoped": true says your API key sees only some workflows, whose runs alone it lists.

  • A run holds at most 20 tags, its search keys included: a call that would give it a 21st throws a run has at most 20 tags: <name> would be its 21st. Names are 1 to 64 letters, digits, - and _; values are 1 to 256 bytes.
  • Tags are kept with their run, 35 days after it ends, so a search key's value outlasts the payload's 14 days, and anyone who can see runs sees it, viewers too, who can't read payloads. Keep secrets and personal data out of tags: step.tag replaces readable secrets with [redacted], and a search key keeps the payload's value as it is.

Follow a run

  • Dashboard

    The Runs screen filters by status, workflow, Started by, time range and tags, searches by id and text, and keeps the filters you use as saved views in your browser. A failed run shows the message its code threw, and a waiting run what it waits for. A run's page shows its tags, its timeline with each step's attempts and waits, outbound requests, logs and payload, with Re-run, Cancel run and Terminate run, Pause run while it runs, Retry now while a step waits to retry, and Resume from the step a failed run failed at. While a run goes on, its page shows each log line as it reaches the logs. A run waiting for an approval shows the request, which approvers answer there with Approve or Deny and a note. Anyone else who can see the run sees the request and how many approvals it has, but not who may answer, who answered or their note.

  • API

    GET /v1/runs and GET /v1/runs/:id, and each run's /timeline, /logs, /logs/stream and /egress. /payload needs a developer key. See API reference.

  • CLI

    shiftlabs runs lists runs, shiftlabs logs <run-id> prints a run's logs, and shiftlabs run <workflow> starts one. See Commands.

  • Kept

    A run is kept 35 days after it ends.

Timeline

A run's timeline lists its dispatches, its lifecycle events and each attempt of each step, in time order. The run's page draws the steps as a waterfall: a lane per step call and a bar per attempt or wait, with the delay before each retry to scale and long idle stretches cut short.

  • Steps

    GET /v1/runs/:id/timeline gives each attempt of a step, and each sleep or wait, as a row with kind step: name, step_kind (the call: run, sleep, waitForEvent, exec and the others, or undo), seq (which call of that name, from 1), attempt, outcome (ok, failed, waiting or timed out), timestamp (when it began) and wall_ms (how long it took). A failed attempt has its message as error, the first 300 characters with readable secrets as [redacted], and delay_ms, the wait planned before the next attempt.

  • Waits

    A sleep ends at its deadline. An event or approval that came while the run slept ends its wait when the run started again.

  • Limits

    A run's first 200 step calls are listed. Of a step's failed attempts that were retried, the first three are; its last attempt and the one that succeeded always are. Steps and events are kept 35 days after they happen, dispatches 14. A run's completed or failed event can arrive a minute or two after the run ended, when Cloudflare reports its last dispatch late.

Logs

GET /v1/runs/:id/logs gives what a run's code printed, oldest first: each line's timestamp, invocation_id (which dispatch or command printed it), seq (its place there), level, message, step and arrived_ms (when it reached the logs).

  • Pages

    500 lines a page, and limit takes up to 2,000. The Next-After header names the page's last line: send it back as ?after= for the lines after it. A page shorter than limit holds every line so far. While the run goes on, ask again later with the same cursor for the lines that came since.

  • Late lines

    A dispatch's lines arrive once it ends, and a command's output as the command prints it, so a line can arrive behind a cursor you already have. Once a run has ended and its lines are in, paging from the first page gives every line once, in order.

  • New lines

    arrived_ms is when the line reached the logs, in milliseconds since the Unix epoch, or 0 for a line from before shiftlabs kept it. A page without ?after= also has a Log-Watermark header: the latest arrived_ms in the run's logs when that page was read, or 0 for a run with no lines yet. A line whose arrived_ms is above it reached the logs after that read, wherever it sorts, and a line at or below it had reached them before. Pages with ?after= have no Log-Watermark. Rarely, a line that reached the logs just before the read isn't readable until just after it.

  • Step

    step is the name of the step whose function printed the line, with log, console or Python's print: in a step started inside another step's function the inner one, and undo <name> in an undo. A command's output has the name of the step.exec that ran it, and an activity's the label of its step.activity: shiftlabs sets those, not your code. It's null outside every step, while two steps run at once, since the logs can't tell which of them printed the line, for exceptions, for lines of a version deployed before 7 November 2026: deploy it again for step, and for a command's or activity's output from before 7 November 2026. Your code can print what marks a step, so treat the step of a line your code printed as a label, not as proof of where it came from.

Stream a run's logs

GET /v1/runs/:id/logs/stream sends a run's logs as Server-Sent Events, oldest first. Each event is one data: line with a JSON array of the lines that came since the last event, each as GET /v1/runs/:id/logs gives it, and its id is the cursor of the furthest line sent so far, the same cursor as Next-After.

shellcurl
# -N prints each event as it arrives; the stream ends once the run has ended and its lines are in.
curl -N https://api.shiftlabs.org/v1/runs/<run>/logs/stream \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"
  • Lines come as they reach the logs: a dispatch's once the dispatch ends, a command's output as the command prints it. The stream reads every 2 seconds. While no new lines come, the same read is answered from the 10-second cache GET /v1/runs/:id/logs uses, so a line that reaches the logs after a quiet spell can take up to 12 seconds to come.
  • After a dropped connection, reconnect with Last-Event-ID set to the last event's id, as a browser's EventSource does: the stream goes on after that line, so each line comes once. A Next-After works too, to stream on from a page you read. A Last-Event-ID that isn't a log cursor gets 400 {"error": "invalid cursor"}.
  • A line can reach the logs behind lines already sent, such as one your code printed outside a step, which arrives once its dispatch ends. The stream sends it in a later event, unless it's behind the last 500 lines this connection sent, or behind the Last-Event-ID the connection started from. Sort by timestamp, invocation_id and seq to show lines in order. A line the stream left out is in GET /v1/runs/:id/logs.
  • Once the run has ended, the stream waits 90 seconds for its last lines, which can arrive a minute after the run ends. Its last event then has the id end, and the stream closes. Reconnecting with Last-Event-ID: end gets 204, which stops a browser's EventSource. A line that arrives after that is only in GET /v1/runs/:id/logs.
  • A stream also ends after 5 minutes: reconnect to go on. While nothing comes, a comment line comes every 20 seconds.
  • A log stream counts toward the 60 streams a workspace opens a minute, with status streams: the next gets 429 with Retry-After. Each of its reads the cache doesn't answer counts toward the workspace's 120 reads a minute of run logs, timelines, egress and metrics: about 30 a minute while lines keep coming, and about 6 while none do, so four busy streams use them all. A read past them sends an event limited with {"retryAfter": 60} and no id, and the stream closes: EventSource waits 60 seconds, then goes on after the last line it got.
  • A browser's EventSource can't send the authorization header. Read the stream with fetch, or an SSE client that sends headers.

Reference