Skip to content

simulate: retry still-failing scenarios in CI with --retries (default 3) - #953

Open
u9g wants to merge 2 commits into
jason/simulate-ci-baselinefrom
jason/simulate-retry-failed
Open

simulate: retry still-failing scenarios in CI with --retries (default 3)#953
u9g wants to merge 2 commits into
jason/simulate-ci-baselinefrom
jason/simulate-retry-failed

Conversation

@u9g

@u9g u9g commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Stacked on jason/simulate-ci-baseline (the --baseline feature, in progress in another session) — only the top two commits are this PR.

What

CI runs of lk agent simulate now retry failed scenarios instead of failing the build on the first flake. After a run finishes with failures, the CLI re-runs only the still-failing scenarios against the same already-registered agent, up to --retries times (default 3, --retries 0 disables). A scenario passes when any attempt passes.

How

  • The retry run's scenarios come from the finished run itself (run.scenario_group), which is populated in both --scenarios and generated-from-source modes — so retries never re-upload source or regenerate scenarios, and generated scenarios are retried verbatim rather than nondeterministically regenerated.
  • The verdict (counts, --baseline comparison, exit error) reads each scenario's outcome from the last attempt that ran it to a terminal state, so a cancelled retry cannot launder an earlier failure.
  • Systemic conditions are never retried: a broken agent, inference-quota exhaustion, or a run that produced no jobs would fail identically and only burn quota.
  • Flakes stay visible: every attempt's transcript prints; a failure that later passed keeps its transcript but loses its ::error:: annotation, and the final counts line names the scenarios that passed on retry.

Commits

  1. refactor(simulate): pure move — the CI poll loop into ciRunPoller, so one invocation can poll several runs with shared broken-agent/quota detection state.
  2. feat(simulate): the --retries flag and retry loop, with tests for the outcome-merging helpers.

u9g added 2 commits August 31, 2026 13:31
Pure move: the loop body is unchanged, its cross-run detection state
(broken agent, quota warning, peak concurrency) now lives on a struct
so a follow-up can poll more than one run per invocation.
…efault 3)

After a run finishes with failures, CI mode re-runs only the failing
scenarios against the same already-registered agent, up to --retries
times; a scenario passes when any attempt does. The scenarios come from
the finished run itself, so generated-from-source runs retry without
re-uploading or regenerating. Systemic conditions (broken agent, quota
exhaustion) are never retried.

The verdict (counts, --baseline comparison, exit error) reads each
scenario's outcome from the last attempt that ran it to a terminal
state, so a cancelled retry cannot launder an earlier failure. Every
attempt's transcript still prints; a failure that later passed keeps
its transcript but loses its ::error:: annotation, and the final counts
name the scenarios that passed on retry so flakes stay visible.
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.

1 participant