fix: tool name parsing when early chunk contains tool name as empty s…#16507
Open
KrKOo wants to merge 1 commit into
Open
fix: tool name parsing when early chunk contains tool name as empty s…#16507KrKOo wants to merge 1 commit into
KrKOo wants to merge 1 commit into
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.
Background
Some OpenAI-compatible providers stream tool-call deltas where the first
function.namevalue is an empty string ("") rather than undefined. The previous check only verifiedname != null, so an empty name was treated as valid and forwarded to the tool-call tracker prematurely. This caused the tracker to emit a tool-call with an empty name and lose the buffered arguments that arrived before the real name was streamed.Summary
Updated the tool-call delta handling in
OpenAICompatibleChatLanguageModel.doStreamto also requirename.length > 0before forwarding a buffered tool-call delta. Added a regression test that streams a tool-call delta withfunction.name: ""followed by the delta containing the real name; the test fails without the fix because the tracker receives an empty name and incomplete arguments.Manual Verification
Command-a model running on VLLM returns the problematic format of stream. After the implementation of the fix, the tool name gets parsed correctly
Checklist
pnpm changesetin the project root)