Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
agent: improve knowledge naming (#2041)
Nicolas Lorine6100debac0f
diff --git a/src/crewai/agent.py b/src/crewai/agent.pyindex dec0effd7..a222995c6 100644--- a/src/crewai/agent.py+++ b/src/crewai/agent.py@@ -1,3 +1,4 @@+import reimport shutilimport subprocessfrom typing import Any, Dict, List, Literal, Optional, Union@@ -153,7 +154,8 @@ class Agent(BaseAgent):def _set_knowledge(self):try:if self.knowledge_sources:- knowledge_agent_name = f"{self.role.replace(' ', '_')}"+ full_pattern = re.compile(r'[^a-zA-Z0-9\-_\r\n]|(\.\.)')+ knowledge_agent_name = f"{re.sub(full_pattern, '_', self.role)}"if isinstance(self.knowledge_sources, list) and all(isinstance(k, BaseKnowledgeSource) for k in self.knowledge_sources):