diff --git a/src/crewai/translations/en.json b/src/crewai/translations/en.json index bd2ba8d46..6858f8996 100644 --- a/src/crewai/translations/en.json +++ b/src/crewai/translations/en.json @@ -60,6 +60,7 @@ "adaptive_reasoning_decision": "You are {role}, a professional with the following background: {backstory}\n\nYour primary goal is: {goal}\n\nAs {role}, you are currently executing a task and need to decide whether to pause and reassess your plan based on the current context.", "mid_execution_reasoning": "You are currently executing a task and need to reassess your plan based on progress so far.\n\nTASK DESCRIPTION:\n{description}\n\nEXPECTED OUTPUT:\n{expected_output}\n\nCURRENT PROGRESS:\nSteps completed: {current_steps}\nTools used: {tools_used}\nProgress summary: {current_progress}\n\nRECENT CONVERSATION:\n{recent_messages}\n\nBased on the current progress and context, please reassess your plan for completing this task.\nConsider what has been accomplished, what challenges you've encountered, and what steps remain.\nAdjust your strategy if needed or confirm your current approach is still optimal.\n\nProvide a detailed updated plan for completing the task.\nEnd with \"READY: I am ready to continue executing the task.\" if you're confident in your plan.", "mid_execution_plan": "You are {role}, a professional with the following background: {backstory}\n\nYour primary goal is: {goal}\n\nAs {role}, you are reassessing your plan during task execution based on the progress made so far.", - "mid_execution_reasoning_update": "I've reassessed my approach based on progress so far. Updated plan:\n\n{plan}" + "mid_execution_reasoning_update": "I've reassessed my approach based on progress so far. Updated plan:\n\n{plan}", + "adaptive_reasoning_context": "\n\nTASK DESCRIPTION:\n{description}\n\nEXPECTED OUTPUT:\n{expected_output}\n\nCURRENT EXECUTION CONTEXT:\n- Steps completed: {current_steps}\n- Tools used: {tools_used}\n- Progress summary: {current_progress}\n\nConsider whether the current approach is optimal or if a strategic pause to reassess would be beneficial. You should reason when:\n- You might be approaching the task inefficiently\n- The context suggests a different strategy might be better\n- You're uncertain about the next steps\n- The progress suggests you need to reconsider your approach\n\nDecide whether reasoning/re-planning is needed at this point." } } diff --git a/src/crewai/utilities/reasoning_handler.py b/src/crewai/utilities/reasoning_handler.py index dd58a75eb..3e0682035 100644 --- a/src/crewai/utilities/reasoning_handler.py +++ b/src/crewai/utilities/reasoning_handler.py @@ -661,29 +661,20 @@ class AgentReasoning: tools_used_str = ", ".join(tools_used) if tools_used else "No tools used yet" # Use the prompt from i18n and format it with the current context - prompt = self.i18n.retrieve("reasoning", "adaptive_reasoning_decision").format( + base_prompt = self.i18n.retrieve("reasoning", "adaptive_reasoning_decision").format( role=self.agent.role, goal=self.agent.goal, backstory=self.__get_agent_backstory() ) - prompt += f"""\n\nTASK DESCRIPTION: -{self.task.description} - -EXPECTED OUTPUT: -{self.task.expected_output} - -CURRENT EXECUTION CONTEXT: -- Steps completed: {current_steps} -- Tools used: {tools_used_str} -- Progress summary: {current_progress} - -Consider whether the current approach is optimal or if a strategic pause to reassess would be beneficial. You should reason when: -- You might be approaching the task inefficiently -- The context suggests a different strategy might be better -- You're uncertain about the next steps -- The progress suggests you need to reconsider your approach - -Decide whether reasoning/re-planning is needed at this point.""" + context_prompt = self.i18n.retrieve("reasoning", "adaptive_reasoning_context").format( + description=self.task.description, + expected_output=self.task.expected_output, + current_steps=current_steps, + tools_used=tools_used_str, + current_progress=current_progress + ) + + prompt = base_prompt + context_prompt return prompt