From d3a09c3180e86fc1d73492660627f0a39e6d4b2c Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Fri, 21 Mar 2025 10:51:14 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20method=20`Cre?= =?UTF-8?q?wAgentParser.=5Fclean=5Faction`=20by=20427,565%=20(#2382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here is the optimized version of the program. Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/agents/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crewai/agents/parser.py b/src/crewai/agents/parser.py index 05c5bc003..88a869c16 100644 --- a/src/crewai/agents/parser.py +++ b/src/crewai/agents/parser.py @@ -136,7 +136,7 @@ class CrewAgentParser: def _clean_action(self, text: str) -> str: """Clean action string by removing non-essential formatting characters.""" - return re.sub(r"^\s*\*+\s*|\s*\*+\s*$", "", text).strip() + return text.strip().strip("*").strip() def _safe_repair_json(self, tool_input: str) -> str: UNABLE_TO_REPAIR_JSON_RESULTS = ['""', "{}"]