fix: reply never finishes when streaming is off and the model calls a tool (#32083)

With Stream Chat Response turned off, a reply where the model called a tool was never saved or marked as finished, so the chat kept showing it as still generating until the page was reloaded. The reply is now saved and finished like any other non-streamed reply. Tools themselves still only run with streaming on, as the docs describe.
This commit is contained in:
Classic298 2026-10-08 19:00:49 +02:00 • committed by GitHub
parent 93fc3fcb72
commit b687225123
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4179,12 +4179,14 @@ async def non_streaming_chat_response_handler(response, ctx):
choices = response_data.get('choices', [])
response_output = response_data.get('output')
content = choices[0].get('message', {}).get('content') if choices else ''
content = (choices[0].get('message', {}).get('content') or '') if choices else ''
# Native tools only run on the streaming path; still finish the turn.
tool_calls = choices[0].get('message', {}).get('tool_calls') if choices else None
if (continuing and 'error' not in response_data) or (
not continuing and choices and (content or response_output)
not continuing and choices and (content or response_output or tool_calls)
):
if content or response_output or continuing:
if content or response_output or tool_calls or continuing:
if not continuing:
await event_emitter(
{