Repository navigation
fix(browser-use): align resume retries and keep failed-attempt evidence - #124
Merged
Merged
Conversation
Resume skipped attempt 2 when the stored primary had evaluator status "unsupported", while a fresh run retries every primary below score 1.0. The protocol declares one failure retry and the release check accepts a retry after any non-passing primary, so both paths now share one _retry_required rule and record the same calls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
agent_run_ms and evidence_finalize_ms were assigned only after the agent and evidence stop succeeded, so a failed attempt reported 0 ms of agent time. Measure both phases in finally blocks and count the failure-path HAR/trace stop as evidence finalization. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The failure-path HAR recorder and trace stop swallowed its exception, so an attempt could lose its network trace without any recorded reason. Append the failure to the attempt's cleanup_errors like the other cleanup steps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
site_container_manager, ensure_site and verify_arm_php_compatibility each created a docker.from_env() client per call and never closed it, so every attempt leaked several HTTP connection pools to the daemon. Close each client once its calls finish, including on failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
login_context checked its browser context and page with assert, which python -O strips, turning the precondition into an AttributeError deep in login. Raise a RuntimeError that names the missing session state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
lanyue-llk
commented
Oct 30, 2026
lanyue-llk
left a comment
Contributor
Author
There was a problem hiding this comment.
Independent review, round 1
Head reviewed: a2090188 (base 8b8aa30f). I found no P0, P1 or P2 defects. Two P3 notes follow; neither blocks merge.
What I verified
- Resume retry rule.
report_check.py:513-519allows attempt 2 only after a primary withscore != 1.0.report_check.py:854-861rejects a complete publication when any non-passing primary has no retry. Under the old resume path, anunsupportedprimary with score 0 was never retried, so a resumed cohort could not pass the release check. Using the fresh-run rule is correct.run()stores fresh rows incompletedbefore attempt 2, so the guard oncompleted[primary_key]covers both the fresh and the resumed path. - Failed-attempt timing.
agent_run_msandevidence_finalize_msare now set infinallyblocks. The failure-path stop adds toevidence_finalize_mswith+=, so an error after the success-path finalize does not lose the earlier time. Both values reachrow["timings"]. - HAR/trace stop errors.
cleanup_errorsis now created before thetry, and the failure-path stop error is appended to it. Nothing outside the runner readscleanup_errorsin a way that changes a verdict. - Docker clients. I found no unclosed per-call
docker.from_env()left inenvironments/webarena/runtime.py. TheContainerManagerandEnvCtrlDockerClientobjects from upstreamwebarena_verifieddo not callfrom_env. - assert → RuntimeError in
login_context: correct. - Bind-port-0 race. I agree with the decision not to change it.
DockerBackend.find_free_portis a protocol method. Its only caller in the repository,lexbench/resource_matrix.py:70, callsrun.find_free_port()on a different object. - Tests fail without the fix. I restored
runner.pyandruntime.pyfrom8b8aa30f, adding a stub_retry_requiredthat keeps the oldunsupportedexception, and rantests/browser_use/test_runner.py. 9 tests failed: both login tests, all four client-closing tests, theunsupportedresume case, and both attempt-level tests. All of them pass on the PR head. ruff(both gates): pass.pytest tests/browser_use tests/test_golden_reports.py -n 2: 270 passed. Golden hashes are unchanged.- Commits: 5 commits, one per bug, each with the Co-Authored-By trailer.
Part of #94matches the remaining scope listed in the body. - CI on
a2090188: every check passes, including "Tests and static checks".
Findings
- P3,
tests/browser_use/test_runner.py:1108. The resume regression test calls only_retry_required. It does not exercise therun()loop where the old divergence was, so a future edit that bypasses the helper in the resume branch would still pass. Suggested fix: add a small loop-level test. Seedattempts.jsonlwith anunsupported, score-0 primary, stub_run_attempt, and assert that attempt 2 runs. Alternatively, move the per-engine attempt loop into a small function that can be tested. - P3,
src/harness/environments/webarena/runtime.py:330. No test checks thatensure_sitecloses its client, unlike the other two call sites. Suggested fix: add an assertion with the existing_patch_docker_clienthelper if that is cheap. This one is optional.
This review does not approve the PR or request changes.
…t loop Move the per-engine primary/retry loop out of run() into _run_engine_attempts so fresh and resumed invocations share one testable loop, and cover it with resume and fresh-run cases that assert which attempts actually execute. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Review round 1 follow-up:
Nothing disputed. Locally: ruff gates pass, and |
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues
Closes #94. This PR covers only the Browser Use items. Still open in #94 and handled in other PRs: Rainbond 4xx readiness, the unbounded
process.wait()in the headless/moli providers, the three P50/P95 definitions, the public WebArena audit fail-open, and the suspectedweb_search/review.py,_wait_cdp,catalog_runner/remote_executionport races,har.pyid(request), import-timetiktokenandwebarena_replay.pylocals()items.Summary
One commit per bug, each with a regression test:
src/harness/browser_use/runner.py). On resume, attempt 2 was skipped when the stored primary had evaluator statusunsupported. A fresh run retries any primary with a score below 1.0. I kept the fresh-run rule because it is the one the project declares in three places. The manifest protocol recordsfailure_retries: 1/task_failure_retries: 1.report_check.pyaccepts a retry after any primary withscore != 1.0. No profile or doc givesunsupportedan exception. Both paths now call one_retry_required(primary)helper, so interrupted and uninterrupted cohorts record the same calls. The resume-skip print is unchanged.agent_run_msandevidence_finalize_mswere assigned only on success. Both are now measured infinallyblocks. The failure-path HAR/trace stop counts towardevidence_finalize_ms.HAR/trace stop failed: <error>tocleanup_errors. The list is created before the attempt starts.browser_use/runtime.pytosrc/harness/environments/webarena/runtime.py.site_container_manager,ensure_siteandverify_arm_php_compatibilityeach opened adocker.from_env()client per call and never closed it. Inprepare_sites, that adds up to several clients per site on every attempt. Each one is now wrapped incontextlib.closing. Function signatures are unchanged, sotrajectory_replay/webarena_replay.pycallers are not touched.assertused as a runtime precondition (suspected, confirmed).login_contextasserted that the browser context and page exist. Underpython -Othe assert is removed and the failure turns into anAttributeError. It now raises an explicitRuntimeError.Not changed:
browser_use/backend.py. This is nowsrc/harness/environments/webarena/backend.py(DockerBackend.find_free_port). The race is real in principle but nothing can trigger it. The method exists only to satisfy thewebarena_verifiedcontainer-backend protocol. Neither the pinnedwebarena_verifiedpackage nor this repository calls it: site ports are fixed bySITE_PORTS, and browser containers use Docker-assigned published ports. Removing it would break protocol conformance, so I left it alone.The new attempt-level tests run
_run_attempt_lockedend to end. They use in-process fakes for CowAgent (sys.modules), the browser service, the HAR recorder and the Docker resource sampler. I checked that the timing test fails on the code before the fix.Test plan
ruff check --config 'include=["*.py"]' --select F,TID252 .andruff check: pass.pytest tests/browser_use tests/trajectory_replay tests/test_golden_reports.py -n 2: 2311 passed, 5 skipped. Golden route hashes are unchanged.runner.pyand it failed, as expected.🤖 Generated with Claude Code