mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-07 08:27:05 +00:00
fix: normalize a tool call name sent as null (#29690)
Some endpoints stream a tool call whose function name is JSON null instead of a string. Nothing normalized it, so the null stayed on the tool call, was written into the stored message, and was sent back to the endpoint in the assistant message on the next turn, where a null is not a valid function name. The delta accumulator now replaces a null name with an empty string, at the same point it already normalizes the arguments field. The call still fails as an unknown tool, which is the right outcome for a call that has no name, so the result is one failed tool call instead of a follow-up request the endpoint has to reject. This is done where the delta enters the accumulator rather than at the consumers, because the name is emitted to the client and persisted while the response is still streaming, before anything downstream could clean it up. Checked against 1261 streaming delta sequences: behaviour is unchanged except where the delta that creates the tool call carries a null name. Seen in #29686 with a custom sglang build.
This commit is contained in:
parent
3361a972b3
commit
66e021a926
1 changed files with 2 additions and 1 deletions
|
|
@ -5008,7 +5008,8 @@ async def streaming_chat_response_handler(response, ctx):
|
|||
if current_response_tool_call is None:
|
||||
# Add the new tool call
|
||||
delta_tool_call.setdefault('function', {})
|
||||
delta_tool_call['function'].setdefault('name', '')
|
||||
if delta_tool_call['function'].get('name') is None:
|
||||
delta_tool_call['function']['name'] = ''
|
||||
delta_tool_call['id'] = delta_tool_call.get('id') or output_id('fc')
|
||||
delta_arguments = delta_tool_call['function'].get('arguments')
|
||||
if not isinstance(delta_arguments, str):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue