Skip to content

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

Add method to get number of steps in agent history

Magnus Müller31fe2cfcbb20
diff --git a/browser_use/agent/views.py b/browser_use/agent/views.py
index cb4f04c96..8476dd592 100644
--- a/browser_use/agent/views.py
+++ b/browser_use/agent/views.py
@@ -306,6 +306,10 @@ class AgentHistoryList(BaseModel):
result.append(o)
return result
+ def number_of_steps(self) -> int:
+ """Get the number of steps in the history"""
+ return len(self.history)
+
class AgentError:
"""Container for agent error handling"""