mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-09 05:06:55 +00:00
504c70f4e0
When using the Responses API (e.g., Azure gpt-5.1-codex-mini), the response.completed event was always returning finish_reason='stop', even when the response contained function_call items in its output. This caused agents like OpenCode to incorrectly conclude the stream ended without tools to execute, breaking tool/function calling workflows. The fix inspects the response.output field in the response.completed event to determine the correct finish_reason: - 'tool_calls' when output contains function_call items - 'stop' otherwise (text-only responses) Added tests to verify: - response.completed with function_call output returns finish_reason='tool_calls' - response.completed with message-only output returns finish_reason='stop' - response.completed with empty output returns finish_reason='stop' (backward compat) Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>