Self-Reflection
The Self-Reflection block enables agents to analyze their own performance, identify mistakes, and improve their reasoning through metacognitive evaluation.
Overview
Self-Reflection implements metacognition in AI workflows, allowing agents to step back and critically evaluate their own thinking, decisions, and outputs. This leads to higher quality results and more robust error detection.
Output Analysis: Examine the agent's previous response or reasoning chain
Error Detection: Identify potential mistakes, biases, or logical inconsistencies
Quality Assessment: Evaluate how well the output meets the original requirements
Improvement Generation: Suggest specific corrections or enhancements
How It Works
graph LR
A[Agent Output] --> B[Self-Analysis]
B --> C[Error Detection]
C --> D[Quality Check]
D --> E{Satisfactory?}
E -->|No| F[Generate Improvements]
F --> G[Revised Output]
E -->|Yes| H[Approved Output]Configuration
Reflection Model
The AI model performing the self-evaluation. Often benefits from using the same or more powerful model than the original agent.
Evaluation Criteria
Specific dimensions to assess:
- Accuracy: Factual correctness and logical consistency
- Completeness: Whether all aspects of the task were addressed
- Relevance: How well the output matches the original request
- Quality: Writing quality, clarity, and usefulness
Reflection Depth
Controls how thorough the self-evaluation becomes:
- Surface: Check for obvious errors and omissions
- Deep: Analyze reasoning chains and assumptions
- Comprehensive: Evaluate methodology and alternative approaches
Confidence Threshold
Minimum confidence level required to approve outputs without revision.
Use Cases
- Content Quality Assurance: Ensuring written content meets standards before publication
- Code Review: Self-checking generated code for bugs and best practices
- Decision Validation: Verifying that recommendations are sound and well-reasoned
Example Workflow
[User Query] → [Agent] → [Self-Reflection] → [Condition] → [Response or Retry]An agent generates a technical explanation, then reflects:
Original Output: "Machine learning uses algorithms to find patterns in data..."
Self-Reflection Analysis:
- ✅ Factually accurate basic definition
- ⚠️ Missing concrete examples
- ⚠️ Could be more engaging for beginners
- ❌ Doesn't address the user's specific use case
Improvement Suggestions:
- Add a real-world example (e.g., email spam filtering)
- Include a simple analogy
- Connect to the user's context about customer data
Revised Output: Enhanced explanation with examples and user-specific context
Best Practice: Use self-reflection for high-stakes outputs where accuracy and quality are critical. Balance thoroughness with computational efficiency.
When to Use This vs Other Blocks
| Block | When to Use |
|---|---|
| Self-Reflection | Quality-critical tasks requiring error detection and improvement |
| Evaluator | Scoring and ranking multiple outputs or options |
| Feedback Loop | Learning from user feedback over time |