[BUG] Crew planning sees only the first knowledge source of an agent

Đang mở
#9,719 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Kiko0301 đang làm issue này rồi.

Từ ngày 24/11/2026.

  • #9720 của @Kiko0301 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
ai

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
61.2k
Fork
9.2k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
180

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của crewAIInc/crewAI

Tất cả issue của crewAIInc/crewAI

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.