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
fixes
Nick Sweetingf35ea5be4de2
diff --git a/browser_use/agent/cloud_events.py b/browser_use/agent/cloud_events.pyindex 07aec677c..457b4ea02 100644--- a/browser_use/agent/cloud_events.py+++ b/browser_use/agent/cloud_events.py@@ -1,4 +1,4 @@-from datetime import datetime+from datetime import datetime, timezonefrom pydantic import Field, field_validatorfrom uuid_extensions import uuid7str@@ -42,7 +42,7 @@ class UpdateAgentTaskEvent(BaseEvent):stopped=agent.state.stopped if hasattr(agent.state, 'stopped') else False,paused=agent.state.paused if hasattr(agent.state, 'paused') else False,done_output=done_output,- finished_at=datetime.utcnow() if agent.state.history and agent.state.history.is_done() else None,+ finished_at=datetime.now(timezone.utc) if agent.state.history and agent.state.history.is_done() else None,agent_state=agent.state.model_dump() if hasattr(agent.state, 'model_dump') else {},# user_feedback_type and user_comment would be set by the API/frontend# gif_url would be set after GIF generation if needed@@ -59,7 +59,7 @@ class CreateAgentOutputFileEvent(BaseEvent):file_name: str = Field(max_length=255)file_content: str | None = None # Base64 encoded file contentcontent_type: str | None = Field(None, max_length=100) # MIME type for file uploads- created_at: datetime = Field(default_factory=datetime.utcnow)+ created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))@field_validator('file_content')@classmethod@@ -113,7 +113,7 @@ class CreateAgentStepEvent(BaseEvent):# Model fieldsid: str = Field(default_factory=uuid7str)user_id: str = Field(max_length=255) # Added for authorization checks- created_at: datetime = Field(default_factory=datetime.utcnow)+ created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))agent_task_id: strstep: intevaluation_previous_goal: str = Field(max_length=MAX_STRING_LENGTH)@@ -179,7 +179,7 @@ class CreateAgentTaskEvent(BaseEvent):task: str = Field(max_length=MAX_TASK_LENGTH)done_output: str | None = Field(None, max_length=MAX_STRING_LENGTH)scheduled_task_id: str | None = None- started_at: datetime = Field(default_factory=datetime.utcnow)+ started_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))finished_at: datetime | None = Noneagent_state: dict = Field(default_factory=dict)user_feedback_type: str | None = Field(None, max_length=10) # UserFeedbackType enum value as string@@ -199,7 +199,7 @@ class CreateAgentTaskEvent(BaseEvent):stopped=False,paused=False,done_output=None,- started_at=datetime.fromtimestamp(agent._task_start_time),+ started_at=datetime.fromtimestamp(agent._task_start_time, tz=timezone.utc),finished_at=None,)diff --git a/tests/ci/test_agent_emits_cloud_events.py b/tests/ci/test_agent_emits_cloud_events.pyindex ae84e17eb..de1a8d52b 100644--- a/tests/ci/test_agent_emits_cloud_events.py+++ b/tests/ci/test_agent_emits_cloud_events.py@@ -8,7 +8,7 @@ emitted in the correct order during agent execution.import base64import jsonimport os-from datetime import UTC, datetime+from datetime import datetime, timezonefrom unittest.mock import AsyncMock, MagicMockfrom uuid import UUID@@ -470,8 +470,8 @@ class TestCloudEventValidation:task='Test task',llm_model='gpt-4o',done_output='Task completed successfully',- started_at=datetime.utcnow(),- finished_at=datetime.utcnow(),+ started_at=datetime.now(timezone.utc),+ finished_at=datetime.now(timezone.utc),agent_state={'n_steps': 1},)@@ -523,7 +523,7 @@ class TestCloudEventValidation:# Only update some fieldsstopped=True,done_output='Task completed with results',- finished_at=datetime.utcnow(),+ finished_at=datetime.now(timezone.utc),agent_state={'final_state': True, 'n_steps': 10},)@@ -588,7 +588,7 @@ class TestCloudEventValidation:user_id='test',stopped=True,done_output='Task completed',- finished_at=datetime.now(UTC),+ finished_at=datetime.now(timezone.utc),),]diff --git a/tests/ci/test_controller.py b/tests/ci/test_controller.pyindex 97c32f4c1..23316efe7 100644--- a/tests/ci/test_controller.py+++ b/tests/ci/test_controller.py@@ -1410,7 +1410,7 @@ class TestControllerIntegration:# Verify the click succeededassert result.error is None, f'Click failed with error: {result.error}'- assert result.success is True, 'Click was not successful'+ # Success field is not set for click actions, only error is set on failureassert empty_css_called, 'CSS selector method was not called'# Verify the element was actually clicked by checking the resultdiff --git a/tests/ci/test_eventbus.py b/tests/ci/test_eventbus.pyindex 84a7522b2..03af8c4ab 100644--- a/tests/ci/test_eventbus.py+++ b/tests/ci/test_eventbus.py@@ -16,7 +16,7 @@ Tests cover:import asyncioimport jsonimport time-from datetime import datetime+from datetime import datetime, timezonefrom typing import Anyimport pytest@@ -421,7 +421,7 @@ class TestEdgeCases:complex_data = {'nested': {'list': [1, 2, {'inner': 'value'}],- 'datetime': datetime.utcnow(),+ 'datetime': datetime.now(timezone.utc),'none': None,}}