Turn Limits and Overrides
When Testronaut runs a mission, it interacts with the browser and the LLM in turns โ one step of reasoning or action per turn.
Each turn might include reading the DOM, deciding what to do next, clicking a button, or verifying a result.
By default, missions are capped at 20 turns to prevent runaway loops, reduce cost, and keep runs predictable.
๐งฉ What Is a Turn?โ
A turn is a single agent reasoning cycle:
- Observe the current browser state (via DOM snapshot or focus section)
- Think and plan the next action
- Execute that action (e.g., click, type, navigate)
- Evaluate the result, and repeat if necessary
You can think of it like a conversation between the agent and the page:
โI see the login form.โ โ โIโll fill it in.โ โ โI see a dashboard now โ success!โ
โ๏ธ Default Behaviorโ
By default:
npx testronaut
runs with a maximum of 20 turns per mission.
This default is defined inside the Testronaut runtime (and can be overridden by configuration or CLI).
๐ง CLI Overrideโ
To temporarily raise or lower the limit, use the --turns flag:
npx testronaut --turns=30
This overrides both:
- the default limit, and
- any value specified in
testronaut-config.json.
๐ก Example:
--turns=10โ quicker runs, fewer LLM calls--turns=40โ longer workflows, more exploration time
Youโll see confirmation in the console:
๐ฏ Turn override: 30
๐ง When to Tune Turn Limitsโ
| Scenario | Recommended Limit | Rationale |
|---|---|---|
| Short, deterministic flows (e.g., login, logout, form submit) | 10โ20 turns | Keeps runtime fast and cost low. |
| Exploratory missions (multi-page flows, decision trees) | 25โ40 turns | Allows more reasoning steps without early cutoffs. |
| Debug or teaching missions | 40โ60 turns | Helps observe agent thought process over longer runs. |
| Continuous or monitored missions | โค15 turns | Keeps resource usage predictable in automation. |
๐งญ If your missions are hitting the limit frequently, it may indicate the agent needs clearer goals or stronger page focus hints.
๐ Why Fewer Turnsโ
- Faster feedback โ runs complete in seconds instead of minutes.
- Lower cost โ fewer LLM tokens and browser steps.
- Cleaner signal โ reduces risk of the agent wandering off-task.
๐ Why More Turnsโ
- Complex UIs โ multi-step flows or dynamic loaders.
- Exploration โ when testing unknown user paths.
- Diagnosis โ seeing how far the agent gets before failure.
๐งฐ Tipsโ
- Start small: 15โ20 turns are usually enough for most missions.
- Increase gradually when debugging long workflows.
- Use your report viewer to inspect how turns were used โ if half of them are retries, itโs usually better to adjust the mission goal rather than raise the cap.
- In CI/CD, keep limits conservative for speed and predictability.
๐งฎ Cost Implicationsโ
Each turn typically involves:
- One reasoning call to your chosen LLM
- One DOM extraction
- One browser action (Playwright step)
Roughly:
total_tokens_used โ turns ร avg_tokens_per_turn
So doubling your turns often doubles token cost and execution time โ tune accordingly.
๐งญ Summaryโ
| Control | Scope | Notes |
|---|---|---|
maxTurns parameter in code | Per mission | Use for static caps in mission files |
TESTRONAUT_TURNS env variable | Per environment | Useful for CI/CD tuning |
--turns=<n> CLI flag | Per run | Quick override (highest priority) |
๐ฌ Turns are the heartbeat of Testronaut โ they balance autonomy and control.
Tuning them gives you precise control over cost, runtime, and exploration depth.