IMPORTANT ENV PACKAGE VERSIONS :-
Pydantic Version :- 2.9.2,
Crew Ai Version :- 0.76.2,
Python Version :- 3.10.15
Error : - Traceback (most recent call last): File "/Users/pravincoder/Developer/Email Advertiser/main.py", line 59, in <module> result = custom_crew.run() File "/Users/pravincoder/Developer/Email Advertiser/main.py", line 30, in run custom_task_1 = tasks.task_1_name( File "/Users/pravincoder/Developer/Email Advertiser/tasks.py", line 13, in task_1_name return Task( File "/opt/homebrew/Caskroom/miniconda/base/envs/email-crew/lib/python3.10/site-packages/pydantic/main.py", line 212, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for Task expected_output Field required [type=missing, input_value={'description': "\nResear...agent 1 backstory here)}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing
Reason :- Task object requires an expected_output field, which you haven't provided. The Task model in pydantic expects specific fields to be filled based on how the Task class is defined.
Solution :- Add the expected_output field in your Task creation.
According Actual Solution:-
from crewai import Task
from textwrap import dedent
# This is an example of how to define custom tasks.
# You can define as many tasks as you want.
# You can also define custom agents in agents.py
class CustomTasks:
def __tip_section(self):
return "If you do your BEST WORK, I'll give you a $10,000 commission!"
def task_1_name(self, agent, var1, var2):
return Task(
description=dedent(
f"""
Do something as part of task 1
{self.__tip_section()}
Make sure to use the most recent data as possible.
Use this variable: {var1}
And also this variable: {var2}
"""
),
expected_output="Expected Output of this Agent(task_1_name) in simple words",
agent=agent,
)
def task_2_name(self, agent):
return Task(
description=dedent(
f"""
Take the input from task 1 and do something with it.
{self.__tip_section()}
Make sure to do something else.
"""
),
expected_output="Expected Output of this Agent(task_2_name) in simple words",
agent=agent,
)
I would like to create a PR on the following issue and Update few things like structure of passing Agent and Task using yaml file.
IMPORTANT ENV PACKAGE VERSIONS :- Pydantic Version :- 2.9.2, Crew Ai Version :- 0.76.2, Python Version :- 3.10.15
Error : -
Traceback (most recent call last): File "/Users/pravincoder/Developer/Email Advertiser/main.py", line 59, in <module> result = custom_crew.run() File "/Users/pravincoder/Developer/Email Advertiser/main.py", line 30, in run custom_task_1 = tasks.task_1_name( File "/Users/pravincoder/Developer/Email Advertiser/tasks.py", line 13, in task_1_name return Task( File "/opt/homebrew/Caskroom/miniconda/base/envs/email-crew/lib/python3.10/site-packages/pydantic/main.py", line 212, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for Task expected_output Field required [type=missing, input_value={'description': "\nResear...agent 1 backstory here)}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing
Reason :-
Task
object requires anexpected_output
field, which you haven't provided. TheTask
model in pydantic expects specific fields to be filled based on how theTask
class is defined.Solution :- Add the expected_output field in your
Task
creation. According Actual Solution:-I would like to create a PR on the following issue and Update few things like structure of passing Agent and Task using yaml file.