mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
This commit fixes issue #3771 where format_answer() was catching all exceptions including OutputParserError and converting them to AgentFinish, which prevented the retry logic in _invoke_loop() from working correctly. Changes: - Modified format_answer() in agent_utils.py to specifically catch and re-raise OutputParserError, allowing the retry logic to handle malformed LLM outputs properly - Added comprehensive tests in test_agent_utils.py to verify the fix and prevent regressions The fix ensures that when an LLM returns malformed output (e.g., missing colons in the Action/Action Input format), the agent will retry with an error message instead of immediately returning an AgentFinish with the malformed text. Co-Authored-By: João <joao@crewai.com>