How you define the Manager agent in the Crew when using the @agent decorator?

Hi,
If you define the manager as this:

	@agent
	def manager(self) -> Agent:
		return Agent(
			config=self.agents_config['manager'],
		)

How you define the manager in your crew?

	return Crew(
		agents=self.agents, # Automatically created by the @agent decorator
		tasks=self.tasks, # Automatically created by the @task decorator
		verbose=True,
		process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
		manager_agent=???,

In your Crew you define…

manager_agent=self.manager(),
manager_llm=self.manager_llm,

I use mainly local models, and most of the time I got errors and the results are not so appealing.

# Agent: {topic} Content Director
## Using tool: Ask question to coworker
## Tool Input:
"{\"coworker\": \"Content Director\", \"question\": \"When reviewing the script for the podcast episode about Angolan music, what specific elements should I prioritize in my analysis? For example, should I focus more on the historical context, the musical styles, the social impact of the music, or a combination of these?\"}"
## Tool Output:

I encountered an error while trying to use the tool. This was the error: 1 validation error for Ask question to coworker
context
  Field required [type=missing, input_value={'coworker': 'Content Dir... combination of these?'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing.
 Tool Ask question to coworker accepts these inputs: Ask a specific question to one of the following coworkers: {topic} Content Director
The input to this tool should be the coworker, the question you have for them, and ALL necessary context to ask the question properly, they know nothing about the question, so share absolute everything you know, don't reference things but instead explain them..
Moving on then. I MUST either use a tool (use one at time) OR give my best final answer not both at the same time. To Use the following format:

Thought: you should always think about what to do
Action: the action to take, should be one of [Delegate work to coworker, Ask question to coworker]
Action Input: the input to the action, dictionary enclosed in curly braces
Observation: the result of the action
... (this Thought/Action/Action Input/Result can repeat N times)
Thought: I now can give a great answer
Final Answer: Your final answer must be the great and the most complete as possible, it must be outcome described




I encountered an error while trying to use the tool. This was the error: 1 validation error for Ask question to coworker
context
  Field required [type=missing, input_value={'coworker': 'Content Dir... combination of these?'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing.
 Tool Ask question to coworker accepts these inputs: Ask a specific question to one of the following coworkers: {topic} Content Director
The input to this tool should be the coworker, the question you have for them, and ALL necessary context to ask the question properly, they know nothing about the question, so share absolute everything you know, don't reference things but instead explain them.

Thanks Kapenge. I found the response also by looking at some other code but there are not many examples out there.
Your problems may be related to running a low performance LLM model or a model that can’t run tools.

A few comments about my case:

  1. For some reason you can’t include the manager agent in the list of agents=self.agents which is weird.
  2. I found my manager agent trying to run some tools itself which is also weird since there are no tools assigned to it. I have to explicitly mention to not run tools.
  3. I am not sure if the best practice is to describe the manager agent logic in the agent definition or have tasks assigned to manager agents. Its role is to delegate work and quality assurance. Any thoughts about this?

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.