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 'cp932' codec can't encode character when using the option to save conversation to a file.
yoichiro abe832127d42402
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex c29380a44..820f313ce 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -67,6 +67,7 @@ class Agent:controller: Controller = Controller(),use_vision: bool = True,save_conversation_path: Optional[str] = None,+ save_conversation_path_encoding: Optional[str] = "utf-8",max_failures: int = 3,retry_delay: int = 10,system_prompt_class: Type[SystemPrompt] = SystemPrompt,@@ -95,6 +96,7 @@ class Agent:self.use_vision = use_visionself.llm = llmself.save_conversation_path = save_conversation_path+ self.save_conversation_path_encoding = save_conversation_path_encodingself._last_result = Noneself.include_attributes = include_attributesself.max_error_length = max_error_length@@ -322,7 +324,7 @@ class Agent:# create folders if not existsos.makedirs(os.path.dirname(self.save_conversation_path), exist_ok=True)- with open(self.save_conversation_path + f'_{self.n_steps}.txt', 'w') as f:+ with open(self.save_conversation_path + f'_{self.n_steps}.txt', 'w', encoding=self.save_conversation_path_encoding) as f:self._write_messages_to_file(f, input_messages)self._write_response_to_file(f, response)