Uh oh!
There was an error while loading. Please reload this page.
fix(ai): tolerate empty-string tool call id/name in streaming deltas - #37842
fix(ai): tolerate empty-string tool call id/name in streaming deltas#37842Garfier wants to merge 1 commit into
Conversation
Some OpenAI-compatible APIs (e.g. DashScope token-plan / GLM-5.2) send empty strings for id and function.name on subsequent tool call deltas instead of omitting them or sending null. The nullish coalescing operator (??) does not treat empty strings as absent, causing appendOrStart to fail with 'tool call delta is missing id or name'. Treat empty strings as absent so the accumulated identity from the first delta is preserved.
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found one potentially related PR: Related PR:
However, #33622 is not a duplicate—it addresses a different issue with a different provider. This PR (#37842) is specifically about tolerating empty strings in tool call |
Garfier
commented
Jul 20, 2026
Closing: upstream v2 already includes an equivalent fix (prefer accumulated identity over delta values). The upstream approach |
Issue for this PR
Closes#37841
Type of change
What does this PR do?
Some OpenAI-compatible APIs (e.g. DashScope token-plan / GLM-5.2) send empty strings for
idandfunction.nameon subsequent tool call deltas instead of omitting them or sendingnull.ToolStream.appendOrStartuses??(nullish coalescing) to fall back to accumulated identity from the first delta, but""is not nullish so the fallback never triggers, and!id/!namethen fails with "OpenAI Chat tool call delta is missing id or name".The fix treats empty strings as absent by using
||before??:This preserves the accumulated identity from the first delta (which does contain valid
idandname) when subsequent deltas send empty strings.How did you verify your code works?
tool-stream.test.tspass.token-plan.cn-beijing.maas.aliyuncs.com) with GLM-5.2 by curling a streaming tool call request and confirming the empty-string delta pattern.Screenshots / recordings
N/A (not a UI change)
Checklist