Personas
Controlling simulated user behavior and guardrails.
Personas define who the simulated user is and how they should behave. This is critical for generating diverse and realistic test data.
Persona Structure
const persona = {
name: 'Anxious Traveler',
description: 'You are in a hurry and get easily frustrated if details are missed.',
guardrails: [
'Always mention your flight number',
'Do not provide your credit card info until asked twice',
'Be concise and slightly impatient'
],
};Using Personas for Testing
You can create different personas to test how your agent handles various user types:
- The Power User: Provides all information upfront in one message.
- The Confused Novice: Asks for clarification on every step.
- The Grumpy Customer: Uses negative sentiment and tries to derail the conversation.
- The International User: Uses different date formats or currency symbols.
Guardrails
Guardrails are strictly enforced instructions for the user model. They are appended to every prompt sent to the LLM playing the user.
const trajectory = createTrajectory({
goal: '...',
persona: {
description: '...',
guardrails: ['Never use emojis', 'Always reply in French'],
},
// ...
}, agent);