Self Reflection AI Agents
Self-reflection is a powerful feature in PraisonAI that enables agents to evaluate and improve their own responses before delivering them. This leads to higher quality outputs and more reliable task completion.
Overview
When an agent with self-reflection enabled processes a task:
- It generates an initial response using its tools and capabilities
- The agent then reflects on its own response, evaluating:
- Completeness
- Accuracy
- Relevance
- Quality
- Based on this reflection, the agent may revise and improve its response
- This cycle can repeat until the agent is satisfied with the quality
Usage
Self-reflection is enabled by default for all agents. You can explicitly control it using the self_reflect
parameter:
Benefits
- Higher Quality Outputs: Agents can catch and correct potential issues before delivering responses
- More Reliable Task Completion: Self-reflection helps ensure all aspects of a task are properly addressed
- Conscious Decision Making: Agents evaluate their own work, leading to more thoughtful responses
- Improved Accuracy: Multiple reflection cycles help refine and perfect the output
Integration with Processes
Self-reflection works seamlessly with both sequential and hierarchical processes:
- Sequential: Each agent self-reflects on their individual tasks
- Hierarchical: Agents self-reflect before reporting to the manager agent, ensuring high-quality inputs for decision-making
Example
Here’s a complete example showing self-reflection in action:
In this example, the researcher agent will:
- Research AI advancements
- Generate an initial report
- Self-reflect on the report’s quality
- Make improvements if needed
- Deliver the final, refined output
Performance Impact
While self-reflection adds additional processing time, the improvement in output quality often justifies the extra computation. The number of reflection cycles need to be manually optimized to balance quality and performance.
Was this page helpful?