Fixes#4036 - Models with native function calling (like Ollama) fail when
the model returns tool_calls but no available_functions are provided.
Previously, when a model returned tool_calls without text content and no
available_functions were provided, the raw tool_calls list was returned.
This list would then cause a "'list' object has no attribute 'rstrip'"
error when passed to format_message_for_llm().
Now, tool_calls are converted to a human-readable string representation
containing the tool name and arguments. This allows the agent to see what
tool the model wanted to call and handle it through text-based parsing.
Changes:
- Modified _handle_non_streaming_response to convert tool_calls to string
- Modified _ahandle_non_streaming_response with the same fix
- Added warning log when this conversion occurs
- Added tests covering the fix for both sync and async paths
Co-Authored-By: João <joao@crewai.com>