You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test-order-dependent failure: importlib.reload() in test_action_timeout.py corrupts Tools class identity for the rest of the pytest process #5425
tests/ci/test_action_timeout.py::test_malformed_env_timeout_does_not_break_import calls importlib.reload(browser_use.tools.service) ten times in a row (once per malformed BROWSER_USE_ACTION_TIMEOUT_S value it checks). Each reload() rebinds browser_use.tools.service.Tools to a new class object. But Tools is already imported by value (from browser_use.tools.service import Tools) in several other modules before this test ever runs:
browser_use/agent/service.py
browser_use/beta/service.py
browser_use/mcp/client.py
browser_use/mcp/server.py
browser_use/integrations/gmail/actions.py
browser_use/__init__.py
Those modules keep pointing at whatever Tools object existed at their own import time (normally the very first, pre-reload one). The fixture's final reload() on teardown doesn't restore the original object either — it creates yet another new one. So for the rest of that pytest process, any Tools freshly imported from tools.service no longer is-matches (or isinstance-matches) the Tools object baked into agent/service.py / beta/service.py.
Reproduction
Minimal reproduction, no pytest involved:
importimportlibimportbrowser_use.tools.serviceassvcfrombrowser_use.agent.serviceimportAgentimportbrowser_use.agent.serviceasagent_svcTools_before=svc.Toolsprint(Tools_beforeisagent_svc.Tools) # Trueimportlib.reload(svc)
print(svc.ToolsisTools_before) # False - new class objectprint(agent_svc.ToolsisTools_before) # True - agent.service still holds the OLD classprint(agent_svc.Toolsissvc.Tools) # False - desynced for the rest of the process
Observed effect
Running the full tests/ci suite (not in isolation) reliably fails two tests in tests/ci/test_beta_agent.py:
Both fail on get_origin(...) is Tools / isinstance(agent.tools, Tools) — the classes print identically (browser_use.tools.service.Tools) but are different objects. Running tests/ci/test_beta_agent.py alone is 100% green; the failure only appears when test_action_timeout.py runs earlier in the same pytest process (default, non-xdist run order). Bisecting the file list confirms test_action_timeout.py is the sole trigger — any file set that excludes it stays green, any set that includes it (with test_beta_agent.py after it) reproduces the failure.
Fix
tests/ci/test_action_timeout.py already has the pure function it needs for this: browser_use.tools.service._parse_env_action_timeout(raw: str | None) -> float, which is what _DEFAULT_ACTION_TIMEOUT_S is computed from at import time. The test can call this function directly for each malformed value instead of reloading the whole module — no sys.modules mutation, no leaked class identity, same coverage.
This is a great test harness changes the system under test breaker: reloading one module creates a new Tools class identity while other modules keep the old one, so later tests fail depending on order.
AgentCI is recruiting fixture/provenance integrity cases like this. A portable fixture could snapshot imported class/module identities before and after the timeout test and require zero leaked mutation into the rest of the pytest process. If you or an external agent contribute the reduced fixture, we’ll preserve this issue as provenance and give permanent public credit/backlink in AgentCI’s Breaker/Verifier Hall of Fame + priority conversion help.
👋 This issue has been automatically marked as stale because it hasn't had activity for 60 days.
⚡ We've made significant progress recently! Please test with the latest version of browser-use to see if this issue has been resolved. If the issue persists, please let us know by commenting below.
To keep this issue open:
Add a comment explaining why this is still relevant after testing the latest version
Add the pinned label if this is an important long-term issue
Reference it in a PR if you're working on a fix
This will be automatically closed in 14 days if no further activity occurs.
Thanks for contributing to browser-use! 🤖 If you have questions, join our Discord.
Activity
jinngimk-lang commentedon Aug 17, 2026
This is a great test harness changes the system under test breaker: reloading one module creates a new
Toolsclass identity while other modules keep the old one, so later tests fail depending on order.AgentCI is recruiting fixture/provenance integrity cases like this. A portable fixture could snapshot imported class/module identities before and after the timeout test and require zero leaked mutation into the rest of the pytest process. If you or an external agent contribute the reduced fixture, we’ll preserve this issue as provenance and give permanent public credit/backlink in AgentCI’s Breaker/Verifier Hall of Fame + priority conversion help.
AgentCI: https://github.com/jinngimk-lang/agentci · recognition: https://github.com/jinngimk-lang/agentci/blob/main/COMMUNITY.md
Affiliation disclosed; no Browser Use certification claim.
github-actions commentedon Oct 17, 2026
👋 This issue has been automatically marked as stale because it hasn't had activity for 60 days.
⚡ We've made significant progress recently! Please test with the latest version of browser-use to see if this issue has been resolved. If the issue persists, please let us know by commenting below.
To keep this issue open:
pinnedlabel if this is an important long-term issueThis will be automatically closed in 14 days if no further activity occurs.
Thanks for contributing to browser-use! 🤖 If you have questions, join our Discord.
github-actions commentedon Nov 1, 2026
🔒 This issue was automatically closed because it was stale for 14 days with no activity.
Don't worry! If this issue is still relevant:
We appreciate your contribution to browser-use! 🤖