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
Logging for max token limit
magmuellerde5a194bb6a4
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 37aae1eb0..81941c22b 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -161,6 +161,13 @@ class Agent:if isinstance(error, (ValidationError, ValueError)):logger.error(f'{prefix}{error_msg}')+ if 'Max token limit reached' in error_msg:+ # cut tokens from history+ self.message_manager.max_input_tokens = self.max_input_tokens - 500+ logger.info(+ f'Cutting tokens from history - new max input tokens: {self.message_manager.max_input_tokens}'+ )+ self.message_manager.cut_messages()self.consecutive_failures += 1elif isinstance(error, RateLimitError):logger.warning(f'{prefix}{error_msg}')