From 66eaf2744a74671060781d72bf99c94393badce1 Mon Sep 17 00:00:00 2001 From: Brandon Hancock Date: Tue, 18 Feb 2025 15:17:59 -0500 Subject: [PATCH] clean up thoughts as well --- src/crewai/agents/parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crewai/agents/parser.py b/src/crewai/agents/parser.py index 4041a5ee6..7dd3ba8e7 100644 --- a/src/crewai/agents/parser.py +++ b/src/crewai/agents/parser.py @@ -122,7 +122,10 @@ class CrewAgentParser: regex = r"(.*?)(?:\n\nAction|\n\nFinal Answer)" thought_match = re.search(regex, text, re.DOTALL) if thought_match: - return thought_match.group(1).strip() + thought = thought_match.group(1).strip() + # Remove any triple backticks from the thought string + thought = thought.replace("```", "").strip() + return thought return "" def _clean_action(self, text: str) -> str: