Retry

Last updated on October 28, 2026

You can control how many times TofuPilot retries a phase when the phase asks for a retry. By default, TofuPilot allows up to 3 retry attempts.

main:
  - name: Network Connect
    python: phases/network
    retry: 
      limit: 5
      delay: 1s

Triggers

TofuPilot only retries phases when:

  1. The phase calls phase.retry() from Python
  2. You configure a next action using then: to retry on specific outcomes (e.g., then: fail: retry or then: error: retry)

The retry does not happen automatically on failure or measurement validation errors: you must explicitly trigger it.

Phases that depend on a retried phase wait until its last attempt completes. A retried phase can read the measurements of its own previous attempt, see Previous Attempt.

Limit

The limit specifies how many retry attempts are allowed after the initial execution. For example, limit: 3 means up to 3 retries after the first attempt (4 total attempts). limit is required, from 1 to 10; delay is optional, at most 1h.

When Retries Run Out

The last attempt keeps its outcome: FAIL for a phase.retry() or a failed measurement, ERROR or TIMEOUT for a then: error: retry or then: timeout: retry that never recovered. That failure then takes the normal next action: the run stops under on_first_failure: stop and continues under on_first_failure: continue.

In a setup phase, the retries run first; only an exhausted retry cancels the run.

Delay

You can add an optional delay between retry attempts using human-readable format: ms (milliseconds), s (seconds), m (minutes), h (hours).

Dashboard Visibility

All retry attempts are preserved and uploaded to the dashboard. Each phase stores a retry_count field (0 = first attempt, 1 = first retry, etc.) so you can see exactly how many attempts were needed.

In the run detail view, retried phases display a retry badge and an expandable tab view showing each attempt with its own measurements, outcome, and duration.

How is this guide?

On this page