crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Unexpected Exception: Manager agent should not have tools

Open leungmanhin opened this issue 1 year ago • 5 comments

I'm using the latest version of crewai and crewai-tools in a Colab notebook, and my manager agent do not have tools, in fact none of my agents have. The exact same code can run successfully without this exception and then fail with it in the next run, and I'll have to re-create my crew in order to successfully run the same code again. It feels like sometimes somehow a tool got equipped to my manager agent during kickoff()?

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
[<ipython-input-13-1d2bf6638f8c>](https://localhost:8080/#) in <cell line: 3>()
      2 
----> 3 discuss_result = discuss_crew.kickoff(
      4     inputs = {
      5         "test_case": test_case

[/usr/local/lib/python3.10/dist-packages/crewai/crew.py](https://localhost:8080/#) in _run_hierarchical_process(self)
    471             manager = self.manager_agent
    472             if manager.tools is not None and len(manager.tools) > 0:
--> 473                 raise Exception("Manager agent should not have tools")
    474             manager.tools = self.manager_agent.get_delegation_tools(self.agents)
    475         else:

Exception: Manager agent should not have tools

leungmanhin avatar Jul 10 '24 12:07 leungmanhin

Hey, I had the same issue when running kickoff() method for the same crew in a loop. I fixed locally by removing the validation of the tools equipped to the manager agent. In the lib, file crewai/crew.py I commented out the two lines that appears in your error message.

    472         # if manager.tools is not None and len(manager.tools) > 0:
    473         #       raise Exception("Manager agent should not have tools")

The other way I prevented this was recreating crew inside the loop instead of reusing same object, as you said. But I think the problem is here:

    474         manager.tools = self.manager_agent.get_delegation_tools(self.agents)

I don't know why it equips the tools to the manager if it will validate later on.

santana-ai avatar Jul 11 '24 13:07 santana-ai

Hi, I ran into this same issue. However, in my case I was trying to equip my manager agent with tools. Is that not allowed? and why would it not be okay for a manager agent to use tools just like other agents?

The other problem I have is following what @santana-ai mentioned:

The other way I prevented this was recreating crew inside the loop instead of reusing same object, as you said. But I think the problem is here: 474 manager.tools = self.manager_agent.get_delegation_tools(self.agents) I don't know why it equips the tools to the manager if it will validate later on.

What is the point of the manager agent who in theory delegates tasks to other agents, to get the tools of the agents it's delegating the tasks to... shouldn't it work they other way around (if anything)? In other words, the delegating agents should inherit the tools from the manager agent, rather than the opposite way around.

As far as I have seen, most people either attach tools to specific tasks, or to specific agents. In the case where tools are assigned to tasks, this logic is fine since the manager agent gives tasks to agents. But in the case where tools are attached to agents, does the manager delegate the tasks according to which tools are equipped to each agent? This is a bit confusing and is not really explained in the docs.

jakeazcona avatar Jul 29 '24 14:07 jakeazcona

same problem here running the code

while True:
    in_message = input("user: ")
    if in_message == "exit":
        break
    result = crew.kickoff({"history": in_message})
    print(f"result: {result}")

the second time it crashes with Exception: Manager agent should not have tools

I am using the 0.86.0, are there other working versions?

Sopralapanca avatar Dec 11 '24 11:12 Sopralapanca

Facing same problem. In second iteration it fails. And to successfully kickoff the crew again, I need to execute crew creation code. Not sure if it's happening because I am creating multiple crews (with different agents and tasks). But even if I rename the manager agent, it still fails.

llm: gemini-1.5-flash-001 / gemini-1.5-pro crewai==0.86.0

@bhancockio @joaomdmoura Is it possible for your team to check this ?

FYI: @madhulokanath

SaurabhTayde avatar Dec 11 '24 23:12 SaurabhTayde

It is intermitent. In my case, I only have to retry and the problem disapear. Utilizing in Google Colab.

hijm avatar Dec 26 '24 03:12 hijm

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jan 25 '25 12:01 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jan 30 '25 12:01 github-actions[bot]