WorkflowRun

retry()

run.retry(stepId?) → Promise<WorkflowRun>

Runs the chain again from a step — the failed one by default. Everything before it is kept, and the replaced attempt is kept too.

from the failureearlier outputs keptattempts are recorded
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

await run.retry();            // from whichever step failed
await run.retry("transform");  // from a chosen step
run.retry()               # from whichever step failed
run.retry("transform")    # from a chosen step

What is kept

  • Every step before the one you restart from, with its output — nothing is recomputed.
  • The replaced attempt, moved into that step's attempts.
  • The run's identifier: it is the same run, continued.
Not recomputing the earlier steps is the point

A chain that failed at step five has already paid for four. Re-running the whole thing would pay again and could repeat an effect — a second message, a second write.

What it is for

  • A transient failure — a service that was briefly down.
  • A fixed configuration: change the workflow, then retry the run against the new definition.
  • A step whose input was wrong, once whatever produced it is corrected.

When it is refused

CodeWhen
run_not_retryableThe run is still going, or a step before the one chosen did not succeed.

The second half of that is the useful guard: restarting from step five when step four failed would run five on something that never happened.

Effects are repeated, not resumed

A retried step does its work again

If a storage write succeeded and a later step failed, retrying from the write writes twice. Choose the step to restart from with that in mind — the default, the failed one, is usually right for exactly this reason.