Skip to main content
Agent Simulation drives the agent under test through realistic multi-turn conversations without writing test transcripts by hand. evaluatorq generates the personas, scenarios, and opening messages, then scores each conversation with an LLM judge. Three LLMs work together in every simulation:
  • 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.
This page covers running simulations and reading the results in Orq.ai. For the full library reference, provider resolution, and the complete example set, see the evaluatorq agent simulation guide.

Prerequisites

  • Python 3.10 or later
  • Install the package with the simulation extras:
Set the API key. When targeting an Orq.ai agent, 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 is generate_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
The result is a list of 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.
Simulations run with parallelism=5 by default. Lower it if the target’s rate limits are strict, or raise it for faster runs.

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 target to test an agent that is not hosted in Orq.ai
The callback form, with upload_results=False for a local-only run:
Python
The only difference between the two forms is the target: a hosted Orq.ai agent key or the callback function. Personas, scenarios, criteria, and the returned results are identical. Two details matter for the callback form:
  • sim_model chooses the model for the simulator and judge. The provider resolves from ORQ_API_KEY (the Orq.ai router) or OPENAI_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
Batch forms generate_personas([...]) and generate_scenarios([...]) take a list of seed phrases and return one object per seed.
The seed guides generation; it is not a transcript to replay. Generation fills in the persona traits and scenario criteria and writes a natural opening message. Each run explores the space around the pattern rather than replaying one recorded conversation.

Full control

Define Persona, 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.
Pass the agent key with the agent: prefix.
Python

Replay saved cases

Every case a simulation runs is one SimulationDatapoint: 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 with load_datapoints_from_jsonl()
  • dataset_id: an Orq.ai dataset
  • experiment_id: rows of an Orq.ai experiment
  • previous_run: a run stored under .evaluatorq/sim-runs/
  • personas and scenarios: passed inline
On the CLI, cases are written with --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 one SimulationResult: 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

When ORQ_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:
Each conversation is logged as a datapoint with its persona, scenario, transcript, and evaluator scores, so runs can be filtered, compared, and tracked over time. Pass 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:
The dashboard serves on 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.