Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Adding .python-version to .gitignore.

Carlos Andrés Planchón Prestes831558bb9f3d
diff --git a/.gitignore b/.gitignore
index c328cfc9a..a2a7b9d42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -186,3 +186,4 @@ gcp-login.json
*.csv
*.json
*.jsonl
+.python-version
diff --git a/.python-version b/.python-version
index 2c0733315..def4b3b8f 100644
--- a/.python-version
+++ b/.python-version
@@ -1 +1 @@
-3.11
+browseruse3132
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index b9f3db316..522f68cc5 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -498,7 +498,11 @@ class Agent(Generic[Context]):
return False, False
# @observe(name='agent.run', ignore_output=True)
- async def run(self, max_steps: int = 100) -> AgentHistoryList:
+ async def run(
+ self,
+ max_steps: int = 100,
+ after_step_func: Callable | None = None
+ ) -> AgentHistoryList:
"""Execute the task with maximum number of steps"""
try:
self._log_agent_run()
@@ -526,6 +530,8 @@ class Agent(Generic[Context]):
await self.step()
+ 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():