Patterns
๐Ÿ”„

Reflexion(RX)

Agents learn from experience through verbal self-reflection and episodic memory

Complexity: highReflection

๐ŸŽฏ 30-Second Overview

Pattern: Agents learn from experience through verbal self-reflection

Why: Converts failures into linguistic insights, enabling learning without fine-tuning

Key Insight: Actor โ†’ Evaluator โ†’ Self-Reflection โ†’ Memory โ†’ Improved Performance

โšก Quick Implementation

1Actor Executes:Generate actions/text for task
2Environment Responds:Get feedback/results
3Evaluator Scores:Assess performance objectively
4Self-Reflect:Generate verbal reinforcement
5Update Memory:Store reflection for next trial
Example: Actor(task) โ†’ Result โ†’ Evaluate โ†’ Reflect(verbal) โ†’ Memory โ†’ Actor(improved)

๐Ÿ“‹ Do's & Don'ts

โœ…Convert feedback into actionable linguistic hints
โœ…Maintain episodic memory of past reflections
โœ…Use specific, concrete reflection prompts
โœ…Implement clear evaluation metrics
โœ…Limit reflection depth to avoid overthinking
โŒStore raw trajectories without reflection
โŒUse vague reflections like "do better"
โŒSkip environment feedback integration
โŒAllow unlimited reflection cycles
โŒIgnore memory constraints in long tasks

๐Ÿšฆ When to Use

Use When

  • โ€ข Multi-step reasoning tasks
  • โ€ข Programming challenges
  • โ€ข Sequential decision making
  • โ€ข Learning from failures

Avoid When

  • โ€ข Single-shot tasks
  • โ€ข Time-critical applications
  • โ€ข Simple Q&A
  • โ€ข Deterministic problems

๐Ÿ“Š Key Metrics

Success Rate
Task completion over trials
Learning Curve
Performance improvement rate
Reflection Quality
Actionability of insights
Memory Efficiency
Relevant recall vs storage
Convergence Speed
Trials to optimal performance
Generalization
Transfer to similar tasks

๐Ÿ’ก Top Use Cases

Code Generation: Write โ†’ Test โ†’ Reflect on errors โ†’ Fix bugs โ†’ Improve
Game Playing: Move โ†’ Observe โ†’ Evaluate โ†’ Reflect on strategy โ†’ Adapt
Problem Solving: Attempt โ†’ Check โ†’ Analyze failure โ†’ Learn โ†’ Retry
Writing Tasks: Draft โ†’ Review โ†’ Reflect on weaknesses โ†’ Revise โ†’ Polish
Agent Training: Act โ†’ Get reward โ†’ Reflect on decisions โ†’ Update policy

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