[ai] Reduce doStreamStep step boundary payload#1932
Draft
VaguelySerious wants to merge 1 commit intomainfrom
Draft
[ai] Reduce doStreamStep step boundary payload#1932VaguelySerious wants to merge 1 commit intomainfrom
VaguelySerious wants to merge 1 commit intomainfrom
Conversation
Move chunksToStep out of the step boundary, returning minimal raw aggregates (text, reasoning, files, sources, warnings, response metadata, finishReason, usage, providerMetadata) and reconstructing the full StepResult in streamTextIterator (workflow context). Also drops the separate `finish` field from the return — its data was fully duplicated by the StepResult fields the caller already needed. The user-facing StepResult exposed via `onStepFinish` and `steps[]` is unchanged. The event-log payload no longer carries: - StepResult's redundant tool-call lists (`dynamicToolCalls`, `staticToolCalls`, `staticToolResults`, `dynamicToolResults`) - The always-empty `toolResults` and `response.messages` arrays - The duplicate `content` and `reasoningText` aggregates - The dual base64 + Uint8Array file encoding (now expanded only after crossing the boundary) - `request.body` (a JSON dump of the input prompt the caller already has) and `finish` (its fields all appear on `step`) Closes #1929. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
🦋 Changeset detectedLatest commit: 8dbc11a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🧪 E2E Test Results✅ All tests passed Summary
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
✅ 📋 Other
|
Contributor
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
workflow with 1 step💻 Local Development
▲ Production (Vercel)
workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
workflow with 10 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 25 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 50 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 10 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 25 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
workflow with 50 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
stream pipeline with 5 transform steps (1MB)💻 Local Development
▲ Production (Vercel)
10 parallel streams (1MB each)💻 Local Development
▲ Production (Vercel)
fan-out fan-in 10 streams (1MB each)💻 Local Development
▲ Production (Vercel)
SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
❌ Some benchmark jobs failed:
Check the workflow run for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chunksToStepout of thedoStreamStepstep boundary. The step now returns minimal raw aggregates (text,reasoning,files,sources,warnings,responseMetadata,rawFinishReason,usage,providerMetadata); the fullStepResultis reconstructed instreamTextIterator(workflow context) viabuildStepResult.finishfield from the return — every field it carried was already on the reconstructedStepResult.StepResultexposed viaonStepFinishandresult.steps[]is unchanged. The reduction is purely in the durable execution event log.What's no longer crossing the boundary:
StepResult's redundant tool-call lists (dynamicToolCalls,staticToolCalls,staticToolResults,dynamicToolResults)toolResultsandresponse.messagescontentandreasoningTextaggregatesbase64 + Uint8Arrayfile encoding (expanded only after the boundary)request.body(a JSON dump of the input prompt the caller already has)finish(itsfinishReason,usage,providerMetadataalready onstep)Internally, the V3
chunks[]array inside the step is also gone — fields are aggregated directly during the streaming transform.Closes #1929.
Test plan
pnpm --filter @workflow/ai test— 187 passing, including updated mocks fordo-stream-step.test.tsandstream-text-iterator.test.tspnpm --filter @workflow/ai build— clean tscStepResultshape is identical)🤖 Generated with Claude Code