Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] "Exception: Manager agent should not have tools" - when used in a flow and hierarchical crew , when using a for loop to process multiple outputs from a previous crew #1851

Open
andrewn3 opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@andrewn3
Copy link

andrewn3 commented Jan 4, 2025

Description

When i define a Process.hierarchical crew with a manager agent, if looping through multiple pydantic objects, the first invocation works ok, but the subsequent fails with the exception Exception: Manager agent should not have tools.
It seems the first time agent tools are set to [] but subsequent times the delegation tool and ask question tools are already assigned and thus fails.

Steps to Reproduce

Create a flow, have one crew create a pydantic list output, define the next flow step to process the pydantic object one item at a time, where this crew uses hierarchical process with a manager.

e.g. for the 2nd step
final_content=[]
for section in myobject.sections:
final_content.append(mycrew().crew().kickoff(inputs).raw)
print(final_content)

Expected behavior

I would expect it not to fail, but it seems as the manager is already initiated then the 2nd invocation causes a problem as the tools are already assigned and thus the crew fails on the 2nd invocation of the for loop.

Screenshots/Code snippets

e.g. for the 2nd step
final_content=[]
for section in myobject.sections:
final_content.append(mycrew().crew().kickoff(inputs).raw)
print(final_content)

with the manager initiated in this form

manager = Agent(
role="Project Manager",
goal="Efficiently manage the crew and ensure high-quality task completion",
backstory="You're an experienced project manager, skilled in overseeing complex projects and guiding teams to success. Your role is to coordinate the efforts of the crew members, ensuring that each task is completed on time and to the highest standard.",
allow_delegation=True,
)

and the crew initiated in this form

Instantiate your crew with a custom manager

crew = Crew(
agents=[researcher, writer],
tasks=[task],
manager_agent=manager,
process=Process.hierarchical,
)

Operating System

Windows 11

Python Version

3.12

crewAI Version

0.83.0

crewAI Tools Version

0.14.0

Virtual Environment

Venv

Evidence

[2025-01-04 11:16:35][WARNING]: Manager agent should not have tools
[Flow._execute_single_listener] Error in method generate_specification: Manager agent should not have tools
Traceback (most recent call last):
File "D:\xxx\crewai\flow\flow.py", line 363, in _execute_single_listener
listener_result = await self._execute_method(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\xxx\crewai\flow\flow.py", line 306, in _execute_method
else method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\xxx\coder\main.py", line 71, in generate_specification
final_content.append(SpecificationCrew().crew().kickoff(inputs=specs).pydantic)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\xxx\crewai\crew.py", line 555, in kickoff
result = self._run_hierarchical_process()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\xxx\crewai\crew.py", line 664, in _run_hierarchical_process
self._create_manager_agent()
File "D:\xxx\crewai\crew.py", line 678, in _create_manager_agent
raise Exception("Manager agent should not have tools")
Exception: Manager agent should not have tools

Possible Solution

If I set the following
self.manager.tools = [] within the @before_kickoff which seemed to solve the issue (I also set tools=[] for the manager agent as well).

I guess it needs to determine whether this is the first invocation or subsequent invocation or the managers tools shouldn't be retained for subsequent calls. I know if i don't use a manager and just use a crew with sequential this work fine so it's just isolated to the manager agent code and how this works.

Additional context

I was following your demo example with Matthew Berman on how to process multiple outputs using this approach (rather use the for_each approach as I couldn't get this to work with a more complex pydantic structure).

@andrewn3 andrewn3 added the bug Something isn't working label Jan 4, 2025
@andrewn3 andrewn3 changed the title [BUG] "Exception: Manager agent should not have tools" - when used in a hierarchical crew , when using a for loop to process multiple outputs from a previous crew [BUG] "Exception: Manager agent should not have tools" - when used in a flow and hierarchical crew , when using a for loop to process multiple outputs from a previous crew Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant