Repository navigation
Conversation
wait slept min(seconds - 1, 30) but told the model it had waited the requested number of seconds. A 1s wait slept nothing, and a 120s wait slept 30s while recording "Waited for 120 seconds". Report the real sleep, keep the 30s cap, and mention the cap when it applies. Fixes browser-use#5362
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/ci/test_tools.py">
<violation number="1" location="tests/ci/test_tools.py:165">
P3: These elapsed-time checks use `time.time()`, which can jump when the system clock is adjusted and spuriously fail; measure the duration with `time.monotonic()` instead.</violation>
<violation number="2" location="tests/ci/test_tools.py:189">
P3: This test stubs the global `asyncio.sleep` with `monkeypatch`, which breaks the repo's binding 'never mock anything' testing rule (CLAUDE.md). The only other sleeps in this file are real. Consider asserting the reported text with a real short wait, or checking the cap logic without a stub. The stub also replaces `asyncio.sleep` for every caller during the test.</violation>
</file>
Reply to a comment to ask cubic a question or push back. It learns from your replies.
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.
View guided diff | Re-trigger cubic
| async def record_sleep(delay: float): | ||
| slept.append(delay) | ||
|
|
||
| monkeypatch.setattr(asyncio, 'sleep', record_sleep) |
There was a problem hiding this comment.
P3: This test stubs the global asyncio.sleep with monkeypatch, which breaks the repo's binding 'never mock anything' testing rule (CLAUDE.md). The only other sleeps in this file are real. Consider asserting the reported text with a real short wait, or checking the cap logic without a stub. The stub also replaces asyncio.sleep for every caller during the test.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/ci/test_tools.py, line 189:
<comment>This test stubs the global `asyncio.sleep` with `monkeypatch`, which breaks the repo's binding 'never mock anything' testing rule (CLAUDE.md). The only other sleeps in this file are real. Consider asserting the reported text with a real short wait, or checking the cap logic without a stub. The stub also replaces `asyncio.sleep` for every caller during the test.</comment>
<file context>
@@ -176,12 +174,31 @@ async def test_wait_action(self, tools, browser_session):
+ async def record_sleep(delay: float):
+ slept.append(delay)
+
+ monkeypatch.setattr(asyncio, 'sleep', record_sleep)
+ wait = tools.registry.registry.actions['wait']
+
</file context>
| assert end_time - start_time <= 2.5 # We wait 3-1 seconds for LLM call | ||
| assert result.extracted_content == 'Waited for 3 seconds' | ||
| assert result.long_term_memory == result.extracted_content | ||
| assert 2.6 <= end_time - start_time <= 4.5 |
There was a problem hiding this comment.
P3: These elapsed-time checks use time.time(), which can jump when the system clock is adjusted and spuriously fail; measure the duration with time.monotonic() instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/ci/test_tools.py, line 165:
<comment>These elapsed-time checks use `time.time()`, which can jump when the system clock is adjusted and spuriously fail; measure the duration with `time.monotonic()` instead.</comment>
<file context>
@@ -158,13 +158,11 @@ async def test_wait_action(self, tools, browser_session):
- assert end_time - start_time <= 2.5 # We wait 3-1 seconds for LLM call
+ assert result.extracted_content == 'Waited for 3 seconds'
+ assert result.long_term_memory == result.extracted_content
+ assert 2.6 <= end_time - start_time <= 4.5
# longer wait
</file context>
|
👋 This PR has been automatically marked as stale because it hasn't had activity for 45 days. To keep this PR open:
This will be automatically closed in 14 days if no further activity occurs. Thanks for contributing to browser-use! 🤖 |
Fixes #5362.
waitcapped at 30s and also subtracted 1s, then wrote the requested duration intolong_term_memory. A request for 1s slept 0s. A request for 120s slept 30s and told the model "Waited for 120 seconds". Later steps plan from that text.The action now sleeps
min(max(seconds, 0), 30)and reports that number. If the request was over 30s, the message says it was capped. The tool description mentions the 30s limit.There is no page to screenshot. The thing the model sees is the log line and
long_term_memory. Same three requests, previous formula on the left of each pair, this branch on the right. 1s and 5s are real sleeps. 120s stubsasyncio.sleepso the run does not sit for 30s; the string still comes fromwait.The existing
test_wait_actionwas asserting the oldseconds - 1timing, so those bounds are updated.test_wait_reports_the_sleep_it_actually_didstubsasyncio.sleepand checks the 1s and 120s cases without waiting 30s.Locally:
ruff checkandruff format --checkon the two files, then2 passed.
Summary by cubic
Fixes #5362 by making the
waittool report the time it actually slept instead of the time it was asked to wait.The action previously slept
min(seconds - 1, 30)and recorded the requested duration inlong_term_memory— a 1s request slept 0s, and a 120s request slept 30s while telling the model "Waited for 120 seconds". Later steps plan from that text, so the model now sees misinformation.The action now sleeps
min(max(seconds, 0), 30)and reports that number. When the request exceeds 30s the response says it was capped, and the tool description mentions the limit.Tests
test_wait_actiontiming bounds to match real sleep durations.test_wait_reports_the_sleep_it_actually_did, which stubsasyncio.sleepto verify the 1s and 120s cases without waiting 30s.Written for commit e04377c. Summary will update on new commits.