OpenAICloudflare 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.

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

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

Key Points

  • Extended step context: name, count, config, attempt
  • step.do() can return ReadableStream for large outputs
  • Streamed outputs still count toward workflow storage limit

Summary

Workflows' step.do() callbacks now receive an extended context object (including step.name, step.count, config, and attempt) and can return ReadableStream results to handle much larger outputs. Non-stream outputs remain limited to 1 MiB; streamed outputs support larger payloads but still count toward the Workflow instance storage limit.

Key Points

  • New context object passed to step.do(stepName, callback) includes:
    • step.name: the name passed to the step
    • step.count: how many times that step name has been invoked in this instance (1-indexed)
    • config: resolved step configuration (retries, timeout with defaults applied)
    • attempt: current attempt number
  • step.do() can return a ReadableStream directly to stream large outputs beyond the 1 MiB non-stream limit.
  • Streamed outputs are still part of the Workflow instance storage limit; plan storage usage accordingly.
  • TypeScript types are provided (e.g. ResolvedStepConfig, WorkflowStepContext) for safer typing.

Example

Inline example calling a bucket and returning a stream: const largePayload = await step.do("fetch-large-file", async () => (await env.MY_BUCKET.get("large-file.bin")).body);

Recommended actions

  • Use step.count to distinguish repeated step invocations in loops.
  • Return ReadableStream from steps when handling large files to avoid the 1 MiB non-stream limit.
  • Monitor workflow storage usage since streams still consume instance storage.

Full Translation

Translations

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

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

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

概要

Workflows の step.do() コールバックに、既存の attempt に加えて追加のコンテキストが渡されるようになりました。また、ステップから ReadableStream を直接返せるようになり、大きな出力をストリームで処理できるようになりました。

Step コンテキストのプロパティ

step.do() コールバックは以下のプロパティを含むコンテキストオブジェクトを受け取ります(従来の attempt も引き続き存在します)。

  • step.namestep.do() に渡した名前
  • step.count — このインスタンス内で同じ名前のステップが何回呼び出されたか(1-indexed)。ループで同じステップを複数回実行する場合に便利です。
  • config — タイムアウトやリトライを含む、デフォルトが適用された解決済みのステップ設定
  • attempt — 現在の試行回数

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;
};

ReadableStream のサポート

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

例(TypeScript)

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

注意: ストリーム化された出力は依然として Workflow インスタンスのストレージ制限の一部として扱われます。


ご不明点や詳細はドキュメント/ヘルプセンターをご参照ください。

Workflows - Additional step context and ReadableStream support now available in Workflows step.do() | Cloudflare Developer Platform | DocsDigest