Repository navigation
Fixes to reasoning-0 not found error - #12055
Merged
Merged
Conversation
Removed afterSwitch to handle case when </think> happens without initial <think>. isFirstReasoning should be toggled correctly in `publish` if a valid thinking block exists Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
aayush-kapoor
left a comment
Collaborator
There was a problem hiding this comment.
please add unit tests to simulate the bug so that we can verify this fixes it.
also add a changeset file. look into our contributing guidelines for more info
Contributor
Author
|
I have pushed a unit test to test if |
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| 'ai': minor | |||
Collaborator
There was a problem hiding this comment.
for future changes, please only do a 'patch' change
Contributor
Author
There was a problem hiding this comment.
Got it, thanks!
aayush-kapoor
approved these changes
Jan 30, 2026
1 task done
turnerburchard
added a commit
to turnerburchard/ai
that referenced
this pull request
Mar 5, 2026
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
1 of 2 tasks
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.
Background
This change is necessary due to the issue #12054, more details are included there.
Summary
I added a check to determine if
reasoning-startas already been emitted. Whenreasoning-starthas not emitted,activeExtraction.isFirstReasoning && activeExtraction.afterSwitchwill betrue, so I have used that as a check to determine if areasoning-startevent needs to be sent.reasoning-0will then be created and the subsequentreasoning-endwill not trigger an error.Manual Verification
After my changes, no thinking blocks will be displayed (for OpenCode) and the error is resolved. The sample script I used for setting up a mock LLM server is located at this gist.
Checklist
pnpm changesetin the project root)Please advise if additional tests and documentation are needed for this change.
Future Work
My implementation assumes
startWithReasoningis initialised asfalse. I have yet to test there are any breaking changes ifstartWithReasoningis `true.Related Issues
#12054