# Run Scenarios Often and Gate Releases on Them

Repeat runs to measure flakiness, compare agents on the same world, gate CI on the result, and tell a Not scored run from a failed one.

> Page: https://langwatch.ai/docs/agent-testing/best-practices/running-and-ci
> Source: https://github.com/langwatch/langwatch/blob/main/docs/agent-testing/best-practices/running-and-ci.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

**Where we are in the story:** the Refunds suite holds Anna's scenario and its siblings, each with fixtures that setup builds and teardown removes. This last step is running it: often enough to trust the result, and in CI so a regression stops a release.

## Repeat runs to measure flakiness

The simulated user words Anna's request differently on every run, so one pass proves little. Set **Run multiple times** in the run dialog (1 to 5 times per scenario and target), and every repetition is its own row with its own verdict. A scenario that passes three times out of five is flaky: read the failed conversations to see whether the agent or a criterion is at fault.

Repeats are cheap to trust because the fixtures are the same on every run. A repeat that fails while the others pass points at the agent's behaviour, not at data left over from an earlier run.

## Compare on the same world

To compare two models, two prompts or two versions of the agent, run the same suite against both in one comparison run. Each side meets Anna's world, built fresh from the same fixtures, so a difference in pass rate is a difference in the agents. See [Compare agents](https://langwatch.ai/docs/agent-testing/compare-agents).

## Gate CI on the result

Start the suite from CI and wait for the batch:

```bash
langwatch test-suite run "Refunds" --target connected:support-agent --wait
```

That is the hybrid path's target. On the app path, start the suite from the platform for now: the CLI's `--target` takes `prompt`, `http`, `code`, `workflow` and `connected` agents, not a Scenario Connector.

`--wait` exits non-zero when a run did not pass, which fails the job. Every run that is not a pass counts, a **Not scored** one included, so a broken setup stops the release too. See [Run from CI](https://langwatch.ai/docs/agent-testing/run-from-ci).

If you poll the batch API yourself, a **Not scored** run counts in neither `passCount` nor `failCount`. A check of `failCount == 0` alone passes a batch whose setups all failed, so also require `passCount` to equal `totalCount`.

## Not scored versus failed

| Result | What it means | What to fix |
|---|---|---|
| Failed | The conversation ran against the right world, and the agent broke a criterion | The agent, or the criterion |
| **Not scored** | Setup failed or timed out, so no turn ran and there is no verdict | The test data: read the setup error on the run |

A **Not scored** run does not count towards the pass rate, because a fault in the test data is not the agent failing. Teardown still runs, but a failed setup hands it no state, so setup must undo its own partial work before it raises, as [Test data](https://langwatch.ai/docs/agent-testing/best-practices/test-data#setup-creates-teardown-cleans-up) describes. A teardown that fails never changes the verdict, but the run shows the error so you can clean up by hand. See [what happens when a hook fails](https://langwatch.ai/docs/agent-testing/setup-and-teardown-hooks#what-happens-when-a-hook-fails).

That is the whole story: Anna's scenario, her world built and removed on every run, repeated and gated in CI. To build it, pick your path in the [overview](https://langwatch.ai/docs/agent-testing/best-practices/overview#which-path-fits-your-team).

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
