Pydantic output of task1 to be used in task 2 of same crew?

The below is my pydantic class which is filled with values on completion of task 1.

class OP(BaseModel):
a: xx = Field(default=“”,description=“.”)
b: xx = Field(default=‘’)), description=“”)
c: xx[xx] = Field(default= , description=“”)
T1 = Task(
    description=f"""
        XXXXXX
        """,
    agent=A1,
expected_output=".",
output_pydantic=OP, 
)

T2 = Task(
    description=f"""XXX
        """,
    agent=A2,
    context = [T1],
    expected_output="",
)

In the task2 how can i use the pydantic output of task 1, where i can explicitly mention in the task that use this {a}?

If you’re using the sequential process, then this is taken care of by CrewAI. As stated in the docs:

Sequential Process

This method mirrors dynamic team workflows, progressing through tasks in a thoughtful and systematic manner. Task execution follows the predefined order in the task list, with the output of one task serving as context for the next.

To customize task context, utilize the context parameter in the Task class to specify outputs that should be used as context for subsequent tasks.

Hey! @rakshit_gupta Where you able to resolve the issue? I am facing the similar issue.

I have two tasks:

  1. Task 1 output is the pydantic model defined as:

class Task1Output(BaseModlel): task1_out: list[float]

  1. Task2 output is also a pydantic model defined as
    class Task2Output(BaseModlel): task2_out: list[dict[str, str]]

I want to use the output of task 1 as an input to task 2. There is no error in Task 1 and I am getting a pydantic output from task 1. I have defined Task 2 as below:

@task
def task2(self) → Task:
return Task(
config=self.tasks_config[“task2_task”],
llm=self.OpenAI35kTurbo,
callback=log_output,
output_pydantic = Task2Output,
context=[self.task1()]
)

Although, I have used context attribute in task 2, it still says “Validation Error: 1 input missing”