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 json mode issue and update branch for testing json mode
mertunsall38ee251acc2e
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex fc6c31a4f..155b4c946 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -526,10 +526,10 @@ class Agent(Generic[Context]):logger.debug(f'🛠️ Tool calling method {method} failed: Failed to parse JSON content: {e}')return False- if method == 'raw':+ if method == 'raw' or method == 'json_mode':# For raw mode, test JSON response formattest_prompt = f"""{CAPITAL_QUESTION}- Respond with a JSON object like: {{"answer": "city_name_in_lowercase"}}"""+ Respond with a json object like: {{"answer": "city_name_in_lowercase"}}"""response = self.llm.invoke([test_prompt])# Basic validation of response@@ -657,8 +657,8 @@ class Agent(Generic[Context]):if self.chat_model_library == 'ChatOpenAI':if any(m in model_lower for m in ['gpt-4', 'gpt-3.5']):return 'function_calling'- if any(m in model_lower for m in ['llama-4', 'llama-3']):- return 'function_calling'+ if any(m in model_lower for m in ['llama']):+ return 'json_mode'# Azure OpenAI modelselif self.chat_model_library == 'AzureChatOpenAI':diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex 3eed85f16..94069a4f5 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -79,4 +79,5 @@ Common action sequences:9. Extraction:- If your task is to find information - call extract_content on the specific pages to get and store the information.- Your responses must be always JSON with the specified format.++Your responses must be always JSON with the specified format.