Skip to content

fix(openai-compatible): keep tool call id and name when later deltas send empty strings - #815

Open
ardazeybek wants to merge 1 commit into
huggingface:mainfrom
ardazeybek:fix/chat-tool-call-empty-deltas
Open

ardazeybek wants to merge 1 commit into
huggingface:mainfrom
ardazeybek:fix/chat-tool-call-empty-deltas

Conversation

@ardazeybek

Copy link
Copy Markdown

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 as tool-call-0 with an empty name. Replaying that history then fails with HTTP 400.

The builder now only updates id and name when 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.

This branch has not been deployed

No deployments
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