Bug in tool invocation for native function calling with Anthropic/Claude

I am using Crewai 1.9.3. I suspect the issue is present in current 1.10.x as well.

My issue is that I was unable to invoke tools when using Claude Opus 4.5. It was always returning responses like:

[ToolUseBlock(id=‘toolu_01Fsjgx8uZ2MAHE5pi6BQ1dW’, input={‘text’: ‘…’, ‘search_params’: {}, ‘endpoint_’: {}}, name=‘my_function’, type=‘tool_use’, caller={‘type’: ‘direct’}), ToolUseBlock(id=‘toolu_01ECrhtNPvDLiXbxCFkHDLrB’, input={‘text’: ‘…’, ‘search_params’: {}, ‘endpoint_’: {}}, name=‘my_function’, type=‘tool_use’, caller={‘type’: ‘direct’})]

I had Claude Code debug it for me and it identified the bug as summarized below:

The issue was in CrewAI’s get_llm_response() function in crewai/utilities/agent_utils.py. When processing LLM responses through _setup_after_llm_call_hooks(), any response that isn’t a BaseModel gets converted to a string via str(answer) (line 1018). This converted Anthropic’s ToolUseBlock list to a string like “[ToolUseBlock(id=‘…’, name=‘…’)]” instead of keeping the structured objects.

I hope someone from CrewAI dev team fixes this or lets me know if there is any other solution to the issue.