fix(ai): support streams without finish reasons - #40965
Open
rekram1-node wants to merge 1 commit into
Open
Conversation
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
compatibility.requireFinishReason, preserving strict behavior when unset ortrueunknownterminal finish after non-empty clean EOF when the option isfalseunknownBehavior
For
requireFinishReason: false, a non-empty stream that ends without a terminal reason completes withstep-finishandfinishevents whose normalized reason isunknown. OpenAI Chat finalizes valid and malformed local tool inputs before emitting that finish. Core continuation remains content-driven, so valid local tools execute and cause the next model step without requiring a synthesizedtool-callsreason.Testing
packages/ai:bun typecheckpackages/core:bun typecheckpackages/core:bun test test/session-runner.test.ts(144 pass)packages/aisuite: 481 pass, 28 skipped, 4 unrelated base failuresgit diff --checkThe existing full AI suite failures are Azure URL expectations with a duplicated
/v1and stale OpenRouter recorded request bodies expecting nousageoption; neither path is changed by this PR.