From 4747a8263abf589644455ff0ebcd295c257610ce Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 12:54:33 +0000 Subject: [PATCH] fix: streaming handler returns tool_calls when available_functions is None MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors _handle_non_streaming_response's explicit path: when tool_calls exist but available_functions is None, return the tool_calls to the caller instead of returning an empty full_response string. Co-Authored-By: João --- lib/crewai/src/crewai/llm.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/crewai/src/crewai/llm.py b/lib/crewai/src/crewai/llm.py index a404ac5ef..aa600708c 100644 --- a/lib/crewai/src/crewai/llm.py +++ b/lib/crewai/src/crewai/llm.py @@ -967,6 +967,12 @@ class LLM(BaseLLM): self._track_token_usage_internal(usage_info) self._handle_streaming_callbacks(callbacks, usage_info, last_chunk) + # If there are tool calls but no available functions, return them + # so the caller (e.g., executor) can handle tool execution. + # This mirrors _handle_non_streaming_response's explicit path. + if tool_calls and not available_functions: + return tool_calls + if not tool_calls or not available_functions: # Only use InternalInstructor for structured output when there # are no tools — otherwise tools would be silently discarded.