Repository navigation
fix(ai): handle missing reasoning-start in streamText eventProcessor - #13110
Open
turnerburchard wants to merge 4 commits into
Open
turnerburchard wants to merge 4 commits into
turnerburchard wants to merge 4 commits into
Conversation
When a provider emits reasoning-delta or reasoning-end events without a preceding reasoning-start (e.g. OpenAI Responses API with empty or malformed reasoning blocks), the eventProcessor now auto-creates the reasoning entry instead of emitting an error that terminates the stream. This is the same class of bug fixed in vercel#12055 for extractReasoningMiddleware, but in a different code path. Fixes vercel#12054
|
Running into this with opus 4.7 and amazon bedrock |
This branch has not been deployed
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
When a provider emits
reasoning-deltaorreasoning-endstream events without a precedingreasoning-start, theeventProcessorinstreamTextnow auto-creates the reasoning entry instead of emitting an error event that terminates the stream.This is the same class of bug fixed in #12055 for
extractReasoningMiddleware, but in theeventProcessorTransformStream insidestreamText.Context
We hit this with OpenAI's Responses API (
reasoningSummary: 'auto') — on a trivial input, the API intermittently sentreasoning-deltaevents without a precedingreasoning-start, producing repeated errors:Changes
stream-text.ts: Whenreasoning-deltaorreasoning-endarrives without an active reasoning entry, auto-create one (matching the approach from Fixes to reasoning-0 not found error #12055) instead of emitting an errorstream-text.test.ts: Two new test cases covering both scenariosTest plan
Relates to #12054