crewAI: [BUG] Arguments validation failed: 2 validation errors for DelegateWorkToolSchema
Description
I encountered an error while trying to use the tool. This was the error: Arguments validation failed: 2 validation errors for DelegateWorkToolSchema
task
Input should be a valid string [type=string_type, input_value={'description': "Identify...ontent.", 'type': 'str'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/string_type
context
Input should be a valid string [type=string_type, input_value={'description': "As part ...ration.", 'type': 'str'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/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'}}
Tool Description: Delegate a specific task to one of the following coworkers: FastAPI Backend Developer
The input to this tool should be the coworker, the task you want them to do, and ALL necessary context to execute the task, they know nothing about the task, so share absolute everything you know, don't reference things but instead explain them.
Steps to Reproduce
- main.py:
def run():
"""
Run the crew.
"""
inputs = {
'project_path': '/my/path/1',
'new_project_path': '/my/path/2',
'base_structure_path': '/my/path/3'
}
result = SdCrew().crew().kickoff(inputs=inputs)
print(result)
- crew.py:
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task, before_kickoff
from crewai_tools import FileReadTool, FileWriterTool, DirectoryReadTool
from langchain_openai import ChatOpenAI
@CrewBase
class SdCrew():
"""SdCrew crew"""
tools = [DirectoryReadTool(), FileReadTool(), FileWriterTool()]
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
@agent
def tech_lead(self) -> Agent:
return Agent(
config=self.agents_config['tech_lead'],
tools=[DirectoryReadTool(), FileReadTool()],
verbose=True
)
@agent
def back_end_developer(self) -> Agent:
return Agent(
config=self.agents_config['back_end_developer'],
tools=self.tools,
allow_code_execution=True,
verbose=True
)
@agent
def front_end_developer(self) -> Agent:
return Agent(
config=self.agents_config['front_end_developer'],
tools=self.tools,
allow_code_execution=True,
verbose=True
)
@agent
def qa_engineer(self) -> Agent:
return Agent(
config=self.agents_config['qa_engineer'],
tools=self.tools,
allow_code_execution=True,
verbose=True
)
@agent
def database_specialist(self) -> Agent:
return Agent(
config=self.agents_config['database_specialist'],
allow_code_execution=True,
verbose=True
)
@task
def architecture_planning(self) -> Task:
return Task(
config=self.tasks_config['architecture_planning']
)
@task
def api_migration(self) -> Task:
return Task(
config=self.tasks_config['api_migration']
)
@task
def business_logic_migration(self) -> Task:
return Task(
config=self.tasks_config['business_logic_migration']
)
@task
def component_migration(self) -> Task:
return Task(
config=self.tasks_config['component_migration']
)
@task
def state_management_migration(self) -> Task:
return Task(
config=self.tasks_config['state_management_migration']
)
@task
def testing_automation(self) -> Task:
return Task(
config=self.tasks_config['testing_automation']
)
@task
def postgresql_queries_migration(self) -> Task:
return Task(
config=self.tasks_config['postgresql_queries_migration']
)
@task
def system_validation(self) -> Task:
return Task(
config=self.tasks_config['system_validation']
)
@before_kickoff
def before_kickoff_function(self, inputs):
print(f"Before kickoff: Project to be migrated: {inputs.get('project_path')}; New project directory: {inputs.get('new_project_path')}; Base structure directory: {inputs.get('base_structure_path')}")
return inputs
@crew
def crew(self) -> Crew:
"""Creates the SdCrew crew"""
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.hierarchical,
manager_llm=ChatOpenAI(temperature=0.1, model_name="gpt-4o-mini"),
respect_context_window=True,
memory=True,
planning=True,
verbose=True
)
- Run
crewai run.
I got a bit reluctant about sharing agents and yasks.yaml. If you really need the files, let me know.
Expected behavior
No delegation error between agents.
Screenshots/Code snippets
Operating System
Other (specify in additional context)
Python Version
3.10
crewAI Version
0.86.0
crewAI Tools Version
0.17.0
Virtual Environment
Conda
Evidence
Print above.
Possible Solution
None.
Additional context
I’m using Linux Mint 21.2 Victoria.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 10
- Comments: 21 (1 by maintainers)
Same here. any idea how to fix that ?
Its default LLM version is gpt-4o-mini change it to gpt-4o (I can fix the error, when I change LLM model to gpt-4o)
Having the same problem here.
The problem appears when I try to use
gpt-4o-mini. But it is solved when I change the OpenAI model to thegpt-4oversion.Input
OPENAI_MODEL_NAME=gpt-4o-miniOutput
Should I downgrade so that I don’t get this error? Which version is stable?
Same here while using the example code from https://docs.crewai.com/how-to/custom-manager-agent
Error:
Used code:
@amindadgar love it, tks!
So after some research I found the problem lies behind the LLM not understanding your tools well. I addressed this problem by better defining my docstring & the input schema. Here’s some notes for anyone to tell how to handle it
Here was code that I could get the tool working well (note that the input schema definition is very important!!).
Here is my workaround when using
gpt-4o-mini(have not seen any errors until now)same error, i am sure this project will be terminated soon.