diff --git a/src/crewai/utilities/planning_handler.py b/src/crewai/utilities/planning_handler.py index 6ce74f236f..303c0dc1af 100644 --- a/src/crewai/utilities/planning_handler.py +++ b/src/crewai/utilities/planning_handler.py @@ -96,6 +96,14 @@ def _create_tasks_summary(self) -> str: tasks_summary = [] for idx, task in enumerate(self.tasks): knowledge_list = self._get_agent_knowledge(task) + agent_tools = task.agent.tools if task.agent else [] + if agent_tools is None: + agent_tools = [] + if knowledge_list is None: + knowledge_list = [] + + knowledge_summary = [str(k) for k in knowledge_list if k is not None] + task_summary = f""" Task Number {idx + 1} - {task.description} "task_description": {task.description} @@ -103,10 +111,8 @@ def _create_tasks_summary(self) -> str: "agent": {task.agent.role if task.agent else "None"} "agent_goal": {task.agent.goal if task.agent else "None"} "task_tools": {task.tools} - "agent_tools": %s%s""" % ( - f"[{', '.join(str(tool) for tool in task.agent.tools)}]" if task.agent and task.agent.tools else '"agent has no tools"', - f',\n "agent_knowledge": "[\\"{knowledge_list[0]}\\"]"' if knowledge_list and str(knowledge_list) != "None" else "" - ) + "agent_tools": {', '.join(str(t) for t in agent_tools)} + "agent_knowledge": {', '.join(str(k) for k in knowledge_summary)}""" tasks_summary.append(task_summary) return " ".join(tasks_summary)