OpenAICloudflare Developer PlatformJun 23, 2026, 12:00 PM

Workflows - Workflows rollback handlers now include 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

Workflows rollback handlers now include step context

Key Points

  • ctx provides step metadata to rollback handlers
  • rollbackConfig controls rollback retries and timeout
  • output and error are passed to rollback for recovery

Summary

Workflows rollback handlers now receive the original step context via a ctx object for the step being rolled back. The ctx includes ctx.step.name, ctx.step.count, ctx.attempt, and the resolved step configuration (defaults applied). The step's rollbackConfig controls retries and timeout for the rollback handler itself.

Key Points

  • Rollback handler signature receives { ctx, output, error }. Use output to access the step's returned value when undoing side effects.
  • ctx exposes step metadata: ctx.step.name, ctx.step.count, ctx.attempt, and the step config (including retry and timeout settings). Use these to customize recovery behavior.
  • rollbackConfig on a step defines retry behavior and timeout for the rollback (e.g., retries.limit, retries.delay, retries.backoff, timeout).
  • Practical usage: include step name and error in rollback reason, adjust retry/backoff based on ctx.attempt, and inspect configured timeouts to avoid long-running rollbacks.

Refer to the Workflows rollback options docs for full API details and examples.

Full Translation

Translations

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

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

Workflows - ロールバックハンドラーにステップコンテキストが含まれるようになりました

Workflows — ロールバックハンドラーにステップコンテキストが含まれるようになりました

公開日: 2026-06-23

Workflows は、下流システムが失敗した際にも回復可能な信頼性の高いマルチステップアプリケーションを構築しやすくするための機能です。今回の更新により、ロールバックハンドラーはロールバック対象のステップに対応する元のステップコンテキストを ctx オブジェクトとして受け取るようになりました。

主な変更点:

  • ロールバックハンドラーで受け取る ctx には次の情報が含まれます:
    • ctx.step.name
    • ctx.step.count
    • ctx.attempt
    • デフォルトが適用されたステップの設定(step config)
  • ステップ設定には当該ステップで使用された再試行(retry)およびタイムアウト(timeout)の設定が含まれるため、それらのフィールドに応じてステップの回復ロジックをカスタマイズできます。

TypeScript の例:

await step.do("create charge", async () => {
    const charge = await createCharge();
    return { chargeId: charge.id };
}, {
    rollback: async ({ ctx, output, error }) => {
        // `output` はロールバック対象のステップが返した値です。
        const { chargeId } = output as { chargeId: string };
        await refundCharge(chargeId, {
            // `ctx` は元のステップコンテキスト(step name, count, attempt, config を含む)です。
            reason: `${ctx.step.name}: ${error.message}`,
        });
    },
    rollbackConfig: {
        // `rollbackConfig` はロールバックハンドラーの再試行やタイムアウトを制御します。
        retries: { limit: 3, delay: "30 seconds", backoff: "linear" },
        timeout: "5 minutes",
    },
});

詳細は rollback options を参照してください。