> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Reflection

> Agents that improve their own work

Agents can review and improve their own responses before returning.

> [!WARNING]
>
> `reflection` is accepted on a `Task` for Python-SDK parity but is **not yet implemented** in the TypeScript SDK — passing it emits a `[praisonai] … not yet honoured` notice and has no effect. This feature is Python-only for now.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    Agent[Agent] --> Review[Review]
    Review --> Output([Output])

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff

    class Agent agent
    class Review,Output tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agent = new Agent({
  reflection: {
    rounds: 2,  // Review twice
    prompt: 'Check for clarity and professionalism'
  }
});
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Reviewer as Self-Review
    
    User->>Agent: "Write a proposal"
    Agent->>Agent: Generate draft
    Agent->>Reviewer: Review draft
    Reviewer-->>Agent: Improvements
    Agent->>Agent: Apply improvements
    Agent-->>User: Polished output
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// 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

> [card] [ReflectionConfig](https://praison.ai/docs/sdk/reference/typescript/classes/ReflectionConfig.md)
>
> Complete configuration options

***

## Best Practices

> [accordion] Use 1-2 rounds
>
> More rounds don't always mean better results.

> [accordion] For quality-critical tasks
>
> Enable for proposals, articles, and important content.

> [accordion] Combine with criteria
>
> Use reflection with criteria for validated quality.

***

## Related

> [card] [Criteria](https://praison.ai/docs/js/criteria.md)
>
> Define success conditions

> [card] [Agent](https://praison.ai/docs/js/agent.md)
>
> Create agents


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.