Customizing user simulation
The from_case_for_user_simulator() factory configures a working user simulator
from a Case. When you need more control over how the simulated user behaves,
override its profile, system prompt, tools, or model.
Actor profiles
Section titled “Actor profiles”Actor profiles define the characteristics, context, and goals of the simulated actor.
Automatic profile generation
Section titled “Automatic profile generation”The simulator can automatically generate realistic profiles from test cases:
from strands_evals import Case, ActorSimulator
case = Case( input="My order hasn't arrived yet", metadata={"task_description": "Order status resolved and customer satisfied"})
# Profile is automatically generated from input and task_descriptionuser_sim = ActorSimulator.from_case_for_user_simulator(case=case)
# Access the generated profileprint(user_sim.actor_profile.traits)print(user_sim.actor_profile.context)print(user_sim.actor_profile.actor_goal)Custom actor profiles
Section titled “Custom actor profiles”For more control, create custom profiles:
from strands_evals.simulation import ActorSimulatorfrom strands_evals.types.simulation import ActorProfile
# Define custom profileprofile = ActorProfile( traits={ "expertise_level": "expert", "communication_style": "technical", "patience_level": "low", "detail_preference": "high" }, context="A software engineer debugging a production memory leak issue.", actor_goal="Identify the root cause and get actionable steps to resolve the memory leak.")
# Create simulator with custom profilesimulator = ActorSimulator( actor_profile=profile, initial_query="Our service is experiencing high memory usage in production.", system_prompt_template="You are simulating: {actor_profile}", max_turns=10)Custom system prompts
Section titled “Custom system prompts”custom_prompt = """You are simulating a user with the following profile:{actor_profile}
Guidelines:- Be concise and direct- Ask clarifying questions when needed- Express satisfaction when goals are met- Set `stop=True` on your structured response when your goal is achieved"""
user_sim = ActorSimulator.from_case_for_user_simulator( case=case, system_prompt_template=custom_prompt, max_turns=10)Adding custom tools
Section titled “Adding custom tools”from strands import tool
@tooldef check_order_status(order_id: str) -> str: """Check the status of an order.""" return f"Order {order_id} is in transit"
user_sim = ActorSimulator.from_case_for_user_simulator( case=case, tools=[check_order_status], # Additional tools for the simulator max_turns=10)Different model for simulation
Section titled “Different model for simulation”user_sim = ActorSimulator.from_case_for_user_simulator( case=case, model="global.anthropic.claude-sonnet-5", # Specific model max_turns=10)Related documentation
Section titled “Related documentation”- User Simulation: Run multi-turn user simulation evaluations
- Simulators Overview: Learn about the ActorSimulator and simulator framework
- Quickstart Guide: Get started with Strands Evals