Simulate whole conversations with an agent from a scenario

POST /Platform/lab/simulate

Simulate whole conversations with an agent from a scenario.

Single-turn diagnose/replay can't catch trajectory failures (wrong tool sequence, bad state carryover, context dilution, recover-then-relapse). Simulation drives an LLM-simulated caller against the agent for up to max_turns turns and returns the transcript; every agent turn carries its llm_request_id for diagnose / replay_llm / create_test.

Safety: mock is forced — irreversible tools never execute (they get an LLM-generated, schema-valid response). By default an un-fixtured READ runs against the live read API once, memoized per scenario, so the agent never acts on invented data it was not told to expect. mock_all_tools=true instead answers every un-fixtured tool (reads included) with a generated response consistent with the scenario and the fixtures — no live integration at all. Nothing is written by default (ephemeral: no Conversation/Message rows, no branch); store=true persists the conversations off main.

Reproducibility: the whole run is evaluated at moment_now (default: the instant the run starts) — system-prompt clock, tool utcnow, message timestamps, and the simulated caller (cached per run index). Pass the SAME moment_now and scenario text again and the run replays from the LLM response cache and the tool-read memo (fast, no fresh generation); pass a new one to force a fresh run. Workflow.run_scenarios stores a moment per scenario for exactly this.

Costs money: every agent turn, simulated-contact turn, generated tool response and judge verdict is a real model call. The response reports what the agent itself cost, per run (cost, with the part spent writing the prompt cache) and on average, cold (cost_per_run_usd) and with a warm cache (warm_cache_cost_per_run_usd). Asynchronous by default (pollable result). With requirements an LLM judge grades each run's transcript (one judge call per requirement per run) and the response carries PASS/FAIL with explanations plus totals. Attach a run to a changeset as test_evidence=[{"tool": "lab simulate", "ref_id": <async_id>, ...}], where async_id is the id this call answers with (the response itself carries no id). The changeset records the id as given; the result stays pollable for a day, while each turn's llm_request_id stays usable for diagnose / replay_llm. Reproduce a trajectory incident by seeding from a real conversation (seed_conversation_id + up_to_message_id) and rerunning with n=5 to measure relapse.

Many contacts in one call: pass scenario a list of scenarios, one text per contact with that contact's own facts; each runs once. The first runs alone and writes the agent's prompt cache, then the rest run 6 at a time and read it, so a later run costs about the warm-cache price instead of paying the cache write again, as separate calls started together each would. requirements, tool_responses and moment_now apply to every scenario; each run names its scenario and cost sums the batch. A text given more than once is sampled again for each occurrence, as n repeats are. At most 100 scenarios. A batch stops starting runs once its runs have spent more than $25 (agent, simulated contact and judges; see spend_usd) or after 40 minutes: runs already going finish, and each scenario not started comes back with stop_reason="skipped" and the reason in failure. For a large batch pass detail="summary": each run then carries what the contact got (final_reply), the verdicts and the cost, and the response stays readable whole. Add report to have each run, and the batch as a whole, boiled down to the answer you ask for.

Everything that happens is written in the scenario. Cross-channel events ("once the agent has sent the deposit link, the Stripe webhook lands: $75 deposit recorded"; "two turns in, his wife texts from +1760...: 'add Mochi too'"; "no one writes; the agent's follow-up job for Pesto fires with: ...") and documents the counterparty sends ("her email carries a one-page rabies certificate for Pesto: given 2025-03-02 by Dr. Lee") are read out of the prose into a typed plan (cached per scenario text) and injected the way production would deliver them. Write a stored document's hash in the prose (pdf-53ziH9DvJi8) to attach that real file; a described document is rendered into a PDF. Each run returns its plan and any events_not_fired.

Body parameters

Returns

SimulateResponse

Example request

curl -X POST "https://api.hilus.ai/Platform/lab/simulate" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'