Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions docs/guides/pr-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,19 @@ personality instead.

A scenario with `transcriptReplay` plays a fixed recording into the target
and scores what its transcriber heard (see
[simulations learnings](../learnings/simulations.md#recording-replays)). The
simulations API runs a replay only from a **saved** scenario, so a check
sends a replay scenario by its UUID in the org, not from the branch. The
target is still built from the branch, which is what a replay tests. So:

- The check needs `transport: voice`, and runs only in its own org (no
`runOrg`). A replay in a suite fails the build of every chat check that
runs the suite, so keep replay scenarios in a suite of their own.
- Apply the scenario before the check can run it. The build fails for a
replay scenario that has never been deployed.
- Before a live run, the check reads each saved replay scenario. If the
file's `transcriptReplay`, `evaluations`, `latencyExpectations` or
`toolMocks` differ from the saved copy, the check stops with an error and
sends nothing: apply the scenario, then rerun.
- Replays are in a platform rollout. An org outside it gets a 400 from the
run.
[simulations learnings](../learnings/simulations.md#recording-replays)). Like
every other scenario, a check sends it inline from the branch, so a PR that
edits the recording URL, the answer key or the WER threshold is tested with
those edits, and the scenario needn't be deployed first. The build refuses
what the platform would:

- The check needs `transport: voice` and an assistant target, not a squad.
A replay in a suite fails the build of every chat or squad check that runs
the suite, so keep replay scenarios in a suite of their own.
- A replay scenario takes no `hooks` and no `latencyExpectations`.
- Replays are in a platform rollout. A run org outside it gets a 400 from
the run. An org or target assistant with HIPAA, PCI or zero data
retention must use `answerKeyUrl` instead of an inline `answerKey`.

## 3. Dry run locally (no key, nothing sent)

Expand Down
21 changes: 11 additions & 10 deletions docs/learnings/simulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,12 @@ behaviours worth knowing when a check surprises you.
default error mocks whether or not a tool was called; read tool results
from `metadata.call.messages` (`tool_calls` carry the ids and names,
`tool_call_result` the answers by `toolCallId`).
- **Replays go by saved UUID.** The run API rejects an inline
`transcriptReplay` ("An inline scenario cannot use transcriptReplay"), on
purpose: a replay must pass the checks that run when a scenario is saved,
and an answer key sent in a run request is never stored. So the check sends
`{type: "simulation", scenarioId, personality}` for a replay scenario, and
first compares the saved copy with the branch's file (see
[Recording replays](#recording-replays)). Replays mock every tool on the
platform by default, so the fail-closed tool rule still holds.
- **Replays go inline too.** The run API accepts an inline
`transcriptReplay` and applies the checks that run when a scenario is
saved, so the 400s match save's (see
[Recording replays](#recording-replays)). Before that change it refused
one ("An inline scenario cannot use transcriptReplay"), and a check had to
run the saved copy instead of the branch's.
- **Runs are named by their entries.** The run API has no run-level name.
The dashboard's runs table (and the runs list's `summary.source.name`)
shows the entries' shared `name` when every entry has the same one (2 or
Expand Down Expand Up @@ -319,8 +317,11 @@ transcriptReplay:
required only when it says `required: true`. For HIPAA, PCI and
zero-data-retention orgs, `value` is absent and only an `answerKeyUrl` can
be saved.
- **Replays run only from a saved scenario**, by `scenarioId` or
`simulationId`, and the org must be in the replay rollout.
- **Replays run inline or saved**, and the org must be in the replay
rollout. Inline or saved, a replay needs the voice transport and a single
assistant target, takes only `wer` metric evaluations, and takes no
`hooks` or `latencyExpectations`. Omitted `instructions` and
`evaluations` are stored as `''` and `[]`.
- **Host the recording at a fixed public URL**, and keep it fetchable for
every future run. Presigned call-recording links expire after 30 minutes,
and Vapi's file store rejects audio. A URL pinned to a commit SHA works.
Expand Down
20 changes: 11 additions & 9 deletions improvements.md
Original file line number Diff line number Diff line change
Expand Up @@ -2401,18 +2401,20 @@ failing one, or a run failing only on a latency budget, showed no detail.

### Current behavior and mitigation

A check sends a replay scenario by its saved UUID, with the target still
built from the branch. It needs voice, its own org, and a deployed scenario.
Before a live run it reads each saved replay scenario and stops with an error
if the file's replay settings differ, so a branch edit isn't judged on the
old copy. The verdict reads `results.transcriptEvaluation` and
`results.latencyEvaluations`.
The platform now accepts an inline `transcriptReplay`, with save's checks,
so a check sends a replay scenario inline from the branch like any other.
The build refuses a replay over chat, against a squad, or with `hooks` or
`latencyExpectations`, as the platform does. The verdict reads
`results.transcriptEvaluation` and `results.latencyEvaluations`.

Before inline replays shipped, a check ran the saved copy by UUID and
compared it with the branch's file first, so a PR that edited a replay was
never what ran.

### Risk

The exception to "what's in the files is what runs" is permanent unless the
platform starts accepting inline replays. The stale-copy comparison accepts
extra keys the platform adds, so a key removed from the file goes unnoticed.
A run org outside the replay rollout, or one where the inline-replay change
hasn't deployed, gets a 400 for the whole run.

### Status

Expand Down
33 changes: 13 additions & 20 deletions src/check-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,7 @@ export function checkMocksApply(args: CheckMocksArgs): void {
walkObject(w, body.target, base);
body.simulations.forEach((entry, index) => {
const label = `simulations[${index}] (${entry.name})`;
// Only a transcript replay goes by scenarioId (see replayEntryBuild). Its
// saved copy can't take default mocks; the platform answers a replay's
// tool calls with a mock of its own, and the dead servers still apply.
if (entry.scenario === undefined && entry.scenarioId === undefined)
w.errors.push(`${label}: needs an inline scenario or a scenarioId`);
if (entry.scenario !== undefined && entry.scenarioId !== undefined)
if ("scenarioId" in entry)
w.errors.push(`${label}: scenarios must be inline, not by scenarioId`);
if (
entry.personalityId !== undefined &&
Expand All @@ -450,12 +445,11 @@ export function checkMocksApply(args: CheckMocksArgs): void {
w.errors.push(
`${label}: personalities must be inline or stock, not ${entry.personalityId}`,
);
if (entry.scenario)
walkObject(w, entry.scenario, {
...base,
path: `${label}.scenario`,
where: "scenario",
});
walkObject(w, entry.scenario, {
...base,
path: `${label}.scenario`,
where: "scenario",
});
if (entry.personality)
walkObject(w, entry.personality, {
...base,
Expand All @@ -464,12 +458,11 @@ export function checkMocksApply(args: CheckMocksArgs): void {
});
});
if (!w.strict) return;
body.simulations.forEach((entry, index) => {
if (entry.scenario)
defaultMocksAdd(
w,
entry.scenario,
`simulations[${index}] (${entry.name}).scenario`,
);
});
body.simulations.forEach((entry, index) =>
defaultMocksAdd(
w,
entry.scenario,
`simulations[${index}] (${entry.name}).scenario`,
),
);
}
Loading
Loading