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
Fix evaluate
Magnus Müller1f58f60c2e2c
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.pyindex e39f4ce6b..976ce75d4 100644--- a/browser_use/tools/service.py+++ b/browser_use/tools/service.py@@ -1024,8 +1024,8 @@ Validated Code (after quote fixing):# Check for wasThrown flag (backup error detection)if result_data.get('wasThrown'):- msg = 'JavaScript execution failed (wasThrown=true)'- logger.debug(f'Code: {code[:200]}...')+ msg = f'JavaScript code: {code} execution failed (wasThrown=true)'+ logger.debug(msg)return ActionResult(error=msg)# Get the actual value@@ -1047,8 +1047,8 @@ Validated Code (after quote fixing):result_text = str(value)# Apply length limit with better truncation- if len(result_text) > 50000:- result_text = result_text[:49950] + '\n... [Truncated after 50000 characters]'+ if len(result_text) > 20000:+ result_text = result_text[:19950] + '\n... [Truncated after 20000 characters]'# Don't log the code - it's already visible in the user's celllogger.debug(f'JavaScript executed successfully, result length: {len(result_text)}')# Return only the result, not the code (code is already in user's cell)@@ -1057,7 +1057,7 @@ Validated Code (after quote fixing):except Exception as e:# CDP communication or other system errorserror_msg = f'Failed to execute JavaScript: {type(e).__name__}: {e}'- logger.debug(f'Code that failed: {code[:200]}...')+ logger.debug(f'JavaScript code that failed: {code[:200]}...')return ActionResult(error=error_msg)def _validate_and_fix_javascript(self, code: str) -> str: