From 813db960458753a9e743ed0d10d7c1fd052c88c6 Mon Sep 17 00:00:00 2001 From: Houyun Sun <18763177732@139.com> Date: Wed, 28 Oct 2026 16:14:53 +0800 Subject: [PATCH] fix(streaming): report tool_calls when an openai-compatible stream ends with stop Non-streaming rewrites a "stop" to "tool_calls" whenever the response carries tool calls (convert_dict_to_response). The stream only did it through finish_reason_handler, and that is reached for providers that end on a separate empty chunk. For openai/azure compatible chunks the finish chunk goes through the received_finish_reason branch, which returns the chunk as-is, so the upstream "stop" reached the caller unchanged. Two things were off: - the branch above returned before the tool_call flag could be used - the flag itself is only set from completion_obj["tool_calls"], which openai-compatible chunks never fill; their tool calls sit on the delta Now the delta is checked as well, and the same stop -> tool_calls rewrite is applied in the received_finish_reason branch. length and content_filter are left alone, same as the non-streaming path. Fixes #48716