- Target agent: the system under test, either a hosted Orq.ai agent (
target="agent:<key>") or any async function - User simulator: plays a persona pursuing a scenario goal, turn by turn
- Judge: scores whether the goal was met and whether any rules were broken
Agent Simulation is available in the Python version of evaluatorq only. The TypeScript version does not support it.
Prerequisites
- Python 3.10 or later
- Install the package with the
simulationextras:
ORQ_API_KEY is the only key needed: the simulator, the judge, and the generators route through the Orq.ai router.
First simulation
The fastest start isgenerate_and_simulate(): it synthesizes the personas, scenarios, and opening messages from a short description of the agent. num_personas × num_scenarios conversations run in parallel.
Python
SimulationResult objects, one per conversation.
evaluator_names selects the scorers applied to each conversation, see Simulation results.
When ORQ_API_KEY is set, results are uploaded to Orq.ai as an Experiment by default. See Results in Orq.ai.
Agents with a memory store attached reject calls that carry no memory scope (a 400 with
memory_entity_id_required). A fresh entity id is minted per conversation automatically, so parallel conversations never share memory. Pass memory_entity_id="..." to run every conversation against one specific, for example pre-seeded, entity instead.Generate from a description
generate_and_simulate() creates personas, scenarios, and opening messages from a brief agent description. Use it for a quick first pass.
Two target forms are supported:
- A hosted Orq.ai agent:
target="agent:<key>". The call is identical to First simulation - Any async function: pass it as
targetto test an agent that is not hosted in Orq.ai
upload_results=False for a local-only run:
Python
sim_modelchooses the model for the simulator and judge. The provider resolves fromORQ_API_KEY(the Orq.ai router) orOPENAI_API_KEY(OpenAI-compatible)- The callback is plain Python: it calls
AsyncOpenAI(), so it needs that provider’s key unless it routes through Orq.ai
Seed by archetype
Instead of specifying every trait by hand, name an archetype.generate_persona() fills in the rest of a Persona; generate_scenario() fills in the rest of a Scenario. The returned objects can be inspected, tweaked, and passed to simulate().
Python
Full control
DefinePersona, Scenario, and Criterion objects by hand to set exact traits, goals, and pass/fail rules.
A persona is who is talking. name, patience, assertiveness, politeness, technical_level, communication_style, and background are required; only emotional_arc and cultural_context are optional.
A scenario is what they want, plus the criteria the agent must, or must not, satisfy. Only name and goal are required.
- Orq agent
- Custom callback
Pass the agent key with the
agent: prefix.Python
Replay saved cases
Every case a simulation runs is oneSimulationDatapoint: a persona, a scenario, and the opening message.
Save the generated cases to a file once, then re-run the same cases against any target.
The file pins the personas, scenarios, and first messages, so a run is reproducible. Use it to compare two agent versions on an identical set of conversations.
simulate() takes one input source per run. The five sources are mutually exclusive:
datapoints: cases loaded from a JSONL file withload_datapoints_from_jsonl()dataset_id: an Orq.ai datasetexperiment_id: rows of an Orq.ai experimentprevious_run: a run stored under.evaluatorq/sim-runs/personasandscenarios: passed inline
--datapoints and replayed with --input.
eq sim from-traces builds new cases from production traces instead.
See the evaluatorq agent simulation guide for the full flag set.
Simulation results
Each persona/scenario pair produces oneSimulationResult:
The result also carries
terminated_by, reason, token_usage, criteria_results, and last_trace_id. See the Python API reference for the full shape.
evaluator_names accepts any of the built-in evaluatorq scorers:
"goal_achieved" and "criteria_met" are used by default when evaluator_names is omitted.
Results in Orq.ai
WhenORQ_API_KEY is set, results are uploaded to the workspace as an Experiment run (upload_results defaults to True). A direct link is printed at the end of the run:
upload_results=False for a local-only run.
Exploring runs locally
Every run is also saved to.evaluatorq/sim-runs/ in the working directory.
The CLI saves runs by default (--no-save skips it). The SDK opts in per run with save=True on simulate() or generate_and_simulate().
The evaluatorq dashboard reads that store and renders the saved runs:
http://127.0.0.1:8080 by default.
Unlike a single-run view, it indexes every saved run, so simulations can be compared over time. List saved runs from the command line with eq sim runs.
The dashboard is a preview and still under active development. Its layout and options may change between releases.
Going further
The evaluatorq documentation covers the parts of Agent Simulation that sit outside Orq.ai:Agent simulation guide
Provider resolution, memory-backed agents, and trace-grounded case generation.
Agent simulation examples
Runnable examples covering tool simulation, hardening loops, and framework targets.
Python API reference
Full signatures for
simulate(), generate_and_simulate(), and the simulation contracts.CLI reference
Every
eq sim command and flag.Agent Simulation cookbook
Step-by-step walkthrough of the same feature, including a plain-OpenAI setup.