diff --git a/src/crewai/crew.py b/src/crewai/crew.py index 948014e0d..96c84d9ab 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -1,9 +1,9 @@ import asyncio import json +import os import uuid from concurrent.futures import Future from hashlib import md5 -import os from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union from langchain_core.callbacks import BaseCallbackHandler @@ -48,7 +48,6 @@ from crewai.utilities.planning_handler import CrewPlanner from crewai.utilities.task_output_storage_handler import TaskOutputStorageHandler from crewai.utilities.training_handler import CrewTrainingHandler - agentops = None if os.environ.get("AGENTOPS_API_KEY"): try: @@ -541,7 +540,7 @@ class Crew(BaseModel): )._handle_crew_planning() for task, step_plan in zip(self.tasks, result.list_of_plans_per_task): - task.description += step_plan + task.description += step_plan.plan def _store_execution_log( self, diff --git a/src/crewai/utilities/planning_handler.py b/src/crewai/utilities/planning_handler.py index 29b89667e..7b9459adf 100644 --- a/src/crewai/utilities/planning_handler.py +++ b/src/crewai/utilities/planning_handler.py @@ -1,14 +1,25 @@ from typing import Any, List, Optional from langchain_openai import ChatOpenAI -from pydantic import BaseModel +from pydantic import BaseModel, Field from crewai.agent import Agent from crewai.task import Task +class PlanPerTask(BaseModel): + task: str = Field(..., description="The task for which the plan is created") + plan: str = Field( + ..., + description="The step by step plan on how the agents can execute their tasks using the available tools with mastery", + ) + + class PlannerTaskPydanticOutput(BaseModel): - list_of_plans_per_task: List[str] + list_of_plans_per_task: List[PlanPerTask] = Field( + ..., + description="Step by step plan on how the agents can execute their tasks using the available tools with mastery", + ) class CrewPlanner: