Persona Agent Changes
Extends an OpenAI CUA sample app with a persona-driven testing agent that accepts instructions and scenarios as command-line arguments.
What this file does
Extends an OpenAI CUA sample app with a persona-driven testing agent that accepts instructions and scenarios as command-line arguments.
When to use it
- Adding persona-based user testing to an existing CUA agent
- Generating structured reports with friction detection and reasoning trails
- Parameterizing test scenarios instead of hardcoding them
- Evaluating websites from different user perspectives automatically
Assumes this stack
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.
What's inside
Lists 2 modified files, 1 new file, 3 documentation files, 2 example personas, usage examples, and a report structure.
Change this for your project
- Replace
examples/sarah_kim_instructions.txtwith your own persona instructions - Replace
examples/sarah_kim_scenario.jsonwith your own scenario JSON - Replace
https://example.comwith the URL you want to test
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Accepting persona instructions and scenarios as CLI arguments instead of hardcoding them
- Using a dedicated report class to capture action timeline, reasoning, and friction points
- Keeping backward compatibility by defaulting new parameters to None/False
Related Documents
Dota 2 Analysis Persona
Defines a structured persona for analyzing Dota 2 replays with frameworks, output formats, and tone guidelines.
🏂 Ridge - 滑雪板店铺AI助手
Defines a snowboard specialist persona named Ridge with 5 MCP tool triggers and 4 conversation flow examples for a Shopify chatbot.
AI_persona
Defines a meticulous, systematic AI coding assistant persona focused on codebase management, debugging, and improvement.
CTO Persona
Defines a CTO persona with decision frameworks, quality standards, and communication style for AI-assisted development.