Skip to content

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 define the characteristics, context, and goals of the simulated actor.

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_description
user_sim = ActorSimulator.from_case_for_user_simulator(case=case)
# Access the generated profile
print(user_sim.actor_profile.traits)
print(user_sim.actor_profile.context)
print(user_sim.actor_profile.actor_goal)

For more control, create custom profiles:

from strands_evals.simulation import ActorSimulator
from strands_evals.types.simulation import ActorProfile
# Define custom profile
profile = 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 profile
simulator = 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_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
)
from strands import tool
@tool
def 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
)
user_sim = ActorSimulator.from_case_for_user_simulator(
case=case,
model="global.anthropic.claude-sonnet-5", # Specific model
max_turns=10
)