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
Resolve Rust conversation paths like Browser Use
Magnus Müllere9ae14b5cc1a
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 53362e8d0..be3f024cd 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -996,10 +996,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- Delegated terminal follow-up runs now send the same raw follow-up text through `browser-use-terminal followup ...`, while the existing `output_model_schema` remains attached to the agent for result parsing.- Proof: `test_rust_agent_add_new_task_preserves_browser_use_raw_followup_task`.+197. Rust Agent conversation-path setup parity+ - Rust-backed construction now resolves `save_conversation_path` with `expanduser().resolve()` and logs Browser Use's "Saving conversation to ..." message before runs.+ - Terminal conversation snapshots continue to write under the resolved directory while preserving the configured file encoding.+ - Proof: `test_rust_agent_resolves_conversation_path_like_browser_use`.+## Current Verification- `python3 -m py_compile browser_use/agent/service.py browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`-- `uv run pytest -q tests/ci/test_rust_agent.py` (165 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (166 tests)- `cargo build -q -p browser-use-cli` on terminal branch `magnus/browser-use-rust-main-integration`- `cargo test -q -p browser-use-cli run_codex_session_command_accepts_task_id_and_model -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 62efd7e2b..77f7da3ba 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -58,7 +58,7 @@ from browser_use.tokens.service import TokenCostfrom browser_use.tokens.views import ModelUsageStats, UsageSummaryfrom browser_use.tools.registry.views import ActionModelfrom browser_use.tools.service import Tools-from browser_use.utils import SignalHandler, URL_PATTERN, check_latest_browser_use_version, get_browser_use_version+from browser_use.utils import SignalHandler, URL_PATTERN, _log_pretty_path, check_latest_browser_use_version, get_browser_use_versionContext = TypeVar('Context')@@ -2511,6 +2511,9 @@ class Agent(Generic[Context, AgentStructuredOutput]):step_timeout=step_timeout,final_response_after_failure=final_response_after_failure,)+ if self.settings.save_conversation_path:+ self.settings.save_conversation_path = Path(self.settings.save_conversation_path).expanduser().resolve()+ self.logger.info(f'💬 Saving conversation to {_log_pretty_path(self.settings.save_conversation_path)}')self._setup_action_models()model_name = str(getattr(self.llm, 'model', self.model) or '').lower()if 'deepseek' in model_name:diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 1d6397130..331832ab8 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -6007,6 +6007,57 @@ async def test_rust_agent_saves_terminal_conversation(tmp_path, monkeypatch):assert agent.state.n_steps == 2+async def test_rust_agent_resolves_conversation_path_like_browser_use(tmp_path, monkeypatch):+ from browser_use.rust import Agent+ from browser_use.utils import _log_pretty_path++ monkeypatch.setenv('BROWSER_USE_TERMINAL_BINARY', '/tmp/browser-use-terminal')++ class RecordingLogger:+ def __init__(self):+ self.infos = []++ def info(self, message, *args, **kwargs):+ self.infos.append(message)++ def debug(self, message, *args, **kwargs):+ pass++ def warning(self, message, *args, **kwargs):+ pass++ def error(self, message, *args, **kwargs):+ pass++ logger = RecordingLogger()+ monkeypatch.setattr(Agent, 'logger', property(lambda self: logger))+ conversation_dir = tmp_path / 'conversations'+ agent = Agent(+ task='save resolved conversation path',+ llm=type('LLM', (), {'model': 'gpt-test'})(),+ task_id='task-path',+ save_conversation_path=conversation_dir,+ )++ assert agent.settings.save_conversation_path == conversation_dir.resolve()+ assert logger.infos[0] == f'💬 Saving conversation to {_log_pretty_path(conversation_dir.resolve())}'++ async def fake_run_process(argv, timeout_seconds=None):+ return 0, 'Session: 12345678-1234-1234-1234-123456789abc\n', ''++ async def fake_load_events():+ return [{'event_type': 'session.done', 'payload': {'result': 'saved path transcript'}}]++ agent._run_process = fake_run_process+ agent._load_events = fake_load_events++ await agent.run(max_steps=2)++ files = list(conversation_dir.resolve().glob('conversation_task-path_*.json'))+ assert len(files) == 1+ assert json.loads(files[0].read_text(encoding='utf-8'))['final_result'] == 'saved path transcript'++async def test_rust_agent_terminal_process_timeout():from browser_use.rust import Agent