Persona Agent Changes
Summary of modifications to the OpenAI CUA sample app to support persona-driven user testing.
Persona Agent Changes
Summary of modifications to the OpenAI CUA sample app to support persona-driven user testing.
Modified Files
1. agent/agent.py (Minimal Changes)
Added:
instructionsparameter to__init__()- accepts system-level persona instructionsenable_reasoningparameter to__init__()- enables CUA reasoning API- Logic in
run_full_turn()to pass both parameters to the Responses API
Why: Allows dynamic persona instructions and captures reasoning for each action.
Backward Compatible: Yes - both parameters default to None/False.
2. persona_agent.py (New File)
Core Features:
- Accepts instructions and scenario as command-line arguments (not hardcoded)
PersonaTestingReportclass for comprehensive tracking:- Action timeline with timestamps
- Reasoning trail from CUA API
- Auto-detection of friction points (keyword-based)
- Final evaluation capture
- JSON export and human-readable output
Command-line Arguments:
--instructions: Path to file or inline string (required)--scenario: Path to JSON file or inline JSON (required)--url: Website to evaluate (required)--persona-name: Name for report (optional, default "Persona")--computer: Browser environment (optional, default "local-playwright")--debug: Debug output (optional)--show: Show screenshots (optional)--output: Save report to JSON file (optional)
Scenario Format (Exactly 5 fields required):
{
"scenario": "string",
"entry_point": "string",
"device": "mobile|desktop|tablet",
"time_pressure": "low|medium|high",
"emotional_state": "string"
}
New Files Created
Documentation
PERSONA_AGENT.md- Full documentationQUICK_START.md- Quick reference guideexamples/PERSONA_EXAMPLES.md- Example personas guide
Example Personas
Sarah Kim (New Parent):
examples/sarah_kim_instructions.txtexamples/sarah_kim_scenario.json
Alex Chen (Tech Shopper):
examples/alex_chen_instructions.txtexamples/alex_chen_scenario.json
Key Design Decisions
✅ What We Did
- No Hardcoding: Instructions and scenarios are inputs, not constants
- Generic Reports: Work for any persona/scenario (not tied to specific domains)
- CUA Reasoning API: Uses built-in reasoning instead of text parsing
- Friction Detection: Automatically flags issues based on reasoning keywords
- Minimal Changes: Only extended Agent class, didn't modify core logic
- Flexible Input: Support both file-based and inline inputs
❌ What We Avoided
- Domain-Specific Parsing: No hardcoded extraction of "pricing" or "delivery terms"
- Hardcoded Personas: Everything is parameterized
- Complex Text Analysis: Let the model provide structured reasoning
- Breaking Changes: All changes are backward compatible
Usage Examples
Basic
python persona_agent.py \
--instructions examples/sarah_kim_instructions.txt \
--scenario examples/sarah_kim_scenario.json \
--url https://example.com \
--persona-name "Sarah Kim"
Inline
python persona_agent.py \
--instructions "You are a shopper..." \
--scenario '{"scenario":"...","entry_point":"...","device":"mobile","time_pressure":"high","emotional_state":"..."}' \
--url https://example.com
With Output
python persona_agent.py \
--instructions examples/sarah_kim_instructions.txt \
--scenario examples/sarah_kim_scenario.json \
--url https://example.com \
--output report.json
Testing Report Structure
{
"persona": "Sarah Kim",
"scenario": {...},
"test_details": {
"start_url": "...",
"duration_seconds": 67.3,
"total_actions": 5,
"timestamp": "2025-10-10T..."
},
"actions_taken": [
{
"timestamp": 3.2,
"action_type": "scroll",
"details": {"direction": "down"},
"reasoning": "Looking for pricing..."
}
],
"reasoning_trail": [...],
"friction_points": [
{
"timestamp": 12.1,
"action": "scroll",
"issue": "Pricing not clearly visible"
}
],
"final_evaluation": "...",
"summary": {
"action_types": {"scroll": 2, "click": 3},
"friction_count": 1,
"completed": true
}
}
Integration with Original Code
The persona agent reuses all existing infrastructure:
utils.create_response()- API callsAgent.run_full_turn()- CUA loopcomputersmodule - Browser environments- Safety checks and callbacks
Only addition: optional instructions and enable_reasoning parameters to Agent.
Related Documents
Dota 2 Analysis Persona
You are a senior Dota 2 analyst providing written analysis of match replays. Your background includes professional play experience (TI qualifiers, 11k peak MMR) and extensive coaching. You deliver insights through structured analysis, not live dialogue.
AI_persona
You are a deep-thinking CodeNavigator, an elite AI coding assistant specializing in comprehensive codebase management, systematic debugging, and strategic code improvement. Your core purpose is helping developers maintain and enhance complex codebases with surgical precision and architectural foresight. You may use an extremely long chain of thoughts to deeply consider the problem and deliberate with yourself via systematic reasoning processes to help come to a correct or most optimal solution b
CTO Persona
You are a senior CTO with 20+ years of experience building and shipping quality software.
System Persona: The Awareness Engine
**Instructions for the User:**