Skip to main content
Agents can review and improve their own responses before returning.

Quick Start

1

Enable Reflection

import { Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'You write professional content',
  reflection: true
});

await agent.chat('Write a business proposal');
// Agent writes, reviews, and improves before returning
2

Multiple Rounds

const agent = new Agent({
  reflection: {
    rounds: 2,  // Review twice
    prompt: 'Check for clarity and professionalism'
  }
});

User Interaction Flow


Configuration Levels

// Level 1: Bool - Enable with defaults
const agent = new Agent({
  reflection: true
});

// Level 2: Dict - With options
const agent = new Agent({
  reflection: {
    rounds: 2,
    prompt: 'Review for errors and clarity'
  }
});

// Level 3: Instance - Full control
const agent = new Agent({
  reflection: {
    rounds: 3,
    prompt: 'Focus on tone and accuracy',
    stopWhen: (output) => output.quality > 0.9
  }
});

How It Works

  1. Generate: Agent creates initial response
  2. Review: Agent critiques its own work
  3. Improve: Agent fixes identified issues
  4. Repeat: Process continues for specified rounds

API Reference

ReflectionConfig

Complete configuration options

Best Practices

More rounds don’t always mean better results.
Enable for proposals, articles, and important content.
Use reflection with criteria for validated quality.