Replay the frozen payload behind a turn, with edits
POST /Platform/lab/replay-llm
Replay the frozen payload behind a turn, with edits.
This is the pre-validation step of the incident workflow: a proposed
change is applied to the cached payload before anything is edited
live. Use one replay for deterministic, low-risk prompt/config
corrections. Use n >= 5 to measure suspected model
slip/flakiness, resolve an ambiguous or inconsistent first replay, or
gate high-impact behavior. The same operation also supports config
probes (models / payload_overrides).
A list of ids runs the same edit across a cohort of real turns, showing that a change moves the target case without disturbing other traffic.
Comparing models ("can this call site / agent / tier switch to M?"):
select a cohort (call_site / agent_id / tier +
since / per_stratum), pass models=[M] and
judge_correctness=true. Every replay is judged against its
original (correct / wrong, which is better) and the verdicts are stored
as labels; each turn is also replayed on its own original model
(baseline) as the noise floor. Read model_report: per model the
correct rate with a 95% interval, regressions (original right, replay
wrong), fixes, errors, cost per call, latency, and the same per
response-shape stratum. Drill into any cell with llm_calls, e.g.
replay_run_id=<run_id>, model_resolved=<M>, verdict=wrong.
model_report compares models, so it leaves out edited replays;
read an edited arm's cost and latency from
llm_calls(replay_run_id=<run_id>) and its per-tool rates from
summary.tool_counts.
When the validated change is promoted through a changeset, attach
the replay as reviewable evidence: pass test_evidence=[{"tool": "lab replay", "ref_id": <replay/llm_request id>, "outcome": "passed"|"failed", "summary": ...}] to entities changeset-open
/ changeset-refresh.
Safe by construction: caching and tool execution are disabled;
integrations are never touched. There is no branch parameter —
the payload is frozen, so a branch cannot rebuild instructions;
branch-aware validation is what live AgentTests (run_tests) are for.
Costs money: n x models real completions per turn, plus
judge and arbiter calls in judge mode, capped at
MAX_REPLAYS_PER_RUN across the run (an over-cap request is refused
with its planned counts before anything runs). REPLAY_CONCURRENCY
turns replay at once, and the run may take up to 30 minutes. In a cohort, a turn
whose cached payload was evicted, or whose replay failed, keeps its
place in results with failure set (and is listed in
selection.missing_ids / selection.failed); match results to
turns by llm_request_id. Asynchronous by
default: requests completing within ~45s (small cohorts) return
their result inline; longer sweeps return HTTP 202 with a pollable
async id (GET /Platform/jobs/async/{async_id}). Force either
behavior per request with ?async= or Prefer: headers.
Body parameters
message_id: optional str. Assistant message id, or a list. Or use llm_request_id.llm_request_id: optional str. Cached request id, or a list.models: optional List[Any]. Replay with these instead of the original model.temperature: optional float. Override for all replays.n: optional int. Completions per model; n >= 3 measures flakiness; keep below 10 without compelling reason.replace_content_strings: optional List[Any].[old, new]string pairs (replaced everywhere), or[index, new_text]to overwrite the text block at that global index. Raises ifoldnever matches.insert_content: optional List[Any].[before_index, text]pairs inserting new text blocks.upsert_tools: optional List[Any]. Tool defs (full OpenAI dicts or bare function schemas) to add or override, matched onfunction.name— an existing name is replaced in place. This supports A/B testing a reworded description, a narrowed enum, or a tool split against real traffic. Property order reaches the model as sent, and the model fills arguments in that order, so build the JSON without sorting keys.remove_tools: optional List[Any]. Tool names to drop, applied beforeupsert_tools. Raises if a name isn't present. Answers whether the model copes without a tool, and proves an override really reached the model. Past calls to a removed tool stay in the history unless rewritten withrewrite_tool_calls.rewrite_tool_calls: optional List[Any].{"name"?, "id"?, "new_name"?, "arguments"?, "result"?}entries. Withnamean entry rewrites EVERY past call to that tool in the history; withidonly the call with that tool_call_id, so each past turn can get its own arguments. A rewrite sets the name, the arguments (a JSON object, written in the key order sent) and the tool result that answers the call. Entries apply in order; unknown keys are refused. Swap a tool coherently withremove_tools=[old]+upsert_tools=[new definition]+rewrite_tool_calls=[{ "name": old, "new_name": new, "arguments": {...}, "result": "ok"}], so the history never calls a tool the request no longer offers. Raises if no past call matches an entry.payload_overrides: optional dict. reasoning_effort, max_tokens, max_completion_tokens, temperature, top_p.inject_tools: optional List[Any]. Deprecated alias forupsert_tools.judge: optional str.Trueenables model-migration diff mode. A criteria string instead judges every replay directly against that requirement and reportscriteria_pass/criteria_failcounts, retaining failed replay bodies so the failure wording is visible. Boolean-looking CLI values (true/false/1/0/yes/no) are coerced to booleans; any other value remains criteria text. In migration mode each replay is classified against the frozen original: a moved behavior signature is alwaystool_diff; a matching signature is judged by an LLM for semantic equivalence of the reply text AND tool arguments (equivalentvscontent_diff), so wording-level model variation does not pollute results. Judge flags are escalated to an ARBITER (arbiter_model) that sees the FULL frozen request plus both completions and rules on correctness: both correct overrules the judge (turn readsequivalentand is omitted); correctness moving one way scoresregressed/improved; both wrong or unverifiable stayscontent_diff. The response is minimal and diff-only:summary.verdicts(the migration scoreboard) plus one compactdiffsentry per DIVERGED turn — the judge's literal[original, replay]excerpt pairs and the arbiter's findings (per-side verdicts, summary, and anyprompt_issuenaming ambiguous instructions). Replay bodies are dropped (rerun on a flagged id to inspect).judge_model: optional str. Equivalence judge (pinned fast default).arbiter_model: optional str. Correctness judge for judge-flagged diffs: reasoning on, sees the full request and both completions, rules each side correct or wrong and which is better (fires only on flagged replays).call_site: optional str. Select the cohort from the call ledger instead of passing ids, by where the completion was requested (code:<path>:<function>orentity:Agent/<id>). The selectors combine and matchllm_calls; simulated conversations, replays and cache hits are excluded.model_source: optional str. Ledger selector: where the model was chosen.tier: optional str. Ledger selector: calls configured with this platform slug (e.g.hilus/low), i.e. the calls a tier change affects.agent_id: optional str. Ledger selector: shorthand forcall_site=entity:Agent/<id>.since: optional str. Ledger window for selectors (7d,12hor ISO).per_stratum: optional int. With selectors, how many calls to replay from each response-shape stratum (tools called, finish reason, prompt version). Picks are the most dissimilar inputs, so rare outcomes and varied requests are always covered.max_candidates: optional int. With selectors, how many recent ledger rows to stratify over.fair: optional bool. Send each candidate model what production would send it: its content quirks (a tool description or turn-context line production words differently for that model, listed per turn inretargeted_quirks) and its sampling/reasoning parameters rebuilt from what the original caller requested, instead of values adjusted for the original model. Defaults to on whenevermodelsis given;falseis the plain model swap of the frozen payload. Calls recorded before the ledger existed keep their original parameters (reported inselection.unfair_ids).judge_correctness: optional bool. Judge every replay's correctness with the reasoning judge (arbiter_model), not only judge-flagged diffs: each replay and its original get labels (correct / wrong, which is better, agreement, reasoning; read them withllm_calls/llm_data). At most one judge call per distinct response per turn; a replay identical to an already-judged original inherits its verdict for free. Verdicts: equivalent (both correct), regressed, improved, content_diff, judge_error, unlabeled (replay not stored), error.baseline: optional bool. Withjudge_correctness, also replay each turn on the model it originally ran on, somodel_reporthas a noise floor to read every other model against (default true).
Returns
ReplayLLMResponse
summary: ReplaySummary. Across every turn.results: List[ReplayTarget]. One per turn, in the order the ids were given (sampling order for selectors), failed turns included withfailureset.selection: optional dict or null. Ledger selection (selectors or fair mode): candidates considered, their response-shape strata, how many were sampled, whether the replay was fair, ids whose parameters stayed as recorded (no ledger row), ids skipped because their cached payload was evicted, and ids whose replay failed (failed: id and failure).run_id: optional str or null. This run's replay_run_id: find its replays with llm_calls(replay_run_id=...); the model report is rebuilt from them.stratum_summaries: optional Dict[str, ReplaySummary] or null. Summary per original response-shape stratum (outcome_sig), so a regression in a rare stratum is not averaged away.model_report: optional ModelReport or null. judge_correctness only: per-model results of this run (baseline = the original model on itself; each arm's correct/wrong rates with 95% intervals, regressions, fixes, errors, cost, latency, per stratum). Rebuilt from the run's stored labels.diffs: optional List[ReplayDiff] or null. Judge mode only: the turns that diverged (empty list = clean sweep). In judge mode per-turn replay bodies are dropped; rerun replay_llm/llm_data on a flagged id to inspect it.
Example request
curl -X POST "https://api.hilus.ai/Platform/lab/replay-llm" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'