[BUG] Crew planning sees only the first knowledge source of an agent
维护者通常 1 天内回复
评估
调研方向
The bug is in _create_tasks_summary() in lib/crewai/src/crewai/utilities/planning_handler.py, where only knowledge_list[0] is embedded in the planner prompt. Run the reproduction script from the issue and check whether "second fact" appears in the summary. Note that pull request #9720 is already open against this issue, so review it before starting. Done means every knowledge source appears in the summary and quotes or newlines in the text are escaped.
由索引模型根据 Issue 内容生成。
描述
Description
CrewPlanner._create_tasks_summary() reads every knowledge source from an agent, then embeds only the first one in the planner prompt:
lib/crewai/src/crewai/utilities/planning_handler.py:140-163
def _create_tasks_summary(self) -> str:
tasks_summary = []
for idx, task in enumerate(self.tasks):
knowledge_list = self._get_agent_knowledge(task)
agent_tools = (
f"[{', '.join(str(tool) for tool in task.agent.tools)}]"
if task.agent and task.agent.tools
else '"agent has no tools"',
f',\n "agent_knowledge": "[\\"{knowledge_list[0]}\\"]"'
if knowledge_list and str(knowledge_list) != "None"
else "",
)
task_summary = f"""
...
"agent_tools": {"".join(agent_tools)}"""
knowledge_list[0] is the only source that reaches the planner. When an agent has two or more knowledge_sources, the rest are dropped without a warning, so the plan is made without context the executor will actually have.
The value is also interpolated unescaped. A source containing a double quote or a newline breaks the "agent_knowledge" value that the surrounding prompt presents as JSON.
Steps to Reproduce
from crewai import Agent, Task
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
from crewai.utilities.planning_handler import CrewPlanner
agent = Agent(
role="Researcher",
goal="Research",
backstory="Backstory",
knowledge_sources=[
StringKnowledgeSource(content="first fact"),
StringKnowledgeSource(content="second fact"),
],
)
task = Task(
description="Explain the topic",
expected_output="An explanation",
agent=agent,
)
summary = CrewPlanner([task], None)._create_tasks_summary()
print("second fact" in summary)
Output on current main:
False
Expected Behavior
Both sources are present in the summary, and their text is escaped so quotes and newlines cannot corrupt it, for example:
"agent_knowledge": ["first fact", "second fact"]
AI assistance
I used an AI coding agent to investigate, reproduce, and prepare this report, and reviewed its results. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors cannot add it with my current permissions.
- 主要语言
- Python
- 星标
- 61.2k
- 派生
- 9.2k
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 180
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
crewAIInc/crewAI 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM provider可能已有人在做 @HashimSyedUBC 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[BUG] Native Azure provider ignores the seed setting可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
crewAIInc/crewAI#9787 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
bug harness
难度 2/5 1-3 小时 新手友好度 72/100
mruangutai/harness#2687 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
modal-labs/modal-client#4158 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 72/100
The-Swarm-Corporation/swarms-rs#168 ·
维护者通常 1 天内回复
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373未关闭
难度 2/5 1-3 小时 新手友好度 72/100
linuxserver/docker-healthchecks#137 · 1 条评论 ·