Move reasoning prompts to en.json and update documentation

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-05-27 08:57:44 +00:00
parent 38ed69577f
commit cbc81ecc06
3 changed files with 24 additions and 31 deletions

View File

@@ -68,10 +68,10 @@ When reasoning is enabled, before executing a task, the agent will:
During task execution, the agent can re-evaluate and adjust its plan based on:
1. **Interval-based reasoning**: The agent reasons after a fixed number of steps (specified by `reasoning_interval`)
2. **Adaptive reasoning**: The agent decides when to reason based on execution context:
- When multiple different tools are used recently (indicating a change in approach)
- When the task is taking longer than expected (iterations > max_iter/2)
- When recent errors or failures are detected in the execution
2. **Adaptive reasoning**: The agent uses its LLM to intelligently decide when reasoning is needed based on:
- Current execution context (task description, expected output, steps taken)
- The agent's own judgment about whether strategic reassessment would be beneficial
- Automatic fallback when recent errors or failures are detected in the execution
This mid-execution reasoning helps agents adapt to new information, overcome obstacles, and optimize their approach as they work through complex tasks.

View File

@@ -57,6 +57,7 @@
"refine_plan": "You are {role}, a professional with the following background: {backstory}\n\nYour primary goal is: {goal}\n\nAs {role}, you are refining a strategic plan for a task that requires your expertise and unique perspective.",
"create_plan_prompt": "You are {role} with this background: {backstory}\n\nYour primary goal is: {goal}\n\nYou have been assigned the following task:\n{description}\n\nExpected output:\n{expected_output}\n\nAvailable tools: {tools}\n\nBefore executing this task, create a detailed plan that leverages your expertise as {role} and outlines:\n1. Your understanding of the task from your professional perspective\n2. The key steps you'll take to complete it, drawing on your background and skills\n3. How you'll approach any challenges that might arise, considering your expertise\n4. How you'll strategically use the available tools based on your experience, exactly what tools to use and how to use them\n5. The expected outcome and how it aligns with your goal\n\nAfter creating your plan, assess whether you feel ready to execute the task or if you could do better.\nConclude with one of these statements:\n- \"READY: I am ready to execute the task.\"\n- \"NOT READY: I need to refine my plan because [specific reason].\"",
"refine_plan_prompt": "You are {role} with this background: {backstory}\n\nYour primary goal is: {goal}\n\nYou created the following plan for this task:\n{current_plan}\n\nHowever, you indicated that you're not ready to execute the task yet.\n\nPlease refine your plan further, drawing on your expertise as {role} to address any gaps or uncertainties. As you refine your plan, be specific about which available tools you will use, how you will use them, and why they are the best choices for each step. Clearly outline your tool usage strategy as part of your improved plan.\n\nAfter refining your plan, assess whether you feel ready to execute the task.\nConclude with one of these statements:\n- \"READY: I am ready to execute the task.\"\n- \"NOT READY: I need to refine my plan further because [specific reason].\"",
"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."
"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."
}
}

View File

@@ -533,29 +533,14 @@ class AgentReasoning:
if content:
recent_messages += f"{role.upper()}: {content[:200]}...\n\n"
return f"""You are currently executing a task and need to reassess your plan based on progress so far.
TASK DESCRIPTION:
{self.task.description}
EXPECTED OUTPUT:
{self.task.expected_output}
CURRENT PROGRESS:
Steps completed: {current_steps}
Tools used: {tools_used_str}
Progress summary: {current_progress}
RECENT CONVERSATION:
{recent_messages}
Based on the current progress and context, please reassess your plan for completing this task.
Consider what has been accomplished, what challenges you've encountered, and what steps remain.
Adjust your strategy if needed or confirm your current approach is still optimal.
Provide a detailed updated plan for completing the task.
End with "READY: I am ready to continue executing the task." if you're confident in your plan.
"""
return self.i18n.retrieve("reasoning", "mid_execution_reasoning").format(
description=self.task.description,
expected_output=self.task.expected_output,
current_steps=current_steps,
tools_used=tools_used_str,
current_progress=current_progress,
recent_messages=recent_messages
)
def should_adaptive_reason_llm(
self,
@@ -662,9 +647,14 @@ End with "READY: I am ready to continue executing the task." if you're confident
"""Create prompt for adaptive reasoning decision."""
tools_used_str = ", ".join(tools_used) if tools_used else "No tools used yet"
return f"""You are currently executing a task. Based on the information below, decide whether you should pause to reassess and update your plan.
TASK DESCRIPTION:
# Use the prompt from i18n and format it with the current context
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:
@@ -682,3 +672,5 @@ Consider whether the current approach is optimal or if a strategic pause to reas
- The progress suggests you need to reconsider your approach
Decide whether reasoning/re-planning is needed at this point."""
return prompt