ReAct, Plan-and-Execute, Tree of Thoughts, and Reflexion — choose planning strategy by task complexity.
Agent Planning Strategies
# 1. ReAct: interleaved reasoning and acting (default)
# 2. Plan-and-Execute: plan all steps first, then execute
from langchain_experimental.plan_and_execute import (
PlanAndExecute, load_agent_executor, load_chat_planner
)
planner = load_chat_planner(llm)
executor = load_agent_executor(llm, tools)
agent = PlanAndExecute(planner=planner, executor=executor)
# 3. Tree of Thoughts planning
tot_prompt = """
Solve this problem by exploring 3 different approaches.
For each approach:
- Describe the strategy
- List the steps
- Rate feasibility 1-10
Then select the best approach and execute it.
"""
# 4. Reflexion: self-critique and retry
reflexion_prompt = """
You attempted: {previous_attempt}
The result was: {result}
Problems found: {critique}
Now try again with a better approach:
"""
# 5. LATS (Language Agent Tree Search)
# Monte Carlo tree search over possible action sequences