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
Record eval-visible Rust history proof
Magnus Müller8242a18e3ea8
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex b88320917..7bb6580da 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -1533,6 +1533,11 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- Rust wrapper construction initializes action/output models and verifies the LLM even when `save_conversation_path` is not set, matching normal Python `Agent` initialization and preventing hosted eval refs from producing empty one-step histories because setup was skipped.- Proof: browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k 'rust_agent_initializes_action_models_without_conversation_path or rust_agent_setup_action_models_signature_matches_browser_use or rust_agent_resolves_conversation_path_like_browser_use'`.+290. Rust Agent eval-visible multi-turn history and usage proof+ - Added a focused regression proof that a realistic two-turn Rust terminal event stream reconstructs two Browser Use history entries, two eval-visible action-history rows, a final `done` result, and nonzero aggregated token usage.+ - This directly guards the hosted stale-ref symptom where long Rust runs appeared in the dashboard as one step with `tokensUsed=0`; the proof belongs on the real `browser_use.rust.Agent` branch rather than in the eval runner.+ - Proof: browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k 'rust_history_reconstructs_eval_visible_multi_turn_actions_and_usage or rust_agent_initializes_action_models_without_conversation_path'`.+## Current Verification- terminal `cargo test -q -p browser-use-browser browser_script_browser_fetch_single_returns_structured_errors_by_default -- --nocapture` on commit `e109049`@@ -1542,6 +1547,9 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- terminal `cargo build -q -p browser-use-cli --bin browser-use-terminal`- browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k 'rust_agent_initializes_action_models_without_conversation_path or rust_agent_setup_action_models_signature_matches_browser_use or rust_agent_resolves_conversation_path_like_browser_use'`- browser-use `uv run ruff format browser_use/agent/service.py browser_use/rust/service.py tests/ci/test_rust_agent.py`+- browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k 'rust_history_reconstructs_eval_visible_multi_turn_actions_and_usage or rust_agent_initializes_action_models_without_conversation_path'`+- browser-use `uv run python -m py_compile tests/ci/test_rust_agent.py`+- browser-use `git diff --check -- tests/ci/test_rust_agent.py`- evaluations-internal `PYTHONPATH=. uv run pytest tests/test_service_cli.py -k 'agent_sdk_judge'` on commit `40e2360`- evaluations-internal `PYTHONPATH=. uv run pytest tests/test_service_cli.py -k 'agent_sdk_judge_timeout or single_generous or timeout_default or timeout_inherits or explicit_timeouts or service_cli_defaults_to_100'` on commit `40e2360`- evaluations-internal `git diff --check -- eval/judges/agent_sdk_judge.py tests/test_service_cli.py`diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 88b52ad91..749ea2bb4 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -542,6 +542,88 @@ def test_rust_history_reconstructs_terminal_tool_call_actions():assert history.action_results()[-1].is_done is True+def test_rust_history_reconstructs_eval_visible_multi_turn_actions_and_usage():+ from browser_use.rust.service import _history_from_events++ history = _history_from_events(+ [+ {'type': 'model.turn.request', 'ts_ms': 1_000, 'payload': {'model': 'claude-sonnet-4-6'}},+ {'type': 'browser.state', 'ts_ms': 1_010, 'payload': {'url': 'about:blank', 'title': ''}},+ {+ 'type': 'tool.started',+ 'ts_ms': 1_020,+ 'payload': {+ 'name': 'browser_script',+ 'tool_call_id': 'call-open',+ 'arguments': {'code': "goto_url('https://example.com')"},+ },+ },+ {+ 'type': 'tool.output',+ 'ts_ms': 1_030,+ 'payload': {'name': 'browser_script', 'tool_call_id': 'call-open', 'text': 'Opened Example Domain'},+ },+ {'type': 'model.usage', 'payload': {'input_tokens': 100, 'cached_input_tokens': 20, 'output_tokens': 15}},+ {'type': 'model.turn.request', 'ts_ms': 2_000, 'payload': {'model': 'claude-sonnet-4-6'}},+ {'type': 'browser.state', 'ts_ms': 2_010, 'payload': {'url': 'https://example.com', 'title': 'Example Domain'}},+ {+ 'type': 'model.tool_call',+ 'ts_ms': 2_020,+ 'payload': {+ 'id': 'call-extract',+ 'name': 'browser_script',+ 'arguments': {'code': 'emit_output(page_info(), label="page_info")'},+ },+ },+ {+ 'type': 'tool.output',+ 'ts_ms': 2_030,+ 'payload': {+ 'name': 'browser_script',+ 'tool_call_id': 'call-extract',+ 'text': 'Page title: Example Domain',+ },+ },+ {'type': 'model.usage', 'payload': {'input_tokens': 140, 'cached_input_tokens': 90, 'output_tokens': 25}},+ {+ 'type': 'tool.started',+ 'ts_ms': 2_040,+ 'payload': {+ 'name': 'done',+ 'tool_call_id': 'call-done',+ 'arguments': {'text': 'Example Domain', 'success': True},+ },+ },+ {'type': 'session.done', 'ts_ms': 2_050, 'payload': {'result': 'Example Domain'}},+ ],+ model='claude-sonnet-4-6',+ started=1.0,+ finished=2.5,+ output_model_schema=None,+ process_error=None,+ )++ dump = history.model_dump()+ action_history = history.action_history()++ assert history.number_of_steps() == 2+ assert len(dump['history']) == 2+ assert history.action_names() == ['browser_script', 'browser_script', 'done']+ assert action_history[0][0]['browser_script']['code'] == "goto_url('https://example.com')"+ assert action_history[0][0]['result'] == 'Opened Example Domain'+ assert action_history[1][0]['browser_script']['code'] == 'emit_output(page_info(), label="page_info")'+ assert action_history[1][0]['result'] == 'Page title: Example Domain'+ assert action_history[1][-1]['done'] == {'text': 'Example Domain', 'success': True}+ assert 'https://example.com' in history.urls()+ assert history.final_result() == 'Example Domain'+ assert history.usage is not None+ assert history.usage.total_prompt_tokens == 240+ assert history.usage.total_prompt_cached_tokens == 110+ assert history.usage.total_completion_tokens == 40+ assert history.usage.total_tokens == 280+ assert history.usage.entry_count == 2++def test_rust_history_reconstructs_terminal_model_tool_call_actions():from browser_use.rust.service import _history_from_events