#21800·ai

WorkflowAgent: a stream part over 10 MiB (e.g. a code_interpreter result) fails doStreamStep; no hook to trim parts before the writable

Author: bruchrisCreated Sep 29, 2026Updated Sep 30, 2026
Labelstask-identify-issue-type-donetask-bug-reproduction-successfactory-activefactory-automatictask-identify-harness-labels-done

Summary

On Vercel World, one ModelCallStreamPart over 10 MiB fails the whole model step of a WorkflowAgent. doStreamStep writes every part it receives to the writable unchanged. When a part is large, the durable stream write is rejected, and there is no hook to shrink or omit the part first.

In our case the large parts are provider-executed tool results: an OpenAI code_interpreter result of 14–18 MB, returned while the model works on a large file in its container.

Observed

The step fails with FatalError. Its cause is a rejected stream write:

PUT https://vercel-workflow.com/api/v2/runs/<run>/stream/<stream>  → 400
{"error":"bad-request","message":"… size 17909807 exceeds maximum allowed size of 10485760 bytes"}

doStreamStep has maxRetries: 0, so the run surfaces this as a failed model call. The step's own data would have been fine; only the trace write is over the limit.

Where

  • src/do-stream-step.ts: inside the for await (const part of modelStream) loop, every part except tool-approval-request goes to await writer.write(part) as is. tool-result parts with providerExecuted: true are included.
  • src/workflow-agent.ts: experimental_transform is declared on the stream options ("Optional stream transformations"), but as far as we can see it is never applied, so it can't be used to trim parts before they reach the writable.

Both points are the same in 2.0.17 (which we run) and in 2.0.53.

Expected

Any of these would work for us:

  1. Apply experimental_transform (or a similar per-part hook) before parts reach the writable.
  2. Keep an oversized part out of the UI stream, for example by replacing its output with a marker, while the step result keeps the full part for the conversation.
  3. Split parts over the World's chunk limit.

Workaround we use

A pnpm patch of dist/index.js: before writer.write(part), a part whose approximate serialized size is over 4 MiB is replaced. For a tool-result or tool-error, the output (or error) becomes { type: 'omitted', reason: 'too_large_for_trace' }; any other part is skipped. The step's aggregates keep the full part.

Versions

  • @ai-sdk/workflow 2.0.17 (also checked 2.0.53)
  • workflow 5.0.0-beta.42, Vercel World
  • Model: an OpenAI Responses model through the AI Gateway, with the provider-executed code_interpreter tool