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.

Fixed the issue 2123 around memory command with CLI (#2155)

Vidit Ostwalac9f8b9d5a0d
diff --git a/docs/concepts/memory.mdx b/docs/concepts/memory.mdx
index ae65db290..298e8814c 100644
--- a/docs/concepts/memory.mdx
+++ b/docs/concepts/memory.mdx
@@ -506,7 +506,7 @@ my_crew = Crew(
)
```
-### Resetting Memory
+### Resetting Memory via cli
```shell
crewai reset-memories [OPTIONS]
@@ -520,8 +520,46 @@ crewai reset-memories [OPTIONS]
| `-s`, `--short` | Reset SHORT TERM memory. | Flag (boolean) | False |
| `-e`, `--entities` | Reset ENTITIES memory. | Flag (boolean) | False |
| `-k`, `--kickoff-outputs` | Reset LATEST KICKOFF TASK OUTPUTS. | Flag (boolean) | False |
+| `-kn`, `--knowledge` | Reset KNOWLEDEGE storage | Flag (boolean) | False |
| `-a`, `--all` | Reset ALL memories. | Flag (boolean) | False |
+Note: To use the cli command you need to have your crew in a file called crew.py in the same directory.
+
+
+
+
+### Resetting Memory via crew object
+
+```python
+
+my_crew = Crew(
+ agents=[...],
+ tasks=[...],
+ process=Process.sequential,
+ memory=True,
+ verbose=True,
+ embedder={
+ "provider": "custom",
+ "config": {
+ "embedder": CustomEmbedder()
+ }
+ }
+)
+
+my_crew.reset_memories(command_type = 'all') # Resets all the memory
+```
+
+#### Resetting Memory Options
+
+| Command Type | Description |
+| :----------------- | :------------------------------- |
+| `long` | Reset LONG TERM memory. |
+| `short` | Reset SHORT TERM memory. |
+| `entities` | Reset ENTITIES memory. |
+| `kickoff_outputs` | Reset LATEST KICKOFF TASK OUTPUTS. |
+| `knowledge` | Reset KNOWLEDGE memory. |
+| `all` | Reset ALL memories. |
+
## Benefits of Using CrewAI's Memory System
diff --git a/src/crewai/cli/utils.py b/src/crewai/cli/utils.py
index 60eb2488a..8912036db 100644
--- a/src/crewai/cli/utils.py
+++ b/src/crewai/cli/utils.py
@@ -257,11 +257,11 @@ def get_crew(crew_path: str = "crew.py", require: bool = False) -> Crew | None:
import os
for root, _, files in os.walk("."):
- if "crew.py" in files:
- crew_path = os.path.join(root, "crew.py")
+ if crew_path in files:
+ crew_os_path = os.path.join(root, crew_path)
try:
spec = importlib.util.spec_from_file_location(
- "crew_module", crew_path
+ "crew_module", crew_os_path
)
if not spec or not spec.loader:
continue
@@ -273,9 +273,11 @@ 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 callable(attr) and hasattr(attr, "crew"):
- crew_instance = attr().crew()
- return crew_instance
+ if isinstance(attr, Crew) and hasattr(attr, "kickoff"):
+ print(
+ f"Found valid crew object in attribute '{attr_name}' at {crew_os_path}."
+ )
+ return attr
except Exception as e:
print(f"Error processing attribute {attr_name}: {e}")