OpenAICloudflare Developer PlatformMar 6, 2026, 12:00 PM

Workflows, Workers - Workflow steps now expose retry attempt number via step context

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Workflow steps now expose retry attempt number via step context

Key Points

  • ctx.attempt exposed in step context
  • attempt number is 1-indexed
  • use for logging, backoff, conditional logic

Summary

Cloudflare Workflows now exposes the current retry attempt number on each step's context for calls to step.do(). Inside your step handler use ctx.attempt to get the attempt number (1-indexed).

Key Points

  • Access the attempt number via ctx.attempt in await step.do("my-step", async (ctx) => { ... }).
  • ctx.attempt is 1 on the first try, 2 on the first retry, etc.
  • Use cases: improved logging and observability, progressive backoff strategies, or conditional logic based on attempt count.
  • Practical: ensure handlers are idempotent and review the Workflows "Sleeping and Retrying" docs for retry semantics and limits.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

Workflows、Workers — ワークフローのステップが step コンテキストでリトライ試行回数を公開するようになりました

Workflows、Workers — ワークフローのステップが step コンテキストでリトライ試行回数を公開するようになりました

概要

Cloudflare Workflows では、ワークフロー実行内の各ステップに対して個別のリトライロジックを設定できます。今回、step.do() 呼び出し内で現在実行中のリトライ試行番号(attempt)にアクセスできるようになりました。

使用例(TypeScript)

次のように ctx.attempt を参照することで、現在の試行回数を取得できます。

await step.do("my-step", async (ctx) => {
  // ctx.attempt は最初の試行で 1、最初のリトライで 2、... となります
  console.log(`Attempt ${ctx.attempt}`);
});

利用シナリオ

  • ロギングと可観測性(どの試行で失敗・成功したかを明示)
  • プログレッシブバックオフ(試行回数に応じた待機時間の調整)
  • 条件付きロジック(特定の試行回数のときのみ別処理を行う)

注意: 現在の試行番号は 1-indexed(最初の試行が 1)です。

詳細

リトライの挙動については、Sleeping and Retrying を参照してください。