> ## 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.

# Criteria

> Define success conditions for agent tasks

Agents can validate their work against criteria before returning results.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Validation Flow"
        A[🤖 Agent] --> B[📝 Output]
        B --> C[✅ Criteria]
        C -->|pass| D[📤 Return]
        C -->|fail| E[🔄 Retry]
    end
    
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef check fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef result fill:#10B981,stroke:#7C90A0,color:#fff
    
    class A,B agent
    class C check
    class D,E result
    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: 'Write blog posts',
  criteria: 'Must be at least 500 words and include 3 key points'
});

const result = await agent.chat('Write about AI trends');
// Agent validates output meets criteria before returning
```

**2. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agent = new Agent({
  criteria: [
    'Contains at least 500 words',
    'Includes an introduction',
    'Has actionable takeaways'
  ]
});
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Validator
    
    User->>Agent: "Write an article"
    Agent->>Agent: Generate content
    Agent->>Validator: Check criteria
    alt Passes
        Validator-->>Agent: ✅ Valid
        Agent-->>User: Final output
    else Fails
        Validator-->>Agent: ❌ Retry
        Agent->>Agent: Improve and retry
    end
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Level 1: String - Simple criteria
const agent = new Agent({
  criteria: 'Must be professional and concise'
});

// Level 2: Array - Multiple criteria
const agent = new Agent({
  criteria: [
    'At least 300 words',
    'Includes examples',
    'No jargon'
  ]
});

// Level 3: Dict - With options
const agent = new Agent({
  criteria: {
    rules: ['professional', 'concise'],
    maxRetries: 3,
    strict: true
  }
});
```

***

## Criteria Options

| Option | Description |
| - | - |
| `rules` | List of validation rules |
| `maxRetries` | Attempts before failing |
| `strict` | Fail on any criteria miss |

***

## API Reference

> [card] [AgentConfig](https://praison.ai/docs/sdk/reference/typescript/classes/AgentConfig.md)
>
> Agent configuration including criteria

***

## Best Practices

> [accordion] Be specific
>
> "At least 500 words" is better than "long enough".

> [accordion] Keep criteria measurable
>
> Criteria the agent can verify work best.

> [accordion] Set retry limits
>
> Prevent infinite loops with maxRetries.

***

## Related

> [card] [Reflection](https://praison.ai/docs/js/reflection.md)
>
> Self-improvement

> [card] [Output](https://praison.ai/docs/js/output.md)
>
> Output formats


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