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
Add handling for zero last screenshots in AgentHistoryList.screenshots method
Magnus Müller5cf281f31582
diff --git a/browser_use/agent/views.py b/browser_use/agent/views.pyindex c2c73b081..31e9ef0c6 100644--- a/browser_use/agent/views.py+++ b/browser_use/agent/views.py@@ -405,6 +405,8 @@ class AgentHistoryList(BaseModel, Generic[AgentStructuredOutput]):def screenshots(self, n_last: int | None = None, return_none_if_not_screenshot: bool = True) -> list[str | None]:"""Get all screenshots from history"""+ if n_last == 0:+ return []if n_last is None:if return_none_if_not_screenshot:return [h.state.screenshot if h.state.screenshot is not None else None for h in self.history]