Repository navigation
feat(browser): stop a browser step repeated in a row with browser.run.max_repeats - #39296
Conversation
….max_repeats A long browser task can scroll or click the same control dozens of times while every call succeeds, so nothing stops it. With browser.run.max_repeats above 0, the op route refuses the step that would repeat the last one too often and tells the agent to try something else. The count is per chat, restarts on a takeover or when the chat ends, and keeps only a checksum of the arguments. Default 0 leaves every op as it was.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS The design holds up: the setting is off by default, the check sits at the one route every op passes through, the count lives on the chat's own hub session, and the refusal is an answer the model can read. Notes
[DESIGN-REVIEWED] 5e8293c Description read[DESCRIPTION-READ] eef2b548c86c5f65a038f57eb3186c7a0af51c5e91f439bdd034f146f520ad01 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the stop is opt-in, has one real consumer, and is not a copy of Notes
What this change shipsInventory (5 items) — 3 justifiedIntent: let a person stop a browser agent that repeats one step in a row, and have the agent get a readable reason. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 5e8293c Description read[DESCRIPTION-READ] ba8a1d8d4b11de52b4898713ed9f84be470f0278fc9679fa8d2b9fc3e0026c36 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] 5e8293c Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. This adds an opt-in The count lives on the chat's own The config is clamped to 0..10,000, and both Tier: 2, held for a person: reviewer-finding: Design Review. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
This review checked head 5e8293c. The new check runs in _bound_op after the in_control and ask branches and before run_op. A refused op never reaches the browser and is not counted. The count resets on takeover. With browser.run.max_repeats at 0 the route answers as it does on main. The 12 new tests pass and use no sleeps, clocks or ports. PR Readiness is green on this head.
Done well: the fingerprint is a CRC32 plus length of op and args, so no typed text is kept. The count lives on the chat's existing LiveSession, so the change adds no process-wide state.
Optional:
- Add a short paragraph to
docs/system-specs/modules/browser.md, next to the refusal codes. It should cover therun_budgetcode, where the check runs, and when the count resets. - An
askreturns beforerun_budget.check, so it does not restart the count. But browser-control.md and the config help say any different step restarts it. Resetsess.runon an ask, or reword the docs. - If the limit is set to 0 and then turned back on, the old count is reused. Keep the fingerprint updated while the limit is off, or reset the count when the limit changes.
Problem / Motivation
Goal: a browser task that repeats one step ends with a clear stop report the agent reads, instead of running until the context or the budget is gone.
The
browsertool has per-op timeouts (browser_harness/budgets.py) and, inside fast mode, a step and time bar. The ordinary path has no limit on a repeat, and every looped call succeeds, so nothing flags it: a click on the same control, or the same scroll, can repeat dozens of times. #36027 records one such session, where nine documentation pages took 60 to 100 screenshots and the host flagged the repeated scroll calls as a loop that Kiro Crew itself did not stop.Why it matters
Each wasted step costs a page read or an image, and a loop of 60 identical calls teaches the agent nothing the first three did not. A person away from the screen finds out only from the bill. A stop with a readable answer lets the agent report where it got to, and lets the person decide whether to raise the limit.
Not a goal
What changed (motivation → approach → change)
One setting,
browser.run.max_repeats, default0(off). The gateway's op route, which sees every op of every chat, asks before the op reaches the browser. A stopped op is not run; the answer is a normal tool result (Error (run_budget): ...) that names the setting and how to go on (raise it, take over the browser, or start a new chat).src/kiro_crew/browser_harness/run_budget.py(new):RunCountandcheck(). The repeat key is a CRC32 checksum plus the length of the op and its arguments as JSON, so a typed value is never kept and typing different text into one field is not a repeat. A refused op is not counted, so the same op stays refused until a different one runs.src/kiro_crew/browser_harness/live_hub.py: the chat'sRunCountlives on its hub session, with the chat's other per-session state. It starts again on a takeover (claim) and at the end of the chat's session (reset_run, called where the chat's tabs are closed). No new process-wide state.src/kiro_crew/dashboard/handlers/browser_ops.py:_run_limits()reads the setting for each op (0 when unreadable)._bound_opcallscheckafter the ask branch and before the op runs, so an op held for the person is not counted. With the setting at 0 it never touches the hub.src/kiro_crew/config/sections_browser.py,sections.py:browser.run.max_repeats(BrowserRunConfig), clamped to 0..10,000.config-baseline.jsonregenerated withscripts/generate_config_baseline.py.docs/browser-control.md(what the limit does),docs/configuration.md(the key).Backwards compatibility
With the setting at 0 the route adds no field to any result and answers as on main;
test_with_the_setting_off_the_route_answers_as_it_always_didpasses on main as well. The new refusal coderun_budgetcan appear only after a person sets the limit. The shim already renders any code asError (<code>): <text>. Removes nothing.Tests
bdc5e2ff9a, 10 of the 12 tests intest/test_browser_run_budget.pyfail (no module, no setting). The two that pass pin the default answer and the tool's rendering of a stop report._bound_opdoes not have (aNameErroranswered asbrowser_erroron every op); that is the break the first version had after feat(browser): isolate sign-ins per chat with browser.isolation #37821 split_bound_opout.bdc5e2ff9a(decisions, design-tweak, terminal-probe and sandbox files, andtest_browser_quick_ask_vault.py's 21 in this environment); none reaches the changed code. The browser, live hub, config, facade, schema, docs and MCP-listing test files: 7,279 passed beside those same 21.flake8,isort,mypyon the changed source files, the repo's black gate, and the comment-history, flake-pattern, wait-discipline, sync-io and lane CI checks pass.python -m pytest test/test_browser_run_budget.py -n0Manual verification
Not run against a live browser. The route tests drive
POST /api/browser/opthroughapi_browser_opwith a fake daemon: the thirdscrollof the same distance under a limit of two answersrun_budgetand makes no browser call, and a different distance goes on.Sibling sweep
Sibling:
browser_harness/reflex.py(fast mode) -- not affected -- it keeps its own step and time bar; one fast-mode call is one op hereSibling:
mcp_tools/browser.py-- not affected -- it renders the refusal through its existingError (<code>)pathSibling:
browser_harness/ops.py-- not affected -- the check sits in the route, sorun_opand its callers are unchangedPattern harvest
Rule candidate: review-prompt
Pattern: a loop guard that answers with a refusal the model reads, keyed on a checksum of the arguments and kept on the chat's own session object, needs no new global state or reset.
Related Issues
Related to #36027, which flagged a repeated-scroll loop. This does not close it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement