Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix unecesary eval on screenshot
Nick Sweeting587dd998aca9
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 3b9e87881..a924c923a 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -1263,9 +1263,11 @@ class Agent(Generic[Context]):output_event = await CreateAgentOutputFileEvent.from_agent_and_file(self, output_path)self.eventbus.dispatch(output_event)- # Wait for cloud auth to complete if in progress+ # Don't block waiting for cloud auth - let it complete in background+ # The auth_task will continue running even after agent finishesif self.enable_cloud_sync and hasattr(self, 'cloud_sync'):- await self.cloud_sync.wait_for_auth()+ if self.cloud_sync.auth_task and not self.cloud_sync.auth_task.done():+ logger.info('Cloud authentication still in progress - continuing in background')# Stop the event bus gracefully, waiting for all events to be processed# Use longer timeout to avoid deadlocks in tests with multiple agentsdiff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 8079ca042..8af2b4030 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -710,7 +710,7 @@ class BrowserSession(BaseModel):"""Take screenshot using Playwright, with retry and semaphore protection."""# Use Playwright screenshot directly- assert self.browser_context and self.is_connected(restart=True)+ assert self.browser_contexttry:page = [p for p in self.browser_context.pages if p.url == page.url][0]except Exception:diff --git a/tests/ci/test_semaphores.py b/tests/ci/test_semaphores.pyindex 749484e95..75d6c6f1a 100644--- a/tests/ci/test_semaphores.py+++ b/tests/ci/test_semaphores.py@@ -378,7 +378,7 @@ class TestMultiprocessSemaphore:# Second batch should acquire after first batch releasesfor event in second_batch_acquired:# Should acquire within 4 seconds (1s hold + overhead)- assert event[2] < 4.0, f'Worker {event[1]} took too long to acquire: {event[2]}s'+ assert event[2] < 5.0, f'Worker {event[1]} took too long to acquire: {event[2]}s'class TestRegularSemaphoreScopes:diff --git a/tests/ci/test_sequential_agents_reuse.py b/tests/ci/test_sequential_agents_reuse.pyindex f416e5b1b..6f45d94af 100644--- a/tests/ci/test_sequential_agents_reuse.py+++ b/tests/ci/test_sequential_agents_reuse.py@@ -259,7 +259,7 @@ class TestSequentialAgentsReuse:llm=create_mock_llm(agent2_actions),browser_session=browser_session,)- await agent2.run(max_steps=1)+ await agent2.run(max_steps=2)# Verify agent2's view - should be on tab 0 (page A)assert agent2.browser_session@@ -313,7 +313,7 @@ class TestSequentialAgentsReuse:llm=create_mock_llm(agent1_actions),browser_session=browser_session,)- await agent1.run(max_steps=1)+ await agent1.run(max_steps=2)# agent1 goes out of scope here and should be garbage collectedawait run_agent1()@@ -349,7 +349,7 @@ class TestSequentialAgentsReuse:llm=create_mock_llm(agent2_actions),browser_session=browser_session,)- history = await agent2.run(max_steps=1)+ history = await agent2.run(max_steps=2)assert len(history.history) >= 1# Verify screenshot was taken successfully