Skip to content

agent_simulation: sample scenarios within a run for pass@k / pass^k - #1799

Open
u9g wants to merge 14 commits into
mainfrom
jason/simulation-repeats
Open

u9g wants to merge 14 commits into
mainfrom
jason/simulation-repeats

Conversation

@u9g

@u9g u9g commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

A run today holds exactly one job per scenario, so a single flaky attempt is indistinguishable from a broken scenario. Repeating a scenario only helps if repeating can also change its verdict, which is what the pass rate is for.

  • SimulationRun.Sampling: samples (attempts per scenario, > 1) and pass_rate (the share of a scenario's samples that must pass for that scenario to pass, 0-1). A scenario needs round(rate × samples) passing samples, so 0.34 of 3 needs 1 and 0.67 of 3 needs 2; 1 requires every sample. Both are required when the message is present.
  • SimulationRun.Create.Request.sampling, mirrored on SimulationRun.sampling. Absent runs each scenario once and requires it to pass, which is today's behaviour. Requires scenario_group. The mirror lets the dashboard render a scenario's verdict without being told the bar out of band.
  • SimulationRun.Job.scenario_id / sample: every attempt of one scenario shares the id, so a run's jobs group back into scenarios. New field numbers; 9 stays reserved.

A scenario stops being all-or-nothing: 2/3 can now be a pass. The run still fails if any scenario fails, so there is no run-level percentage. pass@k and pass^k remain reporting metrics over scenarios and neither gates.

pass_rate is meaningless without samples > 1 — at one sample round(rate × 1) is either a no-op or always-passes — so the two travel together rather than as two independently-optional fields that can be combined into a request that means nothing. Inside Sampling both are plain scalars, because 0 samples and a 0 pass rate are naturally invalid and so already say "unset" without a presence bit.

Note for consumers: Sampling.pass_rate is the threshold a run was given, and RunMetrics.scenario_pass_rate is the observed share of passing jobs. They are a bar and a measurement, not two readings of the same thing.

Consumer migration. samples and pass_rate were briefly flat fields on this branch, never on main and never released, so sampling reuses their field numbers rather than reserving them. livekit/agents-private#457 is merged and pins a commit of this branch in go.mod, so it needs GetSampling().GetSamples() and a repin. livekit/livekit-cli#975 (lk agent simulate --samples / --pass-rate) and livekit/web#6190 follow.

@changeset-bot

changeset-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43aaf61

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
github.com/livekit/protocol Patch
@livekit/protocol Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread protobufs/livekit_agent_simulation.proto Outdated
Comment thread protobufs/livekit_agent_simulation.proto Outdated
u9g added a commit to livekit/livekit-cli that referenced this pull request Sep 15, 2026
@u9g u9g changed the title agent_simulation: repeat scenarios within a run for pass@k / pass^k agent_simulation: sample scenarios within a run for pass@k / pass^k Sep 15, 2026
u9g added a commit to livekit/livekit-cli that referenced this pull request Sep 15, 2026
@u9g
u9g force-pushed the jason/simulation-repeats branch 3 times, most recently from 5c16cbf to 0ef9b88 Compare September 15, 2026 19:23
u9g added 3 commits September 15, 2026 15:34
A run today holds exactly one job per scenario, so a single flaky attempt
is indistinguishable from a broken scenario. `Create.Request.repeats` asks
for k attempts of every scenario in one run; each Job carries the
`scenario_id` and 1-based `attempt` it belongs to so jobs group back into
scenarios. `RunMetrics.pass_at_k` (at least one attempt passed) and
`pass_pow_k` (every attempt passed) summarize the run over scenarios.
@u9g
u9g force-pushed the jason/simulation-repeats branch from 66effb8 to be5b074 Compare September 15, 2026 19:34
u9g added a commit to livekit/livekit-cli that referenced this pull request Sep 16, 2026
u9g added a commit to livekit/livekit-cli that referenced this pull request Sep 16, 2026
u9g added a commit to livekit/livekit-cli that referenced this pull request Sep 17, 2026
u9g added a commit to livekit/livekit-cli that referenced this pull request Sep 17, 2026
@u9g

u9g commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Added min_sample_pass_rate per the decision that the run is gated on a pass rate and that pass@k / pass^k only report. Re-review needed — this PR was approved before the field existed.

The semantics are narrower than "pass^k" suggested, and worth stating plainly because the field comment fixes them for every consumer:

A scenario stops being all-or-nothing. The rate is the share of one scenario's samples that must pass for that scenario to pass — 2/3 becomes a passing scenario at --pass-rate 0.67. It is not an exponent and not a percentage of scenarios. The run then fails if any scenario fails, exactly as it does today, so there is no run-level percentage anywhere.

The rounding is round(rate × samples), so 0.34 of 3 samples needs 1 and 0.67 of 3 needs 2. A strict c/k >= rate comparison would land a step stricter than the number reads, because 1/3 is 0.333 and 2/3 is 0.667 — a typed 0.34 would demand 2 of 3 and a typed 0.67 would demand 3 of 3.

0/unset requires every sample, which is the current behaviour, so existing runs are unaffected.

…rate

A scenario is all-or-nothing today, so repeating it can only ever make it
harder to pass. min_sample_pass_rate is the share of a scenario's samples
that must pass for that scenario to pass, set on Create.Request and
mirrored on SimulationRun so the dashboard can render a verdict without
being told the bar out of band. 0/unset requires every sample, which is
the current behaviour. The run still fails if any scenario fails, and
pass@k / pass^k stay informational.
@u9g
u9g force-pushed the jason/simulation-repeats branch from 6e3a18d to c136f73 Compare September 17, 2026 19:27
// pass, 0-1; 0/unset requires every sample. A scenario needs
// round(rate × samples) of them. The run fails if any scenario fails;
// pass@k and pass^k report over scenarios and neither gates.
double min_sample_pass_rate = 15;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just pass_rate?

Suggested change
double min_sample_pass_rate = 15;
double pass_rate = 15;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, on both the request and the mirrored field on SimulationRun.

u9g and others added 5 commits September 18, 2026 08:08
0 samples means run nothing and a 0 pass rate means require nothing, so
neither zero value can stand for "the caller said nothing" without a
remap that lives only in a comment. Absence carries that instead, and an
explicit 0 becomes a rejectable input. SimulationRun.samples stays plain:
a materialized run always has a real count, 1 when it ran once.
github-actions Bot and others added 2 commits September 18, 2026 13:45
pass_rate is meaningless without samples > 1, so the two are one
decision and a request carrying only one of them is not a state worth
representing. Inside Sampling both are plain: 0 samples and a 0 pass
rate are naturally invalid, so neither needs a presence bit to stand in
for "the caller said nothing".
@u9g
u9g force-pushed the jason/simulation-repeats branch from 7d8e3dd to cb4733f Compare September 18, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants