Files
crewAI/lib
Devin AI b065a45dda Fix #5537: Gracefully handle empty LLM response on forced final answer
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>
2026-04-20 01:50:09 +00:00
..