[BUG] Hierarchical crew fails on its second kickoff: manager_llm crashes, manager_agent delegates to itself
Description
A hierarchical crew only works on its first kickoff(). Anything that runs the same crew again breaks: a second
kickoff()/akickoff(), copy().kickoff() after a run, kickoff_for_each() after a run, and every
train(n_iterations > 1) (it calls kickoff() repeatedly on one copy).
With manager_llm, the first run stores the manager it built, with its delegation tools, in crew.manager_agent.
The next run sees a manager that has tools and raises Exception: Manager agent should not have tools.
With manager_agent, the first run assigns the manager to each task without an agent. On the next run
_update_manager_tools treats the manager as the task's worker, so the only coworker the manager can delegate
to is itself and delegation silently stops working.
This was reported before for training (#2131) and in a flow (#1851); both were closed without a fix.
Steps to Reproduce
- Build a hierarchical crew with one worker agent and
manager_llm=...(ormanager_agent=...). - Run
crew.kickoff()once. It works and the manager delegates to the worker. - Run
crew.kickoff()again on the same crew.
Expected behavior
Every run behaves like the first: no exception, and the manager can delegate to the crew's worker agents.
Screenshots/Code snippets
import json
from typing import Any
from crewai import Agent, Crew, Process, Task
from crewai.llms.base_llm import BaseLLM
class ScriptedLLM(BaseLLM):
def __init__(self, *replies: str) -> None:
super().__init__(model="offline")
self.replies = replies
self.calls = 0
def supports_function_calling(self) -> bool:
return False
def call(self, messages: Any, **kwargs: Any) -> str:
reply = self.replies[self.calls % len(self.replies)]
self.calls += 1
return reply
async def acall(self, messages: Any, **kwargs: Any) -> str:
return self.call(messages, **kwargs)
delegate = json.dumps({"task": "Write a word", "context": "None", "coworker": "Writer"})
manager_llm = ScriptedLLM(
f"Thought: Delegate\nAction: Delegate work to coworker\nAction Input: {delegate}",
"Thought: Done\nFinal Answer: hello",
)
worker_llm = ScriptedLLM("Thought: Done\nFinal Answer: hello")
writer = Agent(role="Writer", goal="Write", backstory="Writes", llm=worker_llm)
task = Task(description="Get a word", expected_output="A word")
crew = Crew(agents=[writer], tasks=[task], process=Process.hierarchical, manager_llm=manager_llm)
for run in (1, 2):
print(run, crew.kickoff().raw, "worker calls:", worker_llm.calls)
Operating System: Other (specify in additional context) Python Version: 3.12 crewAI Version: 1.15.28 (main @ a8877f0cd) crewAI Tools Version: N/A (not used in the repro) Virtual Environment: Venv
Operating System
macOS Monterey
Python Version
3.12
crewAI Version
crewAI Version: 1.15.28 (main @ a8877f0cd)
crewAI Tools Version
N/A (not used in the repro)
Virtual Environment
Venv
Evidence
1 hello worker calls: 1
Traceback (most recent call last):
...
Exception: Manager agent should not have tools
With manager_agent=Agent(role="Boss", ...) instead of manager_llm, both runs return, but on run 2 the
delegation tool lists only "Boss" as a coworker, the worker is never called, and worker calls stays at 1.
Possible Solution
In _create_manager_agent, only reject tools that are not the crew's own delegation tools (BaseAgentTool).
In _update_manager_tools, don't treat the manager as the task's worker when it is the agent left on the task
by the previous run.
Additional context
macOS 26. Reproduced on Python 3.13 with a uv-managed venv (3.13 is not in the version dropdown).