Layer 5: Persona
Overview
Section titled “Overview”The Persona Layer (L5) defines the agent’s identity, personality traits, behavioral constraints, and how it presents itself to users. This is the top layer of ARAL-CORE.
fingerprint Identity
Who the agent is
masks-theater Personality
How the agent behaves
ban Constraints
What the agent won’t do
comment Tone & Style
How the agent communicates
Persona Definition
Section titled “Persona Definition”interface Persona { // Identity id: string name: string role: string description: string
// Personality traits traits: PersonalityTrait[] values: string[]
// Behavioral constraints constraints: Constraint[] ethicalGuidelines: string[]
// Communication style tone: Tone language: string formality: 'formal' | 'casual' | 'professional'
// Capabilities boundaries expertise: string[] limitations: string[]}
interface PersonalityTrait { name: string description: string weight: number // 0.0 to 1.0}
const customerServicePersona: Persona = { id: 'cs-agent-001', name: 'Emma', role: 'Customer Service Representative', description: 'Helpful and empathetic customer service agent',
traits: [ { name: 'helpful', description: 'Always tries to assist', weight: 1.0 }, { name: 'patient', description: 'Never rushes customers', weight: 0.9 }, { name: 'empathetic', description: 'Shows understanding', weight: 0.8 } ],
values: [ 'Customer satisfaction is priority', 'Honesty over quick fixes', 'Respect for all users' ],
constraints: [ 'Never make promises we cant keep', 'Never share confidential information', 'Never engage in arguments' ],
ethicalGuidelines: [ 'Treat all users equally', 'Protect user privacy', 'Be transparent about limitations' ],
tone: 'friendly', language: 'en', formality: 'professional',
expertise: ['product knowledge', 'troubleshooting', 'returns'], limitations: ['Cannot process refunds directly', 'Cannot access payment info']}Behavioral Contract
Section titled “Behavioral Contract”The persona enforces behavioral rules:
class PersonaBehaviorEnforcer { constructor(private persona: Persona) {}
async validateAction(action: string, params: any): Promise<ValidationResult> { // Check against constraints for (const constraint of this.persona.constraints) { if (this.violatesConstraint(action, params, constraint)) { return { allowed: false, reason: `Violates constraint: ${constraint}` } } }
// Check expertise boundaries if (!this.isWithinExpertise(action)) { return { allowed: false, reason: 'Outside area of expertise' } }
return { allowed: true } }
async filterResponse(response: string): Promise<string> { // Apply tone response = await this.applyTone(response, this.persona.tone)
// Enforce formality response = await this.adjustFormality(response, this.persona.formality)
// Check constraints response = await this.enforceConstraints(response)
return response }
private async applyTone(text: string, tone: Tone): Promise<string> { const tonePrompts = { friendly: 'Make this response warm and friendly', professional: 'Make this response professional', casual: 'Make this response conversational', formal: 'Make this response formal' }
return await this.llm.transform(text, tonePrompts[tone]) }}Personality Traits in Action
Section titled “Personality Traits in Action”class PersonalityEngine { async generateResponse( input: string, persona: Persona ): Promise<string> { // Build persona-aware prompt const prompt = `You are ${persona.name}, a ${persona.role}.
Your personality:${persona.traits.map(t => `- ${t.name}: ${t.description}`).join('\n')}
Your values:${persona.values.map(v => `- ${v}`).join('\n')}
Your constraints:${persona.constraints.map(c => `- ${c}`).join('\n')}
Respond to: ${input}
Remember to:- Match your tone (${persona.tone})- Stay within your expertise- Honor your constraints `
const response = await this.llm.complete(prompt)
// Validate response matches persona await this.validatePersonaAlignment(response, persona)
return response }
private async validatePersonaAlignment( response: string, persona: Persona ): Promise<void> { // Check if response violates constraints for (const constraint of persona.constraints) { if (this.violatesConstraint(response, constraint)) { throw new PersonaViolationError( `Response violates constraint: ${constraint}` ) } }
// Check tone alignment const detectedTone = await this.detectTone(response) if (detectedTone !== persona.tone) { console.warn(`Tone mismatch: expected ${persona.tone}, got ${detectedTone}`) } }}Configuration Example
Section titled “Configuration Example”{ "layers": { "persona": { "id": "tech-support", "name": "Alex", "role": "Technical Support Specialist", "description": "Expert technical support agent",
"personality": { "traits": [ { "name": "knowledgeable", "weight": 1.0 }, { "name": "patient", "weight": 0.9 }, { "name": "detail-oriented", "weight": 0.8 } ], "values": [ "Accuracy over speed", "User empowerment", "Continuous learning" ] },
"behavior": { "constraints": [ "Never guess if unsure", "Always verify before suggesting fixes", "Never blame the user" ], "ethicalGuidelines": [ "Respect user privacy", "Admit when wrong", "Provide honest limitations" ] },
"communication": { "tone": "professional", "formality": "professional", "language": "en", "avoidJargon": false, "useExamples": true },
"expertise": { "areas": [ "Software troubleshooting", "Hardware diagnostics", "Network configuration" ], "limitations": [ "Cannot remote access systems", "Cannot modify user data", "Cannot make purchasing decisions" ] } } }}Persona Templates
Section titled “Persona Templates”Customer Service
{ "role": "Customer Service", "traits": ["helpful", "patient", "empathetic"], "tone": "friendly", "constraints": [ "Never make unauthorized promises", "Always escalate complaints appropriately" ]}Technical Expert
{ "role": "Technical Expert", "traits": ["precise", "thorough", "analytical"], "tone": "professional", "constraints": [ "Provide accurate technical information", "Admit when unsure", "Reference documentation" ]}Creative Assistant
{ "role": "Creative Assistant", "traits": ["imaginative", "encouraging", "flexible"], "tone": "casual", "constraints": [ "Respect intellectual property", "Provide original ideas", "Credit inspirations" ]}Best Practices
Section titled “Best Practices”Persona Design
✅ DO:
- Define clear identity and role
- Choose consistent personality traits
- Set explicit constraints
- Document limitations
❌ DON’T:
- Create conflicting traits
- Leave constraints vague
- Overpromise capabilities
Ethical Considerations
✅ DO:
- Include ethical guidelines
- Respect user autonomy
- Be transparent about AI nature
- Protect user privacy
❌ DON’T:
- Manipulate users
- Impersonate humans
- Cross ethical boundaries
Consistency
✅ DO:
- Maintain persona across sessions
- Validate responses for alignment
- Log persona violations
- Iterate based on feedback
❌ DON’T:
- Switch personalities mid-conversation
- Ignore constraint violations
- Skip validation
Testing Personas
Section titled “Testing Personas”describe('Persona Layer', () => { it('should enforce constraints', async () => { const persona = createCustomerServicePersona() const enforcer = new PersonaBehaviorEnforcer(persona)
// Try action outside expertise const result = await enforcer.validateAction( 'modify-user-payment', {} )
expect(result.allowed).toBe(false) expect(result.reason).toContain('Outside area of expertise') })
it('should maintain consistent tone', async () => { const persona = { ...defaultPersona, tone: 'professional' } const engine = new PersonalityEngine()
const responses = await Promise.all([ engine.generateResponse('Hello', persona), engine.generateResponse('Help me', persona), engine.generateResponse('Thank you', persona) ])
for (const response of responses) { const tone = await detectTone(response) expect(tone).toBe('professional') } })})