Patterns
๐ŸŽฏ

ReAct

Combines reasoning with acting through external tool use

Complexity: highReasoning Techniques

๐ŸŽฏ 30-Second Overview

Pattern: Interleaved Reasoning and Acting through iterative Thought โ†’ Action โ†’ Observation cycles

Why: Enables dynamic problem-solving with real-time information and tool integration

Key Insight: Think before acting โ†’ Execute tools โ†’ Observe results โ†’ Reason about next step

โšก Quick Implementation

1Think:Analyze problem & plan approach
2Act:Execute tool/function call
3Observe:Process action results
4Reason:Evaluate & plan next step
5Loop:Repeat until goal achieved
Example: Thought โ†’ search("weather NYC") โ†’ Observation: "72ยฐF sunny" โ†’ Thought โ†’ Done

๐Ÿ“‹ Do's & Don'ts

โœ…Clearly separate Thought and Action phases
โœ…Use structured action formats (function calls)
โœ…Process all observations before next reasoning
โœ…Implement proper tool error handling
โœ…Set maximum iteration limits to prevent loops
โŒSkip observation phase after actions
โŒUse ambiguous or unstructured action formats
โŒAllow infinite reasoning loops without convergence
โŒIgnore tool failures or partial results
โŒMix reasoning and action in single step

๐Ÿšฆ When to Use

Use When

  • โ€ข Tasks requiring external data/tools
  • โ€ข Multi-step research & investigation
  • โ€ข Dynamic problem-solving workflows
  • โ€ข Real-time information needs
  • โ€ข When environment interaction is key

Avoid When

  • โ€ข Simple knowledge-based questions
  • โ€ข Tasks solvable with pure reasoning
  • โ€ข High-latency sensitive applications
  • โ€ข When tools are unreliable/unavailable
  • โ€ข Static content generation

๐Ÿ“Š Key Metrics

Task Success Rate
Goals achieved vs attempted
Tool Utilization
Effective vs unnecessary tool calls
Reasoning Efficiency
Steps to solution convergence
Error Recovery
Success after tool failures
Information Quality
Relevance of gathered data
Iteration Count
Thought-Action cycles per task

๐Ÿ’ก Top Use Cases

Web Research: Thought โ†’ search("AI trends 2024") โ†’ Observe results โ†’ search("specific trend") โ†’ Synthesize
Data Analysis: Thought โ†’ query_database() โ†’ Observe data โ†’ calculate_stats() โ†’ Interpret results
Code Debugging: Thought โ†’ run_tests() โ†’ Observe failures โ†’ examine_code() โ†’ Fix & retest
Travel Planning: Thought โ†’ check_flights() โ†’ Observe options โ†’ check_hotels() โ†’ Book best combo
Customer Support: Thought โ†’ lookup_account() โ†’ Observe history โ†’ check_policy() โ†’ Provide solution

References & Further Reading

Deepen your understanding with these curated resources

Contribute to this collection

Know a great resource? Submit a pull request to add it.

Contribute

Patterns

closed

Loading...

Built by Kortexya