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: Add support for replacing literal secret names in LLM output.
mo19983a304997ca23
diff --git a/browser_use/tools/registry/service.py b/browser_use/tools/registry/service.pyindex 77817cbf4..2186e3141 100644--- a/browser_use/tools/registry/service.py+++ b/browser_use/tools/registry/service.py@@ -451,8 +451,8 @@ class Registry(Generic[Context]):def recursively_replace_secrets(value: str | dict | list) -> str | dict | list:if isinstance(value, str):+ # 1. Handle tagged secrets: <secret>label</secret>matches = secret_pattern.findall(value)- # check if the placeholder key, like x_password is in the output parameters of the LLM and replace it with the sensitive datafor placeholder in matches:if placeholder in applicable_secrets:# generate a totp code if secret is suffixed with bu_2fa_code@@ -467,7 +467,17 @@ class Registry(Generic[Context]):else:# Keep track of missing placeholdersall_missing_placeholders.add(placeholder)- # Don't replace the tag, keep it as is++ # 2. Handle literal secrets: "user_name" (no tags)+ # This handles cases where the LLM forgets to use tags but uses the exact placeholder name+ if value in applicable_secrets:+ placeholder_name = value+ if placeholder_name.endswith('bu_2fa_code'):+ totp = pyotp.TOTP(applicable_secrets[placeholder_name], digits=6)+ value = totp.now()+ else:+ value = applicable_secrets[placeholder_name]+ replaced_placeholders.add(placeholder_name)return valueelif isinstance(value, dict):