Improving LLM Outputs with ReACT and ReWOO
In the evolving landscape of LLM prompt engineering, various strategies have emerged to help language models tackle complex, multi-step tasks. Among these approaches, two patterns stand out for their contrasting philosophies: ReACT (Reasoning and Acting) and ReWOO (Reasoning Without Observation).
A Tale of Two Paradigms
ReACT (Reasoning and Acting) embodies the "think-as-you-go" approach – an iterative dance between reasoning and action that mirrors how humans often work through complex problems.
ReWOO (Reasoning Without Observation) takes the opposite stance – a "plan-then-execute" methodology that separates the thinking phase from the action phase entirely.
Both are powerful prompting strategies with distinct requirements and outcomes. Understanding when to apply each can significantly impact your agent's performance, cost-efficiency, and reliability. But which approach is the best? The answer, as we'll discover, depends heavily on your specific use case, computational constraints, and performance requirements.
Understanding ReACT: The Adaptive Thinker
ReACT operates on a simple yet powerful principle: interleave reasoning with action. The pattern follows a cyclic flow:
- Think - Analyse the current situation and decide what to do next
- Act - Take an action (use a tool, make an API call, etc.)
- Observe - Process the results of the action
- Repeat - Continue until the task is complete
ReACT in Action: A Real Example
Let's say you ask an agent: "Find the current weather in Paris and recommend what to wear."
A ReACT agent might work like this:
Thought: I need to find the current weather in Paris first.
Action: search_weather("Paris, France")
Observation: Current weather is 15°C, light rain, humidity 78%
Thought: Now I know it's cool and rainy. I should recommend appropriate clothing.
Action: generate_clothing_recommendation(temperature=15, conditions="light rain")
Observation: Generated recommendation
Thought: I have all the information needed to provide a complete answer.
Action: format_final_response()
The Strengths of ReACT
- Adaptability: ReACT excels when dealing with uncertain environments where the next step depends heavily on previous results. If a weather API fails, the agent can immediately pivot to alternative data sources.
- Error Recovery: When something goes wrong, ReACT agents can course-correct in real-time. They don't need to restart their entire planning process.
- Dynamic Problem Solving: For exploratory tasks where the solution path isn't clear upfront, ReACT's iterative approach allows for organic discovery of the solution.
- Efficiency for Simple Tasks: When a problem can be solved quickly with just a few tool calls, ReACT's overhead is minimal.
The Challenges of ReACT
- Token Consumption: Each reasoning step requires LLM inference, leading to higher computational costs for complex tasks.
- Potential for Loops: Without careful prompt engineering, ReACT agents can get stuck in reasoning loops or take unnecessarily circuitous paths.
- Lack of Global Planning: Since decisions are made step-by-step, ReACT might miss opportunities for optimisation that require a global view of the task.
Understanding ReWOO: The Strategic Planner
ReWOO takes a radically different approach by completely separating the planning phase from execution. The pattern works in three distinct stages:
- Planner - Generate a complete execution plan with all necessary tool calls
- Worker - Execute the plan by making all the planned tool calls in parallel
- Solver - Synthesise all the results into a final answer
ReWOO in Action: The Same Example
For the Paris weather question, a ReWOO agent would approach it like this:
Planning Phase
Plan:
- Tool Call 1: search_weather("Paris, France") → #E1
- Tool Call 2: generate_clothing_recommendation(temperature=#E1.temperature, conditions=#E1.conditions) → #E2
- Final: Combine weather data from #E1 and recommendations from #E2
Execution Phase
Executing Tool Call 1: search_weather("Paris, France")
Executing Tool Call 2: generate_clothing_recommendation(temperature=15, conditions="light rain")
Synthesis Phase
Combining results to generate final response...
The Strengths of ReWOO
- Parallel Execution: Since the plan is generated upfront, many tool calls can be executed simultaneously, dramatically reducing latency.
- Token Efficiency: Only three LLM calls are needed regardless of complexity: planning, and potentially error handling, and synthesis.
- Predictable Performance: The execution timeline is known upfront, making it easier to manage resources and set expectations.
- Global Optimisation: The planner can optimise the entire workflow, potentially discovering efficiencies that step-by-step execution would miss.
The Challenges of ReWOO
- Rigidity: If the initial plan is flawed or if unexpected results occur, there's no mechanism for mid-course correction without restarting the entire process.
- Planning Overhead: For simple tasks, generating a complete plan might be overkill compared to just executing directly.
- Error Handling Complexity: When tool calls fail, the entire plan may need to be regenerated rather than just adapting the next step.
- Limited Context Propagation: Since tool calls are planned in advance, they can't easily incorporate results from previous calls in complex, dependent scenarios.
Architecture Considerations: Building for Your Needs
When deciding between ReACT and ReWOO, consider these architectural factors:
For ReACT-Favouring Scenarios
Choose ReACT when you have:
- High Uncertainty Environments: When you can't predict what tools you'll need until you see initial results
- Exploratory Workflows: Research tasks, debugging, or investigation scenarios
- Error-Prone Tool Chains: When tools frequently fail and alternatives are needed
- Real-time Requirements: When immediate response to changing conditions is crucial
- Small Model Constraints: When working with smaller LLMs that struggle with complex planning
For ReWOO-Favouring Scenarios
Choose ReWOO when you have:
- Well-Defined Workflows: Clear, repeatable processes with known steps
- Performance-Critical Applications: When latency and efficiency are paramount
- Batch Processing: Scenarios where many similar tasks need processing
- Cost-Conscious Deployments: When minimising LLM API calls is important
- Parallel Computing Resources: When you can execute multiple tool calls simultaneously
Hybrid Approaches: The Best of Both Worlds
The most sophisticated agent systems don't choose one pattern exclusively. Instead, they employ dynamic pattern selection based on task characteristics:
async def select_execution_pattern(
task: Task,
context: Context
) -> ExecutionPattern:
complexity = analyse_task_complexity(task)
uncertainty = assess_environment_uncertainty(context)
resources = check_available_resources()
if complexity.low and uncertainty.low:
return ReWOOPattern()
elif uncertainty.high or resources.limited:
return ReACTPattern()
else:
return HybridPattern() # Custom blend based on specific needs
Some systems even implement ReACT-in-ReWOO patterns, where the overall workflow is planned using ReWOO principles, but individual components use ReACT for adaptive execution.
Making the Choice: A Decision Framework
To help you choose the right pattern for your use case, ask yourself these key questions:
-
How predictable are your workflows?
- Predictable workflows: Choose ReWOO
- Unpredictable workflows: Choose ReACT
-
How critical is execution speed?
- Very critical: Choose ReWOO
- Less critical: Choose ReACT
-
How robust are your tools?
- Highly robust: Choose ReWOO
- Error-prone: Choose ReACT
-
What's your computational budget?
- Limited budget: Choose ReWOO
- Flexible budget: Choose ReACT
-
How important is adaptability?
- Very important: Choose ReACT
- Less important: Choose ReWOO
Conclusion: Context is King
The ReACT vs ReWOO debate isn't about finding a universal winner – it's about understanding the trade-offs and choosing the right tool for the job. ReACT excels in dynamic, uncertain environments where adaptability trumps efficiency. ReWOO dominates in well-defined scenarios where performance and predictability are paramount.
The most successful AI agent implementations recognise that this isn't an either-or decision. By understanding the strengths and limitations of each pattern, and potentially implementing hybrid approaches, you can build agents that are both robust and efficient.
As you design your next AI agent, remember: the best architecture is the one that matches your specific requirements, constraints, and goals. Whether that's the adaptive flexibility of ReACT, the efficient planning of ReWOO, or a hybrid approach that combines the best of both worlds, the choice should be driven by your unique context rather than trending preferences.
The future of AI agents lies not in choosing sides, but in choosing wisely.
Second Mesh Secures Innovate UK funding
Second Mesh has been awarded funding from Innovate UK to develop secure and trusted AI tools for high stakes and regulated sectors such as education.
The ART of getting AI Agents to pick the right tool
An exploration into the ART framework- Automatic Reasoning and Tool-use with embeddings.