mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-28 10:09:21 +00:00
fix(crew): bind task-only agents to crew so multimodal input_files reach the LLM
Some checks failed
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Vulnerability Scan / pip-audit (push) Has been cancelled
Some checks failed
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Vulnerability Scan / pip-audit (push) Has been cancelled
This commit is contained in:
@@ -354,9 +354,16 @@ def prepare_kickoff(
|
|||||||
crew._set_tasks_callbacks()
|
crew._set_tasks_callbacks()
|
||||||
crew._set_allow_crewai_trigger_context_for_first_task()
|
crew._set_allow_crewai_trigger_context_for_first_task()
|
||||||
|
|
||||||
|
agents_to_setup: list[BaseAgent] = list(crew.agents)
|
||||||
|
seen_agent_ids: set[int] = {id(agent) for agent in agents_to_setup}
|
||||||
|
for task in crew.tasks:
|
||||||
|
if task.agent is not None and id(task.agent) not in seen_agent_ids:
|
||||||
|
agents_to_setup.append(task.agent)
|
||||||
|
seen_agent_ids.add(id(task.agent))
|
||||||
|
|
||||||
setup_agents(
|
setup_agents(
|
||||||
crew,
|
crew,
|
||||||
crew.agents,
|
agents_to_setup,
|
||||||
crew.embedder,
|
crew.embedder,
|
||||||
crew.function_calling_llm,
|
crew.function_calling_llm,
|
||||||
crew.step_callback,
|
crew.step_callback,
|
||||||
|
|||||||
@@ -4798,6 +4798,37 @@ def test_crew_kickoff_started_emits_display_name(
|
|||||||
assert captured == [expected]
|
assert captured == [expected]
|
||||||
|
|
||||||
|
|
||||||
|
def test_prepare_kickoff_binds_task_only_agent_to_crew():
|
||||||
|
"""Agents referenced only via task.agent must get .crew set during prepare_kickoff.
|
||||||
|
|
||||||
|
Regression for crewAIInc/crewAI#5534: when Crew is built without
|
||||||
|
agents=[...], multimodal input_files were silently dropped because the
|
||||||
|
agent's .crew attribute was never assigned, gating file lookup off in
|
||||||
|
Task and CrewAgentExecutor.
|
||||||
|
"""
|
||||||
|
from crewai.crews.utils import prepare_kickoff
|
||||||
|
|
||||||
|
task_only_agent = Agent(
|
||||||
|
role="Solo",
|
||||||
|
goal="Describe inputs",
|
||||||
|
backstory="Solo agent assigned only via task.agent",
|
||||||
|
allow_delegation=False,
|
||||||
|
)
|
||||||
|
task = Task(
|
||||||
|
description="Describe the input.",
|
||||||
|
expected_output="A description.",
|
||||||
|
agent=task_only_agent,
|
||||||
|
)
|
||||||
|
crew = Crew(tasks=[task])
|
||||||
|
|
||||||
|
assert task_only_agent.crew is None
|
||||||
|
assert crew.agents == []
|
||||||
|
|
||||||
|
prepare_kickoff(crew, inputs=None)
|
||||||
|
|
||||||
|
assert task_only_agent.crew is crew
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_memory_remember_receives_task_content():
|
def test_memory_remember_receives_task_content():
|
||||||
"""With memory=True, extract_memories receives raw content with task, agent, expected output, and result."""
|
"""With memory=True, extract_memories receives raw content with task, agent, expected output, and result."""
|
||||||
|
|||||||
Reference in New Issue
Block a user