From 52aeac4b75f2ac244c61d1b7de683903f26ce996 Mon Sep 17 00:00:00 2001 From: Lorenze Jay Date: Tue, 1 Apr 2025 14:10:37 -0700 Subject: [PATCH] Remove redundant error handling for action and final answer in CrewAgentParser. Update tests to reflect this change by deleting the corresponding test case. --- src/crewai/agents/parser.py | 4 ---- tests/agents/test_crew_agent_parser.py | 7 ------- 2 files changed, 11 deletions(-) diff --git a/src/crewai/agents/parser.py b/src/crewai/agents/parser.py index 1cf05e455..58605b692 100644 --- a/src/crewai/agents/parser.py +++ b/src/crewai/agents/parser.py @@ -103,10 +103,6 @@ class CrewAgentParser: return AgentFinish(thought, final_answer, text) elif action_match: - if includes_answer: - raise OutputParserException( - f"{FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE}" - ) action = action_match.group(1) clean_action = self._clean_action(action) diff --git a/tests/agents/test_crew_agent_parser.py b/tests/agents/test_crew_agent_parser.py index 4b48e1552..18bb1d523 100644 --- a/tests/agents/test_crew_agent_parser.py +++ b/tests/agents/test_crew_agent_parser.py @@ -227,13 +227,6 @@ def test_missing_action_input_error(parser): assert "I missed the 'Action Input:' after 'Action:'." in str(exc_info.value) -def test_action_and_final_answer_error(parser): - text = "Thought: I found the information\nAction: search\nAction Input: what is the temperature in SF?\nFinal Answer: The temperature is 100 degrees" - with pytest.raises(OutputParserException) as exc_info: - parser.parse(text) - assert "both perform Action and give a Final Answer" in str(exc_info.value) - - def test_safe_repair_json(parser): invalid_json = '{"task": "Research XAI", "context": "Explainable AI", "coworker": Senior Researcher' expected_repaired_json = '{"task": "Research XAI", "context": "Explainable AI", "coworker": "Senior Researcher"}'