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
Surface Rust terminal stream errors
Magnus Müllerff6d3cbf7c56
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 68b70dc0e..82e508f34 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -608,10 +608,16 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- This removes string-annotation drift from the Rust wrapper and keeps docs, runtime introspection, and dependency-injection tooling aligned with the Browser Use Agent interface after the redirect.- Proof: `test_rust_agent_runtime_signatures_match_browser_use_callable_surface`.+120. Rust Agent terminal stream-error reconstruction+ - Terminal current-main `stream_error` events are now reconstructed as Browser Use history errors instead of being collapsed into the generic missing-final-result fallback.+ - This gives Python callers accurate diagnostics for cloud and benchmark runs where the terminal core reaches the browser but the model stream fails before `session.done`.+ - Proof: `test_rust_history_surfaces_terminal_stream_error_message`.+ - Evidence: real_v8 cloud task `18` reached Browser Use cloud and emitted terminal `stream_error` provider messages before this reconstruction fix.+## 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` (92 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (93 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 e0f9f89ad..b3381a8c4 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -781,8 +781,10 @@ def _structured_result_text(def _failure_from_events(events: list[dict[str, Any]]) -> str | None:for event in reversed(events):- if _event_type(event) == 'session.failed':- error = _event_payload(event).get('error')+ event_type = _event_type(event)+ if event_type in ('session.failed', 'stream_error'):+ payload = _event_payload(event)+ error = payload.get('error') or payload.get('message')if isinstance(error, str) and error:return errorreturn Nonediff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 59c6ae1f5..0be450175 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -2489,6 +2489,26 @@ def test_rust_history_marks_missing_terminal_result_as_error():assert history.errors() == ['Rust terminal session did not produce a final result.']+def test_rust_history_surfaces_terminal_stream_error_message():+ from browser_use.rust.service import _history_from_events++ history = _history_from_events(+ [+ {'event_type': 'model.turn.request', 'payload': {'model': 'gpt-test'}},+ {'event_type': 'stream_error', 'payload': {'message': 'provider error'}},+ ],+ model='gpt-test',+ started=1.0,+ finished=2.0,+ output_model_schema=None,+ process_error=None,+ )++ assert history.final_result() is None+ assert history.is_done() is False+ assert history.errors() == ['provider error']++def test_real_v8_smoke_selects_case_by_index_and_task_id(tmp_path):module = _load_real_v8_smoke_module()dataset = tmp_path / 'real_v8.json'