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.

Pr branch (#2312)

Vidit Ostwala2f3566cd98d
diff --git a/src/crewai/cli/utils.py b/src/crewai/cli/utils.py
index 8912036db..078afec60 100644
--- a/src/crewai/cli/utils.py
+++ b/src/crewai/cli/utils.py
@@ -273,11 +273,9 @@ def get_crew(crew_path: str = "crew.py", require: bool = False) -> Crew | None:
for attr_name in dir(module):
attr = getattr(module, attr_name)
try:
- if isinstance(attr, Crew) and hasattr(attr, "kickoff"):
- print(
- f"Found valid crew object in attribute '{attr_name}' at {crew_os_path}."
- )
- return attr
+ if callable(attr) and hasattr(attr, "crew"):
+ crew_instance = attr().crew()
+ return crew_instance
except Exception as e:
print(f"Error processing attribute {attr_name}: {e}")
diff --git a/src/crewai/crew.py b/src/crewai/crew.py
index 76cae613e..f1c33f637 100644
--- a/src/crewai/crew.py
+++ b/src/crewai/crew.py
@@ -1399,12 +1399,12 @@ class Crew(BaseModel):
RuntimeError: If the specified memory system fails to reset
"""
reset_functions = {
- "long": (self._long_term_memory, "long term"),
- "short": (self._short_term_memory, "short term"),
- "entity": (self._entity_memory, "entity"),
- "knowledge": (self.knowledge, "knowledge"),
- "kickoff_outputs": (self._task_output_handler, "task output"),
- "external": (self._external_memory, "external"),
+ "long": (getattr(self, "_long_term_memory", None), "long term"),
+ "short": (getattr(self, "_short_term_memory", None), "short term"),
+ "entity": (getattr(self, "_entity_memory", None), "entity"),
+ "knowledge": (getattr(self, "knowledge", None), "knowledge"),
+ "kickoff_outputs": (getattr(self, "_task_output_handler", None), "task output"),
+ "external": (getattr(self, "_external_memory", None), "external"),
}
memory_system, name = reset_functions[memory_type]