From 6ac374aefaacadb18c66b44cd060b390984dc82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moura?= Date: Sun, 8 Jun 2025 15:35:49 -0700 Subject: [PATCH] fix --- src/crewai/agent.py | 6 +----- src/crewai/utilities/agent_utils.py | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/crewai/agent.py b/src/crewai/agent.py index 1d090aab9..f5f4e66ba 100644 --- a/src/crewai/agent.py +++ b/src/crewai/agent.py @@ -254,11 +254,7 @@ class Agent(BaseAgent): reasoning_handler.handle_agent_reasoning() ) - # Only add reasoning plan to task description if verbose mode is disabled - # In verbose mode, the reasoning plan is already displayed in a panel - is_verbose = self.verbose or (hasattr(self, "crew") and getattr(self.crew, "verbose", False)) - if not is_verbose: - task.description += f"\n\nReasoning Plan:\n{reasoning_output.plan.plan}" + task.description += f"\n\nReasoning Plan:\n{reasoning_output.plan.plan}" except Exception as e: if hasattr(self, "_logger"): self._logger.log( diff --git a/src/crewai/utilities/agent_utils.py b/src/crewai/utilities/agent_utils.py index 94a0dc1bf..ebcd4cc30 100644 --- a/src/crewai/utilities/agent_utils.py +++ b/src/crewai/utilities/agent_utils.py @@ -400,8 +400,10 @@ def show_agent_logs( content=f"\033[1m\033[95m# Agent:\033[00m \033[1m\033[92m{agent_role}\033[00m" ) if task_description: + # Filter out reasoning plan from display (but keep it in actual task for LLM) + display_description = _filter_reasoning_plan_from_display(task_description) printer.print( - content=f"\033[95m## Task:\033[00m \033[92m{task_description}\033[00m" + content=f"\033[95m## Task:\033[00m \033[92m{display_description}\033[00m" ) else: # Execution logs @@ -435,6 +437,24 @@ def show_agent_logs( ) +def _filter_reasoning_plan_from_display(task_description: str) -> str: + """Filter out reasoning plan from task description for display purposes only. + + This keeps the reasoning plan in the actual task description for the LLM to use, + but removes it from the display logs to avoid duplication with reasoning panels. + + Args: + task_description: The full task description that may contain a reasoning plan + + Returns: + Task description with reasoning plan removed for display purposes + """ + # Look for the reasoning plan section and remove it for display + if "\n\nReasoning Plan:\n" in task_description: + return task_description.split("\n\nReasoning Plan:\n")[0] + return task_description + + def load_agent_from_repository(from_repository: str) -> Dict[str, Any]: attributes: Dict[str, Any] = {} if from_repository: