Repository navigation
fix(openai-compatible): keep tool call id and name when later deltas send empty strings - #815
Open
ardazeybek wants to merge 1 commit into
Open
ardazeybek wants to merge 1 commit into
ardazeybek wants to merge 1 commit into
Conversation
…send empty strings
This branch has not been deployed
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.
Some OpenAI-compatible servers send
"id": ""and"function": {"name": ""}on every continuation delta of a streamed tool call, and only fill them in on the first one. The chat-completions builder overwrote the stored values whenever the field was a string, so the empty ones won and the call ended up astool-call-0with an empty name. Replaying that history then fails with HTTP 400.The builder now only updates
idandnamewhen the new value is non-empty. Added a regression test with a first delta carrying the real id/name and two later deltas with empty ones.Possibly related to the empty tool name reports in #678, though that one looks like it is on the Anthropic path, so I'm not claiming it fixes it.
Tested:
uv run pytest tests/test_tau_ai.py -k openai_compatible, ruff check and format.