From 3aa48dcd588dcfa8681e7309213fbdffaa4456fe Mon Sep 17 00:00:00 2001 From: Gustavo Satheler Date: Fri, 21 Mar 2025 13:32:54 -0300 Subject: [PATCH] fix: move agent tools for a variable instead of use format (#2319) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/utilities/planning_handler.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/crewai/utilities/planning_handler.py b/src/crewai/utilities/planning_handler.py index 6ce74f236..1bd14a0c8 100644 --- a/src/crewai/utilities/planning_handler.py +++ b/src/crewai/utilities/planning_handler.py @@ -96,6 +96,10 @@ class CrewPlanner: tasks_summary = [] for idx, task in enumerate(self.tasks): knowledge_list = self._get_agent_knowledge(task) + agent_tools = ( + 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 "" + ) task_summary = f""" Task Number {idx + 1} - {task.description} "task_description": {task.description} @@ -103,10 +107,7 @@ class CrewPlanner: "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(agent_tools)}""" tasks_summary.append(task_summary) return " ".join(tasks_summary)