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

<Steps>
  <Step title="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
    ```
  </Step>

  <Step title="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'
      ]
    });
    ```
  </Step>
</Steps>

***

## 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 title="AgentConfig" icon="code" href="/docs/sdk/reference/typescript/classes/AgentConfig">
  Agent configuration including criteria
</Card>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Be specific">
    "At least 500 words" is better than "long enough".
  </Accordion>

  <Accordion title="Keep criteria measurable">
    Criteria the agent can verify work best.
  </Accordion>

  <Accordion title="Set retry limits">
    Prevent infinite loops with maxRetries.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Reflection" icon="rotate" href="/docs/js/reflection">
    Self-improvement
  </Card>

  <Card title="Output" icon="display" href="/docs/js/output">
    Output formats
  </Card>
</CardGroup>
