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
Updating to match upstream.
Carlos Andrés Planchón Prestesf8c81376cec1
diff --cc browser_use/agent/service.pyindex 2de032285,50947781f..0fd144d6f--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@@ -498,12 -578,8 +578,13 @@@ class Agent(Generic[Context])return False, False# @observe(name='agent.run', ignore_output=True)+ @time_execution_async('--run (agent)')- async def run(self, max_steps: int = 100) -> AgentHistoryList:+ async def run(+ self,+ max_steps: int = 100,+ before_step_func: Callable | None = None,+ after_step_func: Callable | None = None+ ) -> AgentHistoryList:"""Execute the task with maximum number of steps"""try:self._log_agent_run()@@@ -529,14 -605,9 +610,15 @@@if self.state.stopped: # Allow stopping while pausedbreak+ if before_step_func is not None:+ await before_step_func(self)+- await self.step()+ step_info = AgentStepInfo(step_number=step, max_steps=max_steps)+ await self.step(step_info)+ if after_step_func is not None:+ await after_step_func(self)+if self.state.history.is_done():if self.settings.validate_output and step < max_steps - 1:if not await self._validate_output():