Skip to main content

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:

  1. Observe the current browser state (via DOM snapshot or focus section)
  2. Think and plan the next action
  3. Execute that action (e.g., click, type, navigate)
  4. 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โ€‹

ScenarioRecommended LimitRationale
Short, deterministic flows (e.g., login, logout, form submit)10โ€“20 turnsKeeps runtime fast and cost low.
Exploratory missions (multi-page flows, decision trees)25โ€“40 turnsAllows more reasoning steps without early cutoffs.
Debug or teaching missions40โ€“60 turnsHelps observe agent thought process over longer runs.
Continuous or monitored missionsโ‰ค15 turnsKeeps 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โ€‹

ControlScopeNotes
maxTurns parameter in codePer missionUse for static caps in mission files
TESTRONAUT_TURNS env variablePer environmentUseful for CI/CD tuning
--turns=<n> CLI flagPer runQuick 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.