Criteria
Define success conditions for agent tasks
Agents can validate their work against criteria before returning results.
Quick Start
- 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 - With Configuration
typescript 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
| Option | Description |
|---|---|
rules | List of validation rules |
maxRetries | Attempts before failing |
strict | Fail on any criteria miss |
API Reference
AgentConfigAgent 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.