---
title: "Keep the suite within a time budget · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/flaky-and-slow-tests/suite-time-budget
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep the suite within a time budget

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Flaky and slow tests](https://agentwranglers.se/playbook/testing/flaky-and-slow-tests)
- Rule: Set a time limit for the whole suite and for each kind of test, and treat going over it as a failure.
- How: Run tests in parallel, such as pytest-xdist `-n auto`, Playwright workers or sharding across machines. Track the slowest tests and fix them first. A suite that takes too long gets skipped, which is worse than a smaller suite. Run independent steps at the same time. For pages made from one template, check every template plus the riskiest pages and a seeded random sample, and sweep everything in CI. Batch requests in tests, and skip work a test does not need, such as compression.
- Check: The pipeline records each stage's duration and sets a time limit on each, such as `timeout-minutes` in GitHub Actions or `timeout 600` in a script. The run fails when a stage passes its limit.
- Measured: On a reference site, the full check went from 12 minutes to about 70 seconds. Steps ran in parallel, and the browser check sampled pages of one template.

Example:

```sh
pytest -n auto --durations=20
npx playwright test --shard=1/4
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/flaky-and-slow-tests/suite-time-budget`.

- Previous: [Find flaky tests before they merge](https://agentwranglers.se/playbook/testing/flaky-and-slow-tests/repeat-new-tests)
- [Flaky and slow tests](https://agentwranglers.se/playbook/testing/flaky-and-slow-tests)
