mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-06 01:32:36 +00:00
OpenRouter-hosted thinking models (Claude Sonnet 4.5, Opus 4.5, Gemini 3 Pro Preview) can return an empty textual response when forced to produce a final answer after max_iter is reached, because the turn was spent on reasoning tokens. The prior behavior raised a raw ValueError, crashing the entire crew execution. handle_max_iterations_exceeded now returns a graceful AgentFinish using the last partial text (when available) or a descriptive fallback message. Non-string responses are coerced to strings before being passed to format_answer to avoid downstream TypeErrors. Co-Authored-By: João <joao@crewai.com>