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.

fix: handle optional storage with null checks (#1808)

devin-ai-integration[bot]2433819c4f56
diff --git a/src/crewai/knowledge/knowledge.py b/src/crewai/knowledge/knowledge.py
index 571542994..c964333c8 100644
--- a/src/crewai/knowledge/knowledge.py
+++ b/src/crewai/knowledge/knowledge.py
@@ -49,8 +49,13 @@ class Knowledge(BaseModel):
"""
Query across all knowledge sources to find the most relevant information.
Returns the top_k most relevant chunks.
+
+ Raises:
+ ValueError: If storage is not initialized.
"""
-
+ if self.storage is None:
+ raise ValueError("Storage is not initialized.")
+
results = self.storage.search(
query,
limit,