Great question. Assuming Prefect 3.x:
- The retry “attempt” counter (StateDetails.run_count) is incremented when the next attempt actually starts — i.e., when the run enters Running. Merely transitioning to AwaitingRetry (e.g., from Failed → AwaitingRetry) does not increment it.
- Practically: Failed → AwaitingRetry → Scheduled → Running. The increment happens on that final step (when the new attempt begins).
Manual retries:
- Manually triggering a retry (UI/API) schedules another attempt. When that attempt starts (enters Running), run_count increments — so it does count against the max_retries budget used by the orchestrator to decide whether to auto-retry again.
- You can still manually retry even after max_retries are exhausted; however, automatic retries will no longer be scheduled by the policy once the limit is reached.
References:
-
States in Prefect 3
-
Retries how-to