Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

⚡️ Speed up method `CrewAgentParser._clean_action` by 427,565% (#2382)

Saurabh Misrad3a09c3180e8
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 = ['""', "{}"]