Lab
Test and debug agents: see what an agent sees, explain and replay a wrong reply, simulate conversations and run saved tests. A simulation runs a whole conversation.
The objects here:
- A frozen turn: every agent reply keeps the exact request its model
received and the response it gave, named by the reply's
metadata.llm_request_id. Reading, diagnosing and replaying a turn work on that frozen payload, so they show what the model saw then, not what the configuration says now, and take no branch. - A rendered context: what an agent's model would receive on a branch right now (view blocks, tools, readiness), assembled without a turn or a model call.
- A diagnosis: a structured verdict on one turn, judged against a complaint (what went wrong), with a classification that decides where the fix belongs and ready-to-run replay arguments.
- A simulation: whole conversations between a simulated contact and the agent on a branch, with tools mocked and nothing written unless asked.
- Saved tests: AgentTests (one pinned turn with checks), SimulationTests (a saved scenario with requirements) and a Workflow's acceptance scenarios, run together in small targeted selections.
Conventions:
- Everything except reading a turn and rendering a context runs the real model, so it costs money. Test runs are capped per call; run only what a change touches.
- Long operations (diagnose, replay, simulate, test runs) are
asynchronous by default: a slow call answers
202 Acceptedwith an async id to poll, as described under Async operations in the API reference introduction. - Simulations never reach a live integration by default and never write
to
main; routes that takebranchtest that branch's configuration. - The lab explains what the model decided. Runtime defects (latency, audio, telephony, delivery) leave no trace in a frozen turn; look at the call record and logs by request id instead.
To change what an agent does, edit its configuration on a branch with the entities resource and promote it through a changeset, attaching lab runs as evidence.
Operations
- Save an agent reply as a regression test.
POST /Platform/lab/create-test - Diagnose why an agent reply went wrong.
POST /Platform/lab/diagnose - Ask another model whether one LLM call's response was right for its request.
POST /Platform/lab/evaluate-llm - Record your own judgement of one LLM call.
POST /Platform/lab/label-llm - List LLM calls in this org, newest first.
GET /Platform/lab/llm-calls - Read the frozen model request and response behind a reply, with the call's ledger record and its judgements (labels).
GET /Platform/lab/llm-data - Preview what an agent's model would receive.
GET /Platform/lab/render-context - Replay the frozen payload behind a turn, with edits.
POST /Platform/lab/replay-llm - Run a targeted selection of saved tests.
POST /Platform/lab/run-tests - Simulate whole conversations with an agent from a scenario.
POST /Platform/lab/simulate
Objects
CreateTestResponse
test_id: str. Id of the saved AgentTest.test_name: optional str or null. Its name.live_entity_keys: optional List[str]. Entity views rebuilt from current state on each run.initial_run_status: optional "passed" or "failed" or "flaky" or "error" or "not_requested". Outcome of the initial run; not_requested when run was false.initial_run_error: optional str or null. Why the initial run could not execute (status error).initial_run_result: optional InitialRun or null. The initial run's per-check verdicts.
DiagnoseResponse
message_id: optional str or null. Assistant message analyzed, when given.llm_request_id: str. Frozen request analyzed.classification: "tool_response_issue" or "tool_unavailable" or "tool_not_enabled" or "context_bloat" or "ambiguous_instructions" or 8 more. ROOT CAUSE. Determines the fix path.frozen_turn_classification: optional "tool_response_issue" or "tool_unavailable" or "tool_not_enabled" or "context_bloat" or "ambiguous_instructions" or 8 more or null. What the analyzed turn itself did, when it differs from the root cause — typically state_carryover_error when the turn inherited a decision made earlier in the trajectory.root_cause: optional DiagnoseRootCause or null. Where the wrong decision was first made.propagation_chain: optional List[int]. Message indices from the root-cause turn to the frozen turn through which the wrong decision propagated.operative_term: optional str or null. The caller's phrase whose handling is under complaint (e.g. "blood work"). Used to test whether the instructions were clear.cited_instruction_quote: optional str or null. Exact instruction text the analyzer says decides the behavior. For model_slip it must literally appear in the frozen instructions and contain the operative term, else the verdict is downgraded to ambiguous_instructions.complaint_verdict: "confirmed" or "contradicted" or "undeterminable". Whether the payload actually supports the complaint.evidence_of_engagement: optional bool or null. Whether the response quoted, paraphrased, or acted on the tool data relevant to the complaint. A data_presentation verdict requires True; False with that label is downgraded to ambiguous_instructions (the data was never read, so its shape cannot be the cause). None when the analyzer did not say.summary: optional str or null. The verdict in a few sentences.evidence: optional List[DiagnoseEvidence]. Pinpointed artifacts behind the verdict.other_deviations: optional List[DiagnoseOtherDeviation]. Secondary instruction deviations seen in the trajectory that were not needed to explain the complaint.suggested_fix: DiagnoseSuggestedFix. The proposed fix and ready-to-run replay arguments.validation: optional DiagnoseValidation. Replay measurement of the verdict; only run with validate=True.suggested_checks: optional List[str]. Checks to pin this as an AgentTest.follow_up_questions: optional List[str]. Set when evidence was insufficient.analyzer_model: str. Model that produced the analysis.diagnosis_cost_usd: optional float or null. What the analysis cost, in US dollars, when known.parse_degraded: optional bool. The analyzer's JSON needed repair, so fields may be partial. Treat the verdict as lower-confidence.
EvaluateLlmResponse
llm_request_id: str. The call that was judged.verdict: optional "correct" or "wrong" or "unsure" or null. The judge's verdict on the response.reasoning: optional str or null. Why the judge reached its verdict.evidence: optional List[str]. Quotes from the request or response the verdict rests on.judge_model: optional str or null. Concrete model that judged (never a tier slug).next_step: optional dict or null. When wrong: run diagnose with this complaint.
LabelLlmResponse
llm_request_id: str. The call that was labeled.label: dict. The stored manual label (verdict, labeled_by, min_model, note).verdict: optional str or null. The call's current verdict after this label (a human label outranks a judge's).
LlmCallsResponse
count: int. Rows returned.rows: optional List[dict]. One content-free record per LLM round: attribution (call_site, model_source, tier, model_resolved), sample keys, requested params, fingerprints, outcome and latency. Add preview=true for a short look at the last user turn and the response.strata: optional List[LlmCallStratum]. The listed rows grouped by response shape and prompt version, largest first.
LlmDataResponse
message_id: optional str or null. Assistant message the request was resolved from, when given.llm_request_id: str. Id of the frozen request.data: dict. Raw cached{request, response}exactly as sent/received. Deliberately untyped: it is the provider's wire format, and reshaping it here would defeat the point of a ground-truth dump.call: optional dict or null. The call's ledger record (attribution, outcome, cost, current verdict and agreement); null for calls made before the ledger existed.labels: optional List[dict]. Judgements of this call, oldest first.
RenderContextResponse
agent_id: str. Agent rendered.agent_name: optional str or null. Its name.branch: str. Branch whose entity state was rendered.touchpoint: optional str or null. The touchpoint the agent was rendered as reached through (<Type>:<id>), when one was given.blocks: optional List[RenderedContextBlock]. View blocks in placement order.total_chars: optional int. Characters across all blocks.effective_tool_access: optional List[EntityTools]. The agent's tool_access merged with attached workflows' grants, one entry per entity class (allow null = every tool on the class).collected_tools: optional List[str]. Qualified Class.method names the agent's entity graph actually yields after the filter — what the model would be handed as tools (session-transient tools such as Call.transfer_call are added by the channel and are not included).turn_notes: optional List[str]. Lines the touchpoint adds to each turn beside the newest message, outside the cached prompt (through the browser extension: whether your browser tab is connected). Empty without a touchpoint.content_tools: optional Dict[str, List[str]]. Per channel (voice,webchat), the content tools the turn offers on top of the collected tools: how the agent speaks or replies, andpresent_ui(pages in chat) where the organization turned it on. Absent on a channel = none.filter_patterns_matching_nothing: optional List[str]. Class.method names explicitly allowed by tool_access that matched no collected tool — a dead name or an unattached integration.session_only_patterns: optional List[str]. Explicitly allowed Class.method names on session types (Call, Conversation, Agent, touchpoints) that only exist once a conversation arrives; absent from a dry run by design, so not counted as dead.readiness: optional AgentReadiness or null. What is still missing before the agent can run its workflows.readiness_failure: optional str or null. Why readiness could not be computed, when it failed.rendered: optional str or null. All blocks concatenated in placement order (render=true).
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.
RunTestsResponse
branch: optional str or null. Branch tests ran on; null means your configured branch.response_samples: int. Fresh generations per AgentTest.judge_runs: int. Judge retries per semantic check.estimated_agent_generations: int. Agent generations the AgentTests needed (tests x samples).elapsed_ms: float. Wall time of the run, in milliseconds.total: int. Entries in results.passed: int. Entries that passed.failed: int. Entries that failed.flaky: int. Entries that passed in some samples only.errored: int. Entries that could not run.results: optional List[RunTestsEntry]. One entry per test.
SimulateResponse
agent_id: str. Agent under test.branch: optional str or null. Branch whose entity state drove the runs. Withstore=trueit is also where the simulated conversations were persisted; null means the caller's configured branch (ephemeral run, nothing written).store: optional bool. Whether the simulated conversations were persisted.moment_now: optional str or null. Frozen clock (ISO instant) the runs were evaluated at; null = wall clock.n: int. Runs executed:nfor one scenario, one per scenario for a list of scenarios.goal_met_count: int. Runs whose simulated caller reached its goal.runs: optional List[SimulateRun]. One entry per run.requirements: optional List[str]. The requirements judged.tool_responses: optional List[ToolFixture]. The tool fixtures this simulation ran with (normalized), echoed back so the async result is self-describing and replayable.requirements_passed_count: optional int or null. Requirement verdicts that passed, across all runs.requirements_total_count: optional int or null. Judged requirements across all runs (n x requirements).all_requirements_passed: optional bool or null. Every requirement passed in every judged run.cost: optional SimulateCost or null. What the agent under test cost across all runs, including the tools, live reads and subagents it triggered, in US dollars at provider prices before any billing margin. Excludes the simulated contact, generated tool responses and judges. Runs replayed from the response cache cost (close to) nothing; pass a newmoment_nowto measure fresh runs.cost_per_run_usd: optional float or null. Mean ofcost.total_usdover the runs that started: what one conversation with this agent costs, in US dollars at provider prices before any billing margin, including writing the prompt cache. Seewarm_cache_cost_per_run_usdfor the cost once the cache is warm.warm_cache_cost_per_run_usd: optional float or null. Mean ofcost.warm_cache_usdover the runs that started: what one conversation costs when the prompt cache is already warm, as for clients who follow each other, in US dollars at provider prices before any billing margin. Conversations started at the same moment each pay the cache write.report: optional str or null. The answer toreportacross all runs: for one run, that run'sreport; for several, one more cheap-model call that combines the per-run answers. Null withoutreport.report_cost_usd: optional float or null. What thereportcalls cost (one per run, plus the combining call for several runs), in US dollars at provider prices before any billing margin. Never part ofcost. Null withoutreport.spend_usd: optional float or null. Everything the runs and reports of this call spent, in US dollars at provider prices before any billing margin: the agent, the simulated contact, the judges andreport_cost_usd. Generated tool responses are not counted. A batch stops starting runs once its runs' part of this passes the batch spend cap.