I have a standard setup from the docs using the manager, plus the few simple agents, but it fails with pedantic error. My code:
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
# Uncomment the following line to use an example of a custom tool
# from marketing_agent.tools.custom_tool import MyCustomTool
# Check our tools documentations for more information on how to use them
# from crewai_tools import SerperDevTool
@CrewBase
class MarketingAgentCrew():
"""MarketingAgent crew"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
@agent
def researcher(self) -> Agent:
return Agent(
config=self.agents_config['researcher'],
# tools=[MyCustomTool()], # Example of custom tool, loaded on the beginning of file
verbose=True,
allow_delegation=False,
)
@agent
def cto(self) -> Agent:
return Agent(
config=self.agents_config['cto'],
# tools=[MyCustomTool()], # Example of custom tool, loaded on the beginning of file
verbose=True,
allow_delegation=False,
)
@agent
def writer(self) -> Agent:
return Agent(
config=self.agents_config['writer'],
verbose=True,
allow_delegation=False,
)
@task
def reporting_task(self) -> Task:
return Task(
config=self.tasks_config['task'],
output_file='report.md'
)
def manager(self) -> Agent:
return 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,
verbose=True
)
@crew
def crew(self) -> Crew:
"""Creates the MarketingAgent crew"""
return Crew(
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
manager_agent=self.manager(),
process=Process.hierarchical,
verbose=True,
# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
)
Logs:
# Agent: Project Manager
## Thought: Thought: I need to delegate the task of ensuring that the user request is fully completed and verified according to the specified criteria to the Senior Data Researcher. I will carefully construct the task description and context to include all necessary information for them to execute the task effectively.
## Using tool: Delegate work to coworker
## Tool Input:
"{\"task\": {\"description\": \"Complete the user request by validating the output using the specified criteria and verification agents.\", \"type\": \"str\"}, \"context\": {\"description\": \"This user request requires thorough completion and verification. Verification criteria include: 1. Accuracy - ensuring data correctness; 2. Completeness - verifying all elements of the request are addressed; 3. Relevance - checking pertinence to the user request; 4. Consistency - maintaining uniformity in language and formatting; 5. Clarity and Readability - ensuring the output is easily understandable. Use verification agents such as peer reviews, software tools for grammar and clarity checks, source validation for claims, a checklist for systematic evaluation, and a feedback loop for future improvements. Document all findings and results in markdown format.\", \"type\": \"str\"}, \"coworker\": \"Senior Data Researcher\"}"
## Tool Output:
I encountered an error while trying to use the tool. This was the error: 2 validation errors for DelegateWorkToolSchema
task
Input should be a valid string [type=string_type, input_value={'description': 'Complete...agents.', 'type': 'str'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/string_type
context
Input should be a valid string [type=string_type, input_value={'description': 'This use...format.', 'type': 'str'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/string_type.
Tool Delegate work to coworker accepts these inputs: Tool Name: Delegate work to coworker
Tool Arguments: {'task': {'description': 'The task to delegate', 'type': 'str'}, 'context': {'description': 'The context for the task', 'type': 'str'}, 'coworker': {'description': 'The role/name of the coworker to delegate to', 'type': 'str'}}