Skip to content

fix: tool name parsing when early chunk contains tool name as empty s…#16507

Open
KrKOo wants to merge 1 commit into
vercel:mainfrom
KrKOo:fix-tool-name-streaming
Open

fix: tool name parsing when early chunk contains tool name as empty s…#16507
KrKOo wants to merge 1 commit into
vercel:mainfrom
KrKOo:fix-tool-name-streaming

Conversation

@KrKOo

@KrKOo KrKOo commented Jun 30, 2026

Copy link
Copy Markdown

Background

Some OpenAI-compatible providers stream tool-call deltas where the first function.name value is an empty string ("") rather than undefined. The previous check only verified name != 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.doStream to also require name.length > 0 before forwarding a buffered tool-call delta. Added a regression test that streams a tool-call delta with function.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

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features) - minor fix, not needed
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant