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
Reconstruct Rust browser live URLs
Magnus Müllerbaa7bf63f711
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex aaed3c485..63ebe0256 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -734,10 +734,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- This preserves interrupted subagent/session lifecycle outcomes on Python-visible `errors()`, `is_done()`, and final `ActionResult.error` surfaces.- Proof: `test_rust_history_surfaces_terminal_session_interrupted_message`.+145. Rust terminal browser live-URL reconstruction+ - Terminal `browser.live_url` events are now reconstructed into Browser Use `BrowserStateHistory`.+ - This preserves Rust current-main live browser URLs on Python-visible `AgentHistoryList.urls()`, step state, telemetry, callbacks, and saved conversation snapshots even when no `browser.state` event is present.+ - Proof: `test_rust_history_reconstructs_terminal_browser_live_url`.+## 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` (116 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (117 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 5a7458592..464e8f4b0 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -1561,10 +1561,17 @@ def _browser_state_from_events(events: list[dict[str, Any]]) -> BrowserStateHisttitle = candidate_title or titletabs = [TabInfo(url=url, title=title, target_id=candidate_target_id)]continue- if event_type not in ('browser.connected', 'browser.reconnected', 'browser.target_changed', 'browser.page', 'browser.state'):+ if event_type not in (+ 'browser.connected',+ 'browser.reconnected',+ 'browser.target_changed',+ 'browser.live_url',+ 'browser.page',+ 'browser.state',+ ):continuepayload = _event_payload(event)- url = _browser_url(payload.get('url')) or url+ url = _browser_url(payload.get('live_url')) or _browser_url(payload.get('url')) or urltitle = str(payload.get('title') or title)raw_tabs = payload.get('tabs')if isinstance(raw_tabs, list):diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex f5e65b935..f9fdda36f 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -318,6 +318,32 @@ def test_rust_history_reconstructs_terminal_browser_script_urls():assert navigation_history.urls() == ['https://example.com']+def test_rust_history_reconstructs_terminal_browser_live_url():+ from browser_use.rust.service import _history_from_events++ history = _history_from_events(+ [+ {+ 'type': 'browser.live_url',+ 'payload': {+ 'live_url': 'https://live.browser-use.com/watch/session-123',+ 'url': 'https://live.browser-use.com/watch/session-123',+ },+ },+ {'event_type': 'session.done', 'payload': {'result': 'final answer'}},+ ],+ model='gpt-test',+ started=1.0,+ finished=2.0,+ output_model_schema=None,+ process_error=None,+ )++ assert history.urls() == ['https://live.browser-use.com/watch/session-123']+ assert history.history[0].state.url == 'https://live.browser-use.com/watch/session-123'+ assert history.history[0].state.tabs[0].url == 'https://live.browser-use.com/watch/session-123'++def test_rust_history_reconstructs_terminal_screenshot_paths(tmp_path):import base64