Criteria

Define success conditions for agent tasks

Agents can validate their work against criteria before returning results.

Diagram

Validation Flow

pass

fail

๐Ÿค– Agent

๐Ÿ“ Output

โœ… Criteria

๐Ÿ“ค Return

๐Ÿ”„ Retry

Quick Start

  1. Simple Usage
    typescript
    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
    const agent = new Agent({
      criteria: [
        'Contains at least 500 words',
        'Includes an introduction',
        'Has actionable takeaways'
      ]
    });

User Interaction Flow

Diagram
ValidatorAgentUserValidatorAgentUseralt[Passes][Fails]“Write an article”Generate contentCheck criteriaโœ… ValidFinal outputโŒ RetryImprove and retry

Configuration Levels

typescript
// 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

OptionDescription
rulesList of validation rules
maxRetriesAttempts before failing
strictFail on any criteria miss

API Reference

AgentConfig

Agent configuration including criteria


Best Practices

Be specific

“At least 500 words” is better than “long enough”.

Keep criteria measurable

Criteria the agent can verify work best.

Set retry limits

Prevent infinite loops with maxRetries.


Related