Skip to main content
Agents can validate their work against criteria before returning results.

Quick Start

1

Define Success Criteria

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

Multiple Criteria

const agent = new Agent({
  criteria: [
    'Contains at least 500 words',
    'Includes an introduction',
    'Has actionable takeaways'
  ]
});

User Interaction Flow


Configuration Levels

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

“At least 500 words” is better than “long enough”.
Criteria the agent can verify work best.
Prevent infinite loops with maxRetries.