ReAct Few-Shot Examples
What you'll learn: How to design effective demonstration examples that show an agent the "reasoning then acting" pattern, dramatically improving its decision-making accuracy.
What Are Few-Shot Examples in ReAct?
Few-shot examples are sample reasoning-action sequences you include in your prompt to show the agent how to think and act. Instead of just telling the agent "reason, then act," you demonstrate it with 1-3 complete examples of the pattern in action.
Think of it like showing a new chef a recipe by actually cooking the dish first, rather than just handing them written instructions. The agent learns the rhythm and structure by seeing it done.
Why They Matter
Raw ReAct prompts sometimes produce agents that:
- Skip reasoning steps entirely
- Use tools incorrectly
- Format outputs wrong
- Give up too quickly
Well-crafted few-shot examples act as guardrails, showing the exact format and depth of reasoning you expect.
Designing Effective Examples
1. Match Your Domain: If your agent handles customer support, your examples should show customer scenarios—not math problems.
2. Show Complete Cycles: Each example should include:
- Thought: Clear reasoning about what to do next
- Action: A properly formatted tool call
- Observation: A realistic tool response
- Thought: Reasoning about the result
- Continue until task completion
3. Vary Complexity: Include at least one simple case (1-2 steps) and one complex case (3-5 steps) to show the agent when to stop vs. continue.
4. Demonstrate Recovery: Show an example where the first tool call doesn't work, and the agent reasons through trying something else.
Key Takeaway: Well-designed few-shot examples in your ReAct prompt template teach the agent not just what to do, but how to think through problems step-by-step—drastically reducing formatting errors and improving task success rates.