OpenAICloudflare Developer PlatformJun 5, 2026, 3:00 PM

Workflows - Rollback support now available in Workflows

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 support (per-step saga-style)

Key Points

  • Saga-style per-step rollbacks
  • Handlers run in reverse order
  • Rollback outcomes in status & analytics

Summary

Workflows now supports saga-style per-step rollbacks. You can attach a rollback handler and rollbackConfig to each step.do(...); if an instance fails, rollback handlers run in reverse step-start order. Rollbacks support retries and timeouts, their outcomes are exposed in instance status responses, and analytics emit rollback lifecycle events to help distinguish forward vs rollback failures.

Key Points

  • Add compensating logic directly to a step with the rollback option (keeps cleanup next to the step it undoes).
  • Rollbacks run in reverse step-start order and support rollbackConfig including retries (limit, delay, backoff) and timeout.
  • Rollback outcomes are visible in instance status and emitted as analytics events for clearer debugging of failures.
  • Ideal for multi-step operations touching external systems: inventory, payments, tickets, or provisioning.

Quick example (JS/TS)

Use inline options on a step: step.do("provision resource", async () => { /* produce { resourceId } */ }, { rollback: async ({ output }) => { /* deleteResource(output.resourceId) */ }, rollbackConfig: { retries: { limit: 3, delay: "15 seconds", backoff: "linear" }, timeout: "2 minutes" } }).

Actions for engineers

  • Add per-step rollback handlers for operations that require compensation.
  • Configure rollbackConfig to match expected retry behavior and timeouts for cleanup actions.
  • Monitor instance status and workflow analytics to detect and investigate rollback vs forward failures.

Refer to the Workflows rollback options in the docs for detailed configuration 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でロールバックサポートが利用可能になりました

Rollback support now available in Workflows

公開日: 2026-06-05

概要

Workflowsはsagaスタイルのロールバックをサポートするようになりました。各 step.do() に対して補償ロジック(rollbackハンドラ)を追加でき、下流の処理が失敗した場合に自動的に補償処理が実行されます。インスタンスが失敗した場合、ロールバックハンドラはステップの開始順序の逆順で実行されます。

利点とユースケース

  • 複数ステップで外部システムに触れる操作(inventory reservations、payment authorization、ticket creation、infrastructure provisioning など)に有用。
  • トップレベルの catch にすべてのクリーンアップ処理を書く代わりに、各ステップのそばにそのステップを取り消す補償アクションを置ける。
  • ロールバックハンドラは独自の retry/timeout 設定をサポート。
  • Workflows はインスタンスステータス応答でロールバックの結果を公開。
  • Workflows analytics はロールバックのライフサイクルイベントも送出するため、本番ワークフローのデバッグ時に前進実行の失敗とロールバックの失敗を区別しやすくなる。

動作のポイント

  • ロールバックは各ステップ単位で定義。
  • ロールバックはステップの出力(output)にアクセス可能で、必要に応じてその出力を使って補償処理を行う。
  • rollbackConfig でリトライやタイムアウトの挙動を設定可能。
  • ロールバック結果はインスタンスのステータスに反映され、analytics イベントとしても記録される。

使用例(JavaScript)

await step.do(
  "provision resource",
  async () => {
    const resource = await provisionResource();
    return { resourceId: resource.id };
  },
  {
    rollback: async ({ output }) => {
      const { resourceId } = output;
      await deleteResource(resourceId);
    },
    rollbackConfig: {
      retries: { limit: 3, delay: "15 seconds", backoff: "linear" },
      timeout: "2 minutes",
    },
  },
);

使用例(TypeScript)

await step.do(
  "provision resource",
  async () => {
    const resource = await provisionResource();
    return { resourceId: resource.id };
  },
  {
    rollback: async ({ output }) => {
      const { resourceId } = output as { resourceId: string };
      await deleteResource(resourceId);
    },
    rollbackConfig: {
      retries: { limit: 3, delay: "15 seconds", backoff: "linear" },
      timeout: "2 minutes",
    },
  },
);

参照

Refer to rollback options to learn more.