ClaudeCloudflare Developer PlatformApr 21, 2026, 12:00 PM

Workflows - Additional step context and ReadableStream support now available in Workflows step.do()

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

claudeenmodel: claude-haiku-4-5

Workflows: Enhanced step context and ReadableStream support

Key Points

  • Step context now includes step name, invocation count, and resolved configuration
  • ReadableStream support enables handling of large payloads beyond 1 MiB limit
  • Enhanced loop support with step.count tracking for repeated step invocations

Summary

Cloudflare Workflows now provides additional context information in step.do() callbacks and supports returning ReadableStream for handling larger step outputs, enabling more flexible workflow implementations.

Key Points

  • Enhanced step context: step.do() callbacks now receive expanded context objects including:

    • step.name — The name passed to step.do()
    • step.count — Invocation count for steps with the same name (1-indexed), useful for loops
    • config — Resolved step configuration with timeout and retries including defaults
  • ReadableStream support: Steps can now return ReadableStream directly for larger payloads

    • Non-stream outputs remain limited to 1 MiB
    • Streamed outputs support significantly larger data transfers
    • Streamed outputs still count toward Workflow instance storage limits
  • Use case: Fetch and return large files directly from storage buckets without size constraints on individual steps

Full Translation

Translations

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

claudejamodel: claude-haiku-4-5

Workflows - step.do()で追加のステップコンテキストとReadableStreamサポートが利用可能に

Workflows - step.do()で追加のステップコンテキストとReadableStreamサポートが利用可能に

公開日: 2026年4月21日

カテゴリ: Workflows

Workflowsは、step.do()コールバック内で追加のコンテキストを提供し、ReadableStreamの返却をサポートするようになりました。これにより、より大きなステップ出力を処理できます。

ステップコンテキストプロパティ

step.do()コールバックは、attemptと共に新しいプロパティを含むコンテキストオブジェクトを受け取ります:

  • step.name — step.do()に渡された名前
  • step.count — このインスタンス内でその名前のステップが呼び出された回数(1から始まるインデックス)
    • ループ内で同じステップを実行する場合に便利です
  • config — タイムアウトと再試行のデフォルト値が適用された、解決されたステップ設定

TypeScript型定義

type ResolvedStepConfig = {
  retries: {
    limit: number;
    delay: WorkflowDelayDuration | number;
    backoff?: "constant" | "linear" | "exponential";
  };
  timeout: WorkflowTimeoutDuration | number;
};

type WorkflowStepContext = {
  step: {
    name: string;
    count: number;
  };
  attempt: number;
  config: ResolvedStepConfig;
};

step.do()でのReadableStreamサポート

ステップはReadableStreamを直接返すことができるようになりました。非ストリーム形式のステップ出力は1 MiBに制限されていますが、ストリーム出力はより大きなペイロードをサポートします。

使用例

const largePayload = await step.do("fetch-large-file", async () => {
  const object = await env.MY_BUCKET.get("large-file.bin");
  return object.body;
});

注意: ストリーム出力はWorkflowインスタンスストレージ制限の一部と見なされます。