Fix issue #2233: Add support for task-specific knowledge

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-26 04:03:20 +00:00
parent 34d2993456
commit b524855e22
4 changed files with 69 additions and 0 deletions

View File

@@ -207,6 +207,17 @@ class Agent(BaseAgent):
if memory.strip() != "":
task_prompt += self.i18n.slice("memory").format(memory=memory)
# Check if the task has knowledge first
if hasattr(task, 'knowledge') and task.knowledge:
task_knowledge_snippets = task.knowledge.query([task.prompt()])
if task_knowledge_snippets:
task_knowledge_context = extract_knowledge_context(
task_knowledge_snippets
)
if task_knowledge_context:
task_prompt += task_knowledge_context
# Then check agent's knowledge
if self.knowledge:
agent_knowledge_snippets = self.knowledge.query([task.prompt()])
if agent_knowledge_snippets:
@@ -216,6 +227,7 @@ class Agent(BaseAgent):
if agent_knowledge_context:
task_prompt += agent_knowledge_context
# Finally check crew's knowledge
if self.crew:
knowledge_snippets = self.crew.query_knowledge([task.prompt()])
if knowledge_snippets: