Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Promote beta core package quickstart

Gregor Žunič7a888eb9a46c
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/BETA_AGENT_INTEGRATION_FEATURES.md
similarity index 85%
rename from RUST_AGENT_INTEGRATION_FEATURES.md
rename to BETA_AGENT_INTEGRATION_FEATURES.md
index 73bb382d4..f66492da0 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/BETA_AGENT_INTEGRATION_FEATURES.md
@@ -1,12 +1,12 @@
# Rust Agent Integration Feature/Proof Ledger
This branch keeps the Python `Agent` unchanged unless callers explicitly import
-`from browser_use.rust import Agent`.
+`from browser_use.beta import Agent`.
## Current Features
1. Rust SDK server execution path
- - `browser_use.rust.Agent` now runs normal tasks through the terminal SDK server
+ - `browser_use.beta.Agent` now runs normal tasks through the terminal SDK server
(`browser-use-terminal sdk-server --transport stdio`) using the normalized
`agent.run_task` request/response protocol.
- Follow-up tasks reuse the returned SDK `agent_id`, `session_id`, and `browser_id`
@@ -64,7 +64,7 @@ This branch keeps the Python `Agent` unchanged unless callers explicitly import
- Terminal Rust runs only advertise sub-agent tools when the run has a
configured child-agent runner, and SDK JSON-RPC runs now attach the same
runtime-backed child runner as CLI runs. This enables terminal's advanced
- sub-agent system in `browser_use.rust.Agent` evals without exposing
+ sub-agent system in `browser_use.beta.Agent` evals without exposing
spawn tools on unsupported run surfaces.
- Eval GitHub runners now refresh Convex progress during long `run_agent`
and `evaluate` stages, so slow Rust or Agent SDK judge calls stay visible
@@ -176,7 +176,7 @@ This branch keeps the Python `Agent` unchanged unless callers explicitly import
traces against that combined stream, so sub-agent model calls contribute to
run token/cost totals without letting child `session.done` events override
the parent final answer.
- - `browser_use.rust.Agent` no longer treats `_run_process` monkeypatches as an
+ - `browser_use.beta.Agent` no longer treats `_run_process` monkeypatches as an
alternate runtime. Production `run()` and `follow_up()` now require the
Rust SDK server path, so the legacy terminal CLI adapter cannot silently
replace the new server protocol while the normal Python `browser_use.Agent`
@@ -193,7 +193,7 @@ This branch keeps the Python `Agent` unchanged unless callers explicitly import
telemetry payloads when the terminal server returns both live and projected
event streams.
- Browser-use no longer sends a Rust SDK `tool_allowlist` override. The
- terminal SDK server now owns its tool registry for `browser_use.rust.Agent`
+ terminal SDK server now owns its tool registry for `browser_use.beta.Agent`
runs, so local search, web/search helpers, and v2 sub-agent controls are
available in evals when the Rust core registers them.
- Reconstructed browser history ignores internal browser-control endpoint
@@ -244,21 +244,21 @@ This branch keeps the Python `Agent` unchanged unless callers explicitly import
- terminal `cargo test -p browser-use-cli sdk_json_rpc_agent_run_task_executes_fake_backend_with_normalized_history -- --nocapture`
- terminal `cargo test -p browser-use-llm stream_ -- --nocapture`
- terminal `cargo test -p browser-use-cli sdk_provider_run_config_maps_browser_use_options_to_rust_core -- --nocapture`
-- browser-use `uv run python -m py_compile browser_use/rust/service.py`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -k 'browser_script_lifecycle_outputs_as_result or initial_actions_pre_navigate_existing_cdp_session or run_hands_off_completed_initial_navigation_as_context' -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -k 'printed_browser_script_page_info_as_state or browser_script_lifecycle_outputs_as_result or initial_actions_pre_navigate_existing_cdp_session or run_hands_off_completed_initial_navigation_as_context' -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_history_surfaces_running_browser_script_observe_instruction -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -k 'initial_actions_pre_navigate_existing_cdp_session or run_executes_initial_actions_before_sdk or run_hands_off_completed_initial_navigation_as_context' -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -k 'sdk_client_reads_large_json_rpc_lines or sdk_and_reuses_session or translates_browser_use_args_to_terminal'`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -k 'sdk_client_queues_agent_notifications_before_response or sdk_client_reads_large_json_rpc_lines or sdk_and_reuses_session or translates_browser_use_args_to_terminal'`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -k 'rust_sdk_client_reads_large_json_rpc_lines or rust_sdk_client_queues_agent_notifications_before_response' -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_sdk_client_reads_large_json_rpc_lines tests/ci/test_rust_agent.py::test_rust_agent_run_leaves_initial_navigation_for_sdk_by_default tests/ci/test_rust_agent.py::test_rust_agent_initial_actions_can_pre_navigate_existing_cdp_session tests/ci/test_rust_agent.py::test_rust_agent_translates_browser_use_args_to_terminal -q`
-- browser-use `PYTHONPATH=. uv run pytest tests/ci/test_rust_agent.py -q -k 'pre_navigates_cdp_session_before_sdk_by_default or initial_actions_can_pre_navigate_existing_cdp_session or direct_initial_navigation_defaults_on_for_cdp or direct_initial_navigation_can_be_disabled'`
-- browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k "pre_navigates_cdp_session_before_sdk_by_default or keeps_initial_navigation_when_direct_state_mismatches or initial_actions_can_pre_navigate_existing_cdp_session or direct_initial_navigation_defaults_on_for_cdp"`
-- browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k "terminal_token_count_usage or sums_token_count_last_usage_when_latest_total_underreports or terminal_usage_prices_token_count_events or terminal_usage_sums_token_count_cache_creation"`
-- browser-use `uv run pytest -q tests/ci/test_rust_agent.py -k "terminal_nested_model_usage or token_count_does_not_shrink_model_usage_totals or terminal_usage_prices_token_count_events or terminal_usage_prices_anthropic_raw_cache_reads or terminal_usage_sums_token_count_cache_creation or priced_summary_sums_cache_read_tokens or mixed_events_do_not_shrink_totals or priced_usage_prefers_model_usage_over_token_count or sums_token_count_last_usage_when_latest_total_underreports"`
-- browser-use `python -m py_compile browser_use/rust/service.py`
+- browser-use `uv run python -m py_compile browser_use/beta/service.py`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -k 'browser_script_lifecycle_outputs_as_result or initial_actions_pre_navigate_existing_cdp_session or run_hands_off_completed_initial_navigation_as_context' -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -k 'printed_browser_script_page_info_as_state or browser_script_lifecycle_outputs_as_result or initial_actions_pre_navigate_existing_cdp_session or run_hands_off_completed_initial_navigation_as_context' -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_rust_history_surfaces_running_browser_script_observe_instruction -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -k 'initial_actions_pre_navigate_existing_cdp_session or run_executes_initial_actions_before_sdk or run_hands_off_completed_initial_navigation_as_context' -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -k 'sdk_client_reads_large_json_rpc_lines or sdk_and_reuses_session or translates_browser_use_args_to_terminal'`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -k 'sdk_client_queues_agent_notifications_before_response or sdk_client_reads_large_json_rpc_lines or sdk_and_reuses_session or translates_browser_use_args_to_terminal'`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -k 'rust_sdk_client_reads_large_json_rpc_lines or rust_sdk_client_queues_agent_notifications_before_response' -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_rust_sdk_client_reads_large_json_rpc_lines tests/ci/test_beta_agent.py::test_beta_agent_run_leaves_initial_navigation_for_sdk_by_default tests/ci/test_beta_agent.py::test_beta_agent_initial_actions_can_pre_navigate_existing_cdp_session tests/ci/test_beta_agent.py::test_beta_agent_translates_browser_use_args_to_terminal -q`
+- browser-use `PYTHONPATH=. uv run pytest tests/ci/test_beta_agent.py -q -k 'pre_navigates_cdp_session_before_sdk_by_default or initial_actions_can_pre_navigate_existing_cdp_session or direct_initial_navigation_defaults_on_for_cdp or direct_initial_navigation_can_be_disabled'`
+- browser-use `uv run pytest -q tests/ci/test_beta_agent.py -k "pre_navigates_cdp_session_before_sdk_by_default or keeps_initial_navigation_when_direct_state_mismatches or initial_actions_can_pre_navigate_existing_cdp_session or direct_initial_navigation_defaults_on_for_cdp"`
+- browser-use `uv run pytest -q tests/ci/test_beta_agent.py -k "terminal_token_count_usage or sums_token_count_last_usage_when_latest_total_underreports or terminal_usage_prices_token_count_events or terminal_usage_sums_token_count_cache_creation"`
+- browser-use `uv run pytest -q tests/ci/test_beta_agent.py -k "terminal_nested_model_usage or token_count_does_not_shrink_model_usage_totals or terminal_usage_prices_token_count_events or terminal_usage_prices_anthropic_raw_cache_reads or terminal_usage_sums_token_count_cache_creation or priced_summary_sums_cache_read_tokens or mixed_events_do_not_shrink_totals or priced_usage_prefers_model_usage_over_token_count or sums_token_count_last_usage_when_latest_total_underreports"`
+- browser-use `python -m py_compile browser_use/beta/service.py`
- terminal `cargo test -p browser-use-cli sdk_transport -- --nocapture`
- terminal `cargo test -p browser-use-providers server_overloaded -- --nocapture`
- terminal `cargo test -p browser-use-agent observe_timeout -- --nocapture`
@@ -269,22 +269,22 @@ This branch keeps the Python `Agent` unchanged unless callers explicitly import
- terminal `cargo test -p browser-use-agent search -- --nocapture`
- terminal `cargo test -p browser-use-agent dispatcher -- --nocapture`
- terminal `cargo test -p browser-use-cli sdk_json_rpc_agent_run_returns_child_usage_events_separately -- --nocapture`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_runs_through_sdk_and_reuses_session_for_followup tests/ci/test_rust_agent.py::test_rust_agent_recovers_final_result_from_sdk_notifications_after_transport_error tests/ci/test_rust_agent.py::test_rust_agent_preserves_sdk_notification_history_on_cancel -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_recovers_final_result_from_sdk_notifications_after_transport_error tests/ci/test_rust_agent.py::test_rust_agent_recovers_nested_sdk_notification_events tests/ci/test_rust_agent.py::test_rust_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_recovers_nested_sdk_notification_events tests/ci/test_rust_agent.py::test_rust_agent_prefers_notification_final_when_response_history_lacks_result tests/ci/test_rust_agent.py::test_rust_agent_uses_sdk_history_usage_when_events_do_not_include_usage tests/ci/test_rust_agent.py::test_rust_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_recovers_final_result_from_sdk_notifications_after_transport_error tests/ci/test_rust_agent.py::test_rust_agent_recovers_nested_sdk_notification_events tests/ci/test_rust_agent.py::test_rust_agent_recovers_projected_sdk_final_events tests/ci/test_rust_agent.py::test_rust_agent_prefers_notification_final_when_response_history_lacks_result tests/ci/test_rust_agent.py::test_rust_agent_uses_sdk_history_usage_when_events_do_not_include_usage tests/ci/test_rust_agent.py::test_rust_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_runs_through_sdk_and_reuses_session_for_followup -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_runs_through_sdk_and_reuses_session_for_followup tests/ci/test_beta_agent.py::test_beta_agent_recovers_final_result_from_sdk_notifications_after_transport_error tests/ci/test_beta_agent.py::test_beta_agent_preserves_sdk_notification_history_on_cancel -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_recovers_final_result_from_sdk_notifications_after_transport_error tests/ci/test_beta_agent.py::test_beta_agent_recovers_nested_sdk_notification_events tests/ci/test_beta_agent.py::test_beta_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_recovers_nested_sdk_notification_events tests/ci/test_beta_agent.py::test_beta_agent_prefers_notification_final_when_response_history_lacks_result tests/ci/test_beta_agent.py::test_beta_agent_uses_sdk_history_usage_when_events_do_not_include_usage tests/ci/test_beta_agent.py::test_beta_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_recovers_final_result_from_sdk_notifications_after_transport_error tests/ci/test_beta_agent.py::test_beta_agent_recovers_nested_sdk_notification_events tests/ci/test_beta_agent.py::test_beta_agent_recovers_projected_sdk_final_events tests/ci/test_beta_agent.py::test_beta_agent_prefers_notification_final_when_response_history_lacks_result tests/ci/test_beta_agent.py::test_beta_agent_uses_sdk_history_usage_when_events_do_not_include_usage tests/ci/test_beta_agent.py::test_beta_agent_prices_sdk_child_usage_events_without_overriding_parent_result -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_runs_through_sdk_and_reuses_session_for_followup -q`
- terminal `cargo fmt --check`
- terminal `cargo test -p browser-use-cli sdk_json_rpc_browser_create_preserves_browser_use_settings -- --nocapture`
- terminal `cargo test -p browser-use-cli sdk_provider_run_config_maps_browser_use_options_to_rust_core -- --nocapture`
- terminal `cargo test -p browser-use-agent stored_cloud_profile_uses_sdk_proxy_country_env_when_connecting -- --nocapture`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_sdk_browser_payload_includes_profile_domains_window_and_proxy -q`
-- browser-use `uv run python -m py_compile browser_use/rust/service.py`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_sdk_event_dedupe_removes_projected_usage_duplicates tests/ci/test_rust_agent.py::test_rust_history_ignores_internal_browser_connection_url tests/ci/test_rust_agent.py::test_rust_agent_default_llm_matches_browser_use_default tests/ci/test_rust_agent.py::test_rust_agent_default_llm_respects_default_llm_env tests/ci/test_rust_agent.py::test_rust_agent_exposes_logging_helper_methods tests/ci/test_rust_agent.py::test_rust_agent_telemetry_filters_empty_reconstructed_urls -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py::test_rust_agent_translates_browser_use_args_to_terminal tests/ci/test_rust_agent.py::test_rust_agent_sdk_params_leave_terminal_tools_unrestricted -q`
-- browser-use `uv run pytest tests/ci/test_rust_agent.py -q`
-- browser-use `uv run ruff check browser_use/rust/service.py tests/ci/test_rust_agent.py tests/ci/models/test_llm_model_factory.py`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_sdk_browser_payload_includes_profile_domains_window_and_proxy -q`
+- browser-use `uv run python -m py_compile browser_use/beta/service.py`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_rust_sdk_event_dedupe_removes_projected_usage_duplicates tests/ci/test_beta_agent.py::test_rust_history_ignores_internal_browser_connection_url tests/ci/test_beta_agent.py::test_beta_agent_default_llm_matches_browser_use_default tests/ci/test_beta_agent.py::test_beta_agent_default_llm_respects_default_llm_env tests/ci/test_beta_agent.py::test_beta_agent_exposes_logging_helper_methods tests/ci/test_beta_agent.py::test_beta_agent_telemetry_filters_empty_reconstructed_urls -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py::test_beta_agent_translates_browser_use_args_to_terminal tests/ci/test_beta_agent.py::test_beta_agent_sdk_params_leave_terminal_tools_unrestricted -q`
+- browser-use `uv run pytest tests/ci/test_beta_agent.py -q`
+- browser-use `uv run ruff check browser_use/beta/service.py tests/ci/test_beta_agent.py tests/ci/models/test_llm_model_factory.py`
- terminal `cargo test -p browser-use-browser browser_script_http_get_many_preserves_order_and_errors -- --nocapture`
- terminal `cargo test -p browser-use-browser browser_script_browser_fetch_single_returns_structured_errors_by_default -- --nocapture`
- terminal `cargo test -p browser-use-browser browser_script_js_accepts_anonymous_function_snippets -- --nocapture`
diff --git a/README.md b/README.md
index b33a7e2e8..640522553 100644
--- a/README.md
+++ b/README.md
@@ -49,18 +49,20 @@
# 👋 Human Quickstart
-**1. Create environment and install Browser-Use with [uv](https://docs.astral.sh/uv/) (Python>=3.11):**
-```bash
-uv init && uv add browser-use && uv sync
-# uvx browser-use install # Run if you don't have Chromium installed
+Browser Use 0.13 introduces a new beta agent powered by a Rust core and a browser harness built for current frontier models. It gives the model a real browser/computer action space, persistent tools, and recovery loops inspired by coding agents.
+
+```text
+Python API -> Rust core -> Browser harness -> Web task done
```
-**Experimental Rust agent:** install Browser Use Terminal for `from browser_use.rust import Agent`:
+**1. Install Browser Use with the native core runtime (Python>=3.11):**
```bash
-curl -fsSL https://browser-use.com/terminal/install.sh | sh
-browser
+uv add "browser-use[core]"
+# or: pip install "browser-use[core]"
```
+The `[core]` extra installs the native Browser Use runtime for your platform.
+
**2. [Optional] Get your API key from [Browser Use Cloud](https://cloud.browser-use.com/new-api-key?utm_source=github&utm_medium=readme-quickstart-api-key):**
```
# .env
@@ -71,39 +73,23 @@ BROWSER_USE_API_KEY=your-key
**3. Run your first agent:**
```python
-from browser_use import Agent, Browser, ChatBrowserUse
-# from browser_use import ChatGoogle # ChatGoogle(model='gemini-3-flash-preview')
-# from browser_use import ChatAnthropic # ChatAnthropic(model='claude-sonnet-4-6')
-import asyncio
-
-async def main():
- browser = Browser(
- # use_cloud=True, # Use a stealth browser on Browser Use Cloud
- )
-
- agent = Agent(
- task="Find the number of stars of the browser-use repo",
- llm=ChatBrowserUse(),
- # llm=ChatGoogle(model='gemini-3-flash-preview'),
- # llm=ChatAnthropic(model='claude-sonnet-4-6'),
- browser=browser,
- )
- await agent.run()
-
-if __name__ == "__main__":
- asyncio.run(main())
-```
-
-**4. [Optional] Try the experimental Rust core:**
-```python
-from browser_use import ChatBrowserUse
-from browser_use.rust import Agent
+from browser_use.beta import Agent, BrowserProfile, ChatBrowserUse
+# from browser_use.beta import ChatOpenAI # ChatOpenAI(model='gpt-5.5')
+# from browser_use.beta import ChatGoogle # ChatGoogle(model='gemini-3.1-pro-preview')
+# from browser_use.beta import ChatAnthropic # ChatAnthropic(model='claude-opus-4-8')
import asyncio
async def main():
agent = Agent(
task="Find the number of stars of the browser-use repo",
llm=ChatBrowserUse(),
+ # llm=ChatOpenAI(model='gpt-5.5'),
+ # llm=ChatGoogle(model='gemini-3.1-pro-preview'),
+ # llm=ChatAnthropic(model='claude-opus-4-8'), # Sonnet also works well.
+ browser_profile=BrowserProfile(
+ headless=False,
+ allowed_domains=["*.github.com"],
+ ),
)
history = await agent.run()
print(history.final_result())
@@ -112,6 +98,8 @@ if __name__ == "__main__":
asyncio.run(main())
```
+Existing Python agent users can keep using `from browser_use import Agent`. The new Rust-powered beta agent is `from browser_use.beta import Agent`.
+
Check out the [library docs](https://docs.browser-use.com/open-source/introduction) and the [cloud docs](https://docs.cloud.browser-use.com?utm_source=github&utm_medium=readme-cloud-docs) for more!
<br/>
diff --git a/browser_use/agent/__init__.py b/browser_use/agent/__init__.py
index 0d1e0c4c5..334e583e9 100644
--- a/browser_use/agent/__init__.py
+++ b/browser_use/agent/__init__.py
@@ -6,11 +6,11 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from browser_use.agent.service import Agent
- from browser_use.rust.service import RustAgentError
+ from browser_use.beta.service import BetaAgentError
_LAZY_IMPORTS = {
'Agent': ('browser_use.agent.service', 'Agent'),
- 'RustAgentError': ('browser_use.rust.service', 'RustAgentError'),
+ 'BetaAgentError': ('browser_use.beta.service', 'BetaAgentError'),
}
@@ -28,5 +28,5 @@ def __getattr__(name: str):
__all__ = [
'Agent',
- 'RustAgentError',
+ 'BetaAgentError',
]
diff --git a/browser_use/beta/__init__.py b/browser_use/beta/__init__.py
new file mode 100644
index 000000000..1a3b32f43
--- /dev/null
+++ b/browser_use/beta/__init__.py
@@ -0,0 +1,72 @@
+"""Beta Browser Use integration."""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING
+
+from browser_use.beta.service import Agent, BetaAgentError, find_browser_use_terminal_binary
+
+if TYPE_CHECKING:
+ from browser_use.browser import BrowserProfile, BrowserSession
+ from browser_use.browser import BrowserSession as Browser
+ from browser_use.llm.anthropic.chat import ChatAnthropic
+ from browser_use.llm.azure.chat import ChatAzureOpenAI
+ from browser_use.llm.browser_use.chat import ChatBrowserUse
+ from browser_use.llm.google.chat import ChatGoogle
+ from browser_use.llm.groq.chat import ChatGroq
+ from browser_use.llm.litellm.chat import ChatLiteLLM
+ from browser_use.llm.mistral.chat import ChatMistral
+ from browser_use.llm.oci_raw.chat import ChatOCIRaw
+ from browser_use.llm.ollama.chat import ChatOllama
+ from browser_use.llm.openai.chat import ChatOpenAI
+ from browser_use.llm.vercel.chat import ChatVercel
+
+_LAZY_IMPORTS = {
+ 'Browser': ('browser_use.browser', 'BrowserSession'),
+ 'BrowserProfile': ('browser_use.browser', 'BrowserProfile'),
+ 'BrowserSession': ('browser_use.browser', 'BrowserSession'),
+ 'ChatOpenAI': ('browser_use.llm.openai.chat', 'ChatOpenAI'),
+ 'ChatGoogle': ('browser_use.llm.google.chat', 'ChatGoogle'),
+ 'ChatAnthropic': ('browser_use.llm.anthropic.chat', 'ChatAnthropic'),
+ 'ChatBrowserUse': ('browser_use.llm.browser_use.chat', 'ChatBrowserUse'),
+ 'ChatGroq': ('browser_use.llm.groq.chat', 'ChatGroq'),
+ 'ChatLiteLLM': ('browser_use.llm.litellm.chat', 'ChatLiteLLM'),
+ 'ChatMistral': ('browser_use.llm.mistral.chat', 'ChatMistral'),
+ 'ChatAzureOpenAI': ('browser_use.llm.azure.chat', 'ChatAzureOpenAI'),
+ 'ChatOCIRaw': ('browser_use.llm.oci_raw.chat', 'ChatOCIRaw'),
+ 'ChatOllama': ('browser_use.llm.ollama.chat', 'ChatOllama'),
+ 'ChatVercel': ('browser_use.llm.vercel.chat', 'ChatVercel'),
+}
+
+
+def __getattr__(name: str):
+ if name in _LAZY_IMPORTS:
+ module_path, attr_name = _LAZY_IMPORTS[name]
+ from importlib import import_module
+
+ module = import_module(module_path)
+ attr = getattr(module, attr_name)
+ globals()[name] = attr
+ return attr
+ raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
+
+
+__all__ = [
+ 'Agent',
+ 'BetaAgentError',
+ 'Browser',
+ 'BrowserProfile',
+ 'BrowserSession',
+ 'ChatAnthropic',
+ 'ChatAzureOpenAI',
+ 'ChatBrowserUse',
+ 'ChatGoogle',
+ 'ChatGroq',
+ 'ChatLiteLLM',
+ 'ChatMistral',
+ 'ChatOCIRaw',
+ 'ChatOllama',
+ 'ChatOpenAI',
+ 'ChatVercel',
+ 'find_browser_use_terminal_binary',
+]
diff --git a/browser_use/rust/service.py b/browser_use/beta/service.py
similarity index 99%
rename from browser_use/rust/service.py
rename to browser_use/beta/service.py
index 61752beea..e6865091a 100644
--- a/browser_use/rust/service.py
+++ b/browser_use/beta/service.py
@@ -94,8 +94,8 @@ except ImportError:
Laminar = None # type: ignore
-class RustAgentError(RuntimeError):
- """Raised when the Rust terminal core cannot run a task."""
+class BetaAgentError(RuntimeError):
+ """Raised when the beta agent cannot run a task."""
def _laminar_ready() -> bool:
@@ -203,7 +203,7 @@ def find_browser_use_terminal_binary() -> str:
path_binary = shutil.which('browser-use-terminal')
if path_binary:
return path_binary
- raise RustAgentError(
+ raise BetaAgentError(
f'Could not find browser-use-terminal. Install Browser Use Terminal with `{TERMINAL_INSTALL_COMMAND}`, '
'install browser-use-core, or set BROWSER_USE_TERMINAL_BINARY to a built terminal CLI.'
)
@@ -220,7 +220,7 @@ def _find_packaged_browser_use_terminal_binary() -> str | None:
return None
-class RustSdkJsonRpcError(RustAgentError):
+class RustSdkJsonRpcError(BetaAgentError):
"""Raised when the Rust SDK server returns a JSON-RPC error."""
def __init__(self, code: int, message: str) -> None:
@@ -262,7 +262,7 @@ class RustSdkClient:
)
except (FileNotFoundError, PermissionError) as exc:
command = self.command[0] if self.command else 'browser-use-terminal'
- raise RustAgentError(
+ raise BetaAgentError(
f'Could not start Rust SDK server command {command!r}. '
f'Install Browser Use Terminal with `{TERMINAL_INSTALL_COMMAND}`, '
'or set BROWSER_USE_TERMINAL_BINARY to a built terminal CLI.'
@@ -273,7 +273,7 @@ class RustSdkClient:
async def call(self, method: str, params: dict[str, Any] | None = None) -> Any:
await self.start()
if self.process is None or self.process.stdin is None:
- raise RustAgentError('Rust SDK server stdin is unavailable')
+ raise BetaAgentError('Rust SDK server stdin is unavailable')
loop = asyncio.get_running_loop()
async with self._write_lock:
request_id = self._next_id
@@ -291,7 +291,7 @@ class RustSdkClient:
await self.process.stdin.drain()
except (BrokenPipeError, ConnectionResetError) as exc:
self._pending.pop(request_id, None)
- raise RustAgentError(f'Rust SDK server pipe closed while sending {method}') from exc
+ raise BetaAgentError(f'Rust SDK server pipe closed while sending {method}') from exc
try:
return await future
except asyncio.CancelledError:
@@ -320,7 +320,7 @@ class RustSdkClient:
*(task for task in (self._reader_task, self._stderr_task) if task is not None and task is not asyncio.current_task()),
return_exceptions=True,
)
- self._fail_all(RustAgentError('Rust SDK server closed'))
+ self._fail_all(BetaAgentError('Rust SDK server closed'))
self.process = None
async def _read_stdout(self) -> None:
@@ -344,19 +344,19 @@ class RustSdkClient:
if not self._handle_stdout_line(raw_line):
return
if len(buffer) > self.max_line_bytes:
- self._fail_all(RustAgentError(f'Rust SDK JSON-RPC line exceeded {self.max_line_bytes} bytes without newline'))
+ self._fail_all(BetaAgentError(f'Rust SDK JSON-RPC line exceeded {self.max_line_bytes} bytes without newline'))
return
except Exception as exc:
message = f'Rust SDK stdout reader failed: {exc}'
self.stderr_lines.append(message)
- self._fail_all(RustAgentError(message))
+ self._fail_all(BetaAgentError(message))
finally:
if self._pending:
detail = '\n'.join(self.stderr_lines[-20:])
message = 'Rust SDK server exited before responding'
if detail:
message = f'{message}: {detail}'
- self._fail_all(RustAgentError(message))
+ self._fail_all(BetaAgentError(message))
def _handle_stdout_line(self, raw_line: bytes) -> bool:
line = raw_line.decode('utf-8', errors='replace').strip()
@@ -365,7 +365,7 @@ class RustSdkClient:
try:
message = json.loads(line)
except json.JSONDecodeError as exc:
- self._fail_all(RustAgentError(f'Invalid Rust SDK JSON-RPC line: {line}: {exc}'))
+ self._fail_all(BetaAgentError(f'Invalid Rust SDK JSON-RPC line: {line}: {exc}'))
return False
self._handle_message(message)
return True
@@ -379,7 +379,7 @@ class RustSdkClient:
def _handle_message(self, message: Any) -> None:
if not isinstance(message, dict):
- self._fail_all(RustAgentError(f'Rust SDK server emitted non-object JSON-RPC message: {message!r}'))
+ self._fail_all(BetaAgentError(f'Rust SDK server emitted non-object JSON-RPC message: {message!r}'))
return
method = message.get('method')
if method in {'agent.event', 'agent.projected_event'}:
@@ -395,7 +395,7 @@ class RustSdkClient:
return
request_id = message.get('id')
if not isinstance(request_id, int):
- self._fail_all(RustAgentError('Rust SDK JSON-RPC response id must be an integer'))
+ self._fail_all(BetaAgentError('Rust SDK JSON-RPC response id must be an integer'))
return
future = self._pending.pop(request_id, None)
if future is None or future.done():
@@ -3743,7 +3743,7 @@ def _record_laminar_terminal_tool_spans(events: list[dict[str, Any]], *, max_spa
with _laminar_start_span(f'rust_core.tool.{tool_call.get("name") or "tool"}', input=input_messages, span_type='TOOL'):
_laminar_set_span_attributes(
{
- 'runtime': 'browser_use.rust',
+ 'runtime': 'browser_use.beta',
'tool_name': tool_call.get('name'),
'tool_call_id': tool_call_id,
'tool_index': span_index,
@@ -3798,7 +3798,7 @@ def _record_laminar_terminal_llm_spans(
span_output_messages = _terminal_laminar_span_output_messages(span_output)
_laminar_set_span_attributes(
{
- 'runtime': 'browser_use.rust',
+ 'runtime': 'browser_use.beta',
'model': str(span_input.get('model') or default_model),
'provider': str(span_input.get('provider') or default_provider),
'turn_index': span_index,
@@ -3904,7 +3904,7 @@ def _load_rust_history(file_path: str | Path) -> AgentHistoryList:
with open(file_path, encoding='utf-8') as history_file:
data = json.load(history_file)
if not isinstance(data, dict):
- raise RustAgentError(f'Invalid Browser Use history file: {file_path}')
+ raise BetaAgentError(f'Invalid Browser Use history file: {file_path}')
for item in data.get('history', []):
if isinstance(item, dict):
item['model_output'] = None
@@ -4669,7 +4669,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
model = getattr(self.llm, 'model', None) or self.model
provider = getattr(self.llm, 'provider', None) or 'rust-terminal'
summary = {
- 'runtime': 'browser_use.rust',
+ 'runtime': 'browser_use.beta',
'model': model,
'provider': provider,
'max_steps': max_steps,
@@ -4914,7 +4914,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
started=started,
finished=finished,
output_model_schema=self.output_model_schema,
- process_error='Rust agent stopped before terminal run.',
+ process_error='Beta agent stopped before terminal run.',
)
self.history = self.result
await self._apply_terminal_usage_costs([])
@@ -4922,9 +4922,9 @@ class Agent(Generic[Context, AgentStructuredOutput]):
self._record_laminar_run_observability(
max_steps=max_steps,
duration_seconds=finished - started,
- process_error='Rust agent stopped before terminal run.',
+ process_error='Beta agent stopped before terminal run.',
)
- self._record_run_telemetry(max_steps=max_steps, agent_run_error='Rust agent stopped before terminal run.')
+ self._record_run_telemetry(max_steps=max_steps, agent_run_error='Beta agent stopped before terminal run.')
self._dispatch_run_update_event()
self._log_final_outcome_messages()
await self._finalize_run_cleanup()
@@ -4944,7 +4944,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
started=started,
finished=finished,
output_model_schema=self.output_model_schema,
- process_error='Rust agent stopped before terminal run.',
+ process_error='Beta agent stopped before terminal run.',
)
self.history = self.result
await self._apply_terminal_usage_costs([])
@@ -4952,9 +4952,9 @@ class Agent(Generic[Context, AgentStructuredOutput]):
self._record_laminar_run_observability(
max_steps=max_steps,
duration_seconds=finished - started,
- process_error='Rust agent stopped before terminal run.',
+ process_error='Beta agent stopped before terminal run.',
)
- self._record_run_telemetry(max_steps=max_steps, agent_run_error='Rust agent stopped before terminal run.')
+ self._record_run_telemetry(max_steps=max_steps, agent_run_error='Beta agent stopped before terminal run.')
self._dispatch_run_update_event()
self._log_final_outcome_messages()
await self._finalize_run_cleanup()
@@ -4994,7 +4994,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
enqueue_timeout: int | None = None,
) -> AgentHistoryList[AgentStructuredOutput]:
if not self.terminal_session_id or not self._sdk_agent_id:
- raise RustAgentError('No active Rust session. Call run() before follow_up().')
+ raise BetaAgentError('No active Rust session. Call run() before follow_up().')
resolved_max_steps = max_steps if max_steps is not None else self.kwargs.get('max_steps', 100)
self.add_new_task(task)
self.state.follow_up_task = False
@@ -5913,7 +5913,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
self.logger.debug('Initial actions completed')
async def _execute_direct_initial_navigation_actions(self) -> list[ActionResult] | None:
- """Pre-navigate existing CDP-backed browser sessions before the Rust agent starts."""
+ """Pre-navigate existing CDP-backed browser sessions before the Beta agent starts."""
self._completed_initial_navigation_urls = []
self._completed_initial_navigation_states = []
if not _direct_initial_navigation_enabled():
@@ -6268,13 +6268,13 @@ class Agent(Generic[Context, AgentStructuredOutput]):
except Exception as exc:
await self._sdk_client.close()
self._sdk_client = None
- raise RustAgentError(
+ raise BetaAgentError(
'Failed to negotiate browser-use-terminal SDK protocol via runtime.ping. '
'Install a compatible browser-use-core package or set BROWSER_USE_TERMINAL_BINARY to a compatible binary.'
) from exc
await self._sdk_client.close()
self._sdk_client = None
- raise RustAgentError(
+ raise BetaAgentError(
f'Unsupported browser-use-terminal SDK protocol {protocol_version!r}; expected 1. '
'Install a compatible browser-use-core package or set BROWSER_USE_TERMINAL_BINARY to a compatible binary.'
)
@@ -6450,7 +6450,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
def _conversation_snapshot(self) -> dict[str, Any]:
return {
- 'agent': 'browser_use.rust.Agent',
+ 'agent': 'browser_use.beta.Agent',
'task_id': self.task_id,
'session_id': self.session_id,
'terminal_session_id': self.terminal_session_id,
@@ -6598,12 +6598,12 @@ def _align_browser_use_agent_signatures() -> None:
for name, browser_use_method in vars(_PythonAgent).items():
if name.startswith('__') and name != '__init__':
continue
- rust_method = getattr(Agent, name, None)
- if rust_method is None or not callable(browser_use_method) or not callable(rust_method):
+ beta_method = getattr(Agent, name, None)
+ if beta_method is None or not callable(browser_use_method) or not callable(beta_method):
continue
try:
- rust_method.__signature__ = inspect.signature(browser_use_method)
- rust_method.__annotations__ = dict(getattr(browser_use_method, '__annotations__', {}))
+ beta_method.__signature__ = inspect.signature(browser_use_method)
+ beta_method.__annotations__ = dict(getattr(browser_use_method, '__annotations__', {}))
except (TypeError, ValueError, AttributeError):
continue
try:
@@ -6612,12 +6612,12 @@ def _align_browser_use_agent_signatures() -> None:
pass
agent_hook_func = Callable[[_PythonAgent], Awaitable[None]]
for name in ('run', 'run_sync'):
- rust_method = getattr(Agent, name, None)
- if rust_method is None:
+ beta_method = getattr(Agent, name, None)
+ if beta_method is None:
continue
try:
- rust_method.__annotations__['on_step_start'] = agent_hook_func | None
- rust_method.__annotations__['on_step_end'] = agent_hook_func | None
+ beta_method.__annotations__['on_step_start'] = agent_hook_func | None
+ beta_method.__annotations__['on_step_end'] = agent_hook_func | None
except (TypeError, AttributeError, KeyError):
continue
diff --git a/browser_use/rust/__init__.py b/browser_use/rust/__init__.py
deleted file mode 100644
index 060bbf421..000000000
--- a/browser_use/rust/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-"""Rust-core Browser Use integration."""
-
-from browser_use.rust.service import Agent, RustAgentError, find_browser_use_terminal_binary
-
-__all__ = [
- 'Agent',
- 'RustAgentError',
- 'find_browser_use_terminal_binary',
-]
diff --git a/examples/rust_agent/basic.py b/examples/beta_agent/basic.py
similarity index 55%
rename from examples/rust_agent/basic.py
rename to examples/beta_agent/basic.py
index c5222ed44..e8b087fcb 100644
--- a/examples/rust_agent/basic.py
+++ b/examples/beta_agent/basic.py
@@ -7,8 +7,11 @@ Set BU_CDP_URL or BROWSER_USE_CDP_URL to attach to a remote Browser Use cloud br
import asyncio
import os
-from browser_use import BrowserSession
-from browser_use.rust import Agent
+from browser_use.beta import Agent, BrowserSession, ChatBrowserUse
+
+# from browser_use.beta import ChatOpenAI # ChatOpenAI(model='gpt-5.5')
+# from browser_use.beta import ChatGoogle # ChatGoogle(model='gemini-3.1-pro-preview')
+# from browser_use.beta import ChatAnthropic # ChatAnthropic(model='claude-opus-4-8')
async def main() -> None:
@@ -17,7 +20,14 @@ async def main() -> None:
task = os.environ.get('BU_TASK', 'Open https://example.com and report the page title.')
max_steps = int(os.environ.get('BU_MAX_STEPS', '20'))
- agent = Agent(task=task, browser_session=browser_session)
+ agent = Agent(
+ task=task,
+ llm=ChatBrowserUse(),
+ # llm=ChatOpenAI(model='gpt-5.5'),
+ # llm=ChatGoogle(model='gemini-3.1-pro-preview'),
+ # llm=ChatAnthropic(model='claude-opus-4-8'), # Sonnet also works well.
+ browser_session=browser_session,
+ )
history = await agent.run(max_steps=max_steps)
print(history.final_result() or '(no final result)')
diff --git a/pyproject.toml b/pyproject.toml
index 3da938574..ff4500603 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
name = "browser-use"
description = "Make websites accessible for AI agents"
authors = [{ name = "Gregor Zunic" }]
-version = "0.13.0rc2"
+version = "0.13.0rc3"
readme = "README.md"
requires-python = ">=3.11,<4.0"
classifiers = [
@@ -59,7 +59,7 @@ dependencies = [
[project.optional-dependencies]
cli = ["textual==7.4.0"]
-rust = [
+core = [
"browser-use-core==0.13.0rc2; sys_platform == 'darwin' and platform_machine == 'arm64'",
"browser-use-core==0.13.0rc2; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"browser-use-core==0.13.0rc2; sys_platform == 'linux' and platform_machine == 'x86_64'",
@@ -161,9 +161,9 @@ exclude = [
"browser_use/llm/oci_raw/*",
"browser_use/llm/tests/test_chat_models.py",
"browser_use/llm/tests/test_single_step.py",
- # Dynamic Rust compatibility wrapper; covered by tests/ci/test_rust_agent.py.
- "browser_use/rust/service.py",
- "tests/ci/test_rust_agent.py",
+ # Dynamic beta agent wrapper; covered by tests/ci/test_beta_agent.py.
+ "browser_use/beta/service.py",
+ "tests/ci/test_beta_agent.py",
"product_extraction.py",
"discover/",
"list/",
diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_beta_agent.py
similarity index 88%
rename from tests/ci/test_rust_agent.py
rename to tests/ci/test_beta_agent.py
index cfb3e3941..d6a742335 100644
--- a/tests/ci/test_rust_agent.py
+++ b/tests/ci/test_beta_agent.py
@@ -13,13 +13,13 @@ from pydantic import BaseModel
@pytest.fixture(autouse=True)
-def _disable_rust_agent_latest_version_check(monkeypatch):
- import browser_use.rust.service as rust_service
+def _disable_beta_agent_latest_version_check(monkeypatch):
+ import browser_use.beta.service as beta_service
async def no_latest_version():
return None
- monkeypatch.setattr(rust_service, 'check_latest_browser_use_version', no_latest_version)
+ monkeypatch.setattr(beta_service, 'check_latest_browser_use_version', no_latest_version)
monkeypatch.delenv('DEFAULT_LLM', raising=False)
monkeypatch.setenv('BROWSER_USE_API_KEY', 'test-browser-use-api-key')
@@ -27,75 +27,102 @@ def _disable_rust_agent_latest_version_check(monkeypatch):
def test_top_level_agent_preserves_python_service():
from browser_use import Agent as TopLevelAgent
from browser_use.agent.service import Agent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
assert TopLevelAgent is BrowserUseAgent
- assert TopLevelAgent is not RustAgent
+ assert TopLevelAgent is not BetaAgent
def test_agent_package_export_preserves_python_service():
from browser_use.agent import Agent as AgentPackageAgent
from browser_use.agent.service import Agent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
assert AgentPackageAgent is BrowserUseAgent
- assert AgentPackageAgent is not RustAgent
+ assert AgentPackageAgent is not BetaAgent
def test_agent_service_export_preserves_python_service():
from browser_use.agent.service import Agent as ServiceAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
+
+ assert ServiceAgent is not BetaAgent
+
+
+def test_beta_package_reexports_chat_models_and_browser_config():
+ from browser_use import Browser as TopLevelBrowser
+ from browser_use import BrowserProfile as TopLevelBrowserProfile
+ from browser_use import BrowserSession as TopLevelBrowserSession
+ from browser_use import ChatBrowserUse as TopLevelChatBrowserUse
+ from browser_use.beta import (
+ Browser,
+ BrowserProfile,
+ BrowserSession,
+ ChatAnthropic,
+ ChatBrowserUse,
+ ChatGoogle,
+ ChatOpenAI,
+ )
+ from browser_use.llm.anthropic.chat import ChatAnthropic as LlmChatAnthropic
+ from browser_use.llm.google.chat import ChatGoogle as LlmChatGoogle
+ from browser_use.llm.openai.chat import ChatOpenAI as LlmChatOpenAI
- assert ServiceAgent is not RustAgent
+ assert Browser is TopLevelBrowser
+ assert BrowserProfile is TopLevelBrowserProfile
+ assert BrowserSession is TopLevelBrowserSession
+ assert ChatBrowserUse is TopLevelChatBrowserUse
+ assert ChatGoogle is LlmChatGoogle
+ assert ChatAnthropic is LlmChatAnthropic
+ assert ChatOpenAI is LlmChatOpenAI
-def test_rust_agent_class_metadata_matches_browser_use_service_surface():
+def test_beta_agent_class_metadata_matches_browser_use_service_surface():
from browser_use import Agent as TopLevelAgent
from browser_use.agent.service import Agent as ServiceAgent
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
assert TopLevelAgent is ServiceAgent is BrowserUseAgent
- assert RustAgent is not BrowserUseAgent
- assert RustAgent.__name__ == BrowserUseAgent.__name__ == 'Agent'
- assert RustAgent.__qualname__ == BrowserUseAgent.__qualname__ == 'Agent'
- assert RustAgent.__module__ == BrowserUseAgent.__module__ == 'browser_use.agent.service'
- assert RustAgent.__doc__ == BrowserUseAgent.__doc__
- assert repr(RustAgent) == repr(BrowserUseAgent)
+ assert BetaAgent is not BrowserUseAgent
+ assert BetaAgent.__name__ == BrowserUseAgent.__name__ == 'Agent'
+ assert BetaAgent.__qualname__ == BrowserUseAgent.__qualname__ == 'Agent'
+ assert BetaAgent.__module__ == BrowserUseAgent.__module__ == 'browser_use.agent.service'
+ assert BetaAgent.__doc__ == BrowserUseAgent.__doc__
+ assert repr(BetaAgent) == repr(BrowserUseAgent)
-def test_rust_agent_generic_subscription_matches_browser_use():
+def test_beta_agent_generic_subscription_matches_browser_use():
from browser_use.agent.service import Agent as ServiceAgent
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class Answer(BaseModel):
answer: str
browser_use_alias = BrowserUseAgent[dict, Answer]
- rust_alias = RustAgent[dict, Answer]
+ beta_alias = BetaAgent[dict, Answer]
service_alias = ServiceAgent[dict, Answer]
- assert get_args(rust_alias) == get_args(browser_use_alias) == (dict, Answer)
+ assert get_args(beta_alias) == get_args(browser_use_alias) == (dict, Answer)
assert get_args(service_alias) == (dict, Answer)
- assert get_origin(rust_alias) is RustAgent
+ assert get_origin(beta_alias) is BetaAgent
assert get_origin(service_alias) is BrowserUseAgent
with pytest.raises(TypeError, match='Too few arguments'):
- RustAgent[Answer]
+ BetaAgent[Answer]
-def test_rust_agent_constructor_signature_matches_browser_use_order(tmp_path):
+def test_beta_agent_constructor_signature_matches_browser_use_order(tmp_path):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
browser_use_params = list(inspect.signature(BrowserUseAgent.__init__).parameters)
- rust_params = list(inspect.signature(RustAgent.__init__).parameters)
+ beta_params = list(inspect.signature(BetaAgent.__init__).parameters)
- assert rust_params == browser_use_params
+ assert beta_params == browser_use_params
values = []
- for param in list(inspect.signature(RustAgent.__init__).parameters.values())[1:]:
+ for param in list(inspect.signature(BetaAgent.__init__).parameters.values())[1:]:
if param.name == 'task':
values.append('Check constructor parity.')
elif param.name == 'llm':
@@ -111,36 +138,36 @@ def test_rust_agent_constructor_signature_matches_browser_use_order(tmp_path):
assert param.default is not inspect.Parameter.empty
values.append(param.default)
- agent = RustAgent(*values)
+ agent = BetaAgent(*values)
assert agent.source == 'signature-source'
assert agent.file_system_path == str(tmp_path / 'agent-files')
assert agent.task_id == 'signature-task-id'
-def test_rust_agent_runtime_signatures_match_browser_use_callable_surface():
+def test_beta_agent_runtime_signatures_match_browser_use_callable_surface():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
- assert inspect.signature(RustAgent) == inspect.signature(BrowserUseAgent)
- assert inspect.signature(RustAgent.__init__) == inspect.signature(BrowserUseAgent.__init__)
+ assert inspect.signature(BetaAgent) == inspect.signature(BrowserUseAgent)
+ assert inspect.signature(BetaAgent.__init__) == inspect.signature(BrowserUseAgent.__init__)
browser_use_callables = {
name for name, value in vars(BrowserUseAgent).items() if callable(value) and not name.startswith('__')
}
- rust_callables = {name for name, value in vars(RustAgent).items() if callable(value) and not name.startswith('__')}
+ beta_callables = {name for name, value in vars(BetaAgent).items() if callable(value) and not name.startswith('__')}
- for method_name in sorted(browser_use_callables & rust_callables):
- assert inspect.signature(getattr(RustAgent, method_name)) == inspect.signature(getattr(BrowserUseAgent, method_name))
+ for method_name in sorted(browser_use_callables & beta_callables):
+ assert inspect.signature(getattr(BetaAgent, method_name)) == inspect.signature(getattr(BrowserUseAgent, method_name))
-def test_rust_agent_constructor_type_hints_match_browser_use_core_params():
+def test_beta_agent_constructor_type_hints_match_browser_use_core_params():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
from browser_use.tools.service import Tools
browser_use_hints = get_type_hints(BrowserUseAgent.__init__)
- rust_hints = get_type_hints(RustAgent.__init__)
+ beta_hints = get_type_hints(BetaAgent.__init__)
for name in (
'llm',
@@ -150,7 +177,7 @@ def test_rust_agent_constructor_type_hints_match_browser_use_core_params():
'page_extraction_llm',
'sample_images',
):
- assert rust_hints[name] == browser_use_hints[name]
+ assert beta_hints[name] == browser_use_hints[name]
def assert_tools_context_hint(annotation):
inner = [arg for arg in get_args(annotation) if arg is not type(None)]
@@ -162,48 +189,48 @@ def test_rust_agent_constructor_type_hints_match_browser_use_core_params():
for name in ('tools', 'controller'):
assert_tools_context_hint(browser_use_hints[name])
- assert_tools_context_hint(rust_hints[name])
+ assert_tools_context_hint(beta_hints[name])
- assert 'kwargs' not in rust_hints
- assert 'return' not in rust_hints
+ assert 'kwargs' not in beta_hints
+ assert 'return' not in beta_hints
-def test_rust_agent_run_type_hints_match_browser_use_hooks():
+def test_beta_agent_run_type_hints_match_browser_use_hooks():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
for method_name in ('run', 'run_sync'):
browser_use_hints = get_type_hints(getattr(BrowserUseAgent, method_name))
- rust_hints = get_type_hints(getattr(RustAgent, method_name))
+ beta_hints = get_type_hints(getattr(BetaAgent, method_name))
- assert rust_hints == browser_use_hints
+ assert beta_hints == browser_use_hints
-def test_rust_agent_action_model_helper_type_hints_match_browser_use():
+def test_beta_agent_action_model_helper_type_hints_match_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
for method_name in ('_convert_initial_actions', 'multi_act'):
browser_use_hints = get_type_hints(getattr(BrowserUseAgent, method_name))
- rust_hints = get_type_hints(getattr(RustAgent, method_name))
+ beta_hints = get_type_hints(getattr(BetaAgent, method_name))
- assert rust_hints == browser_use_hints
+ assert beta_hints == browser_use_hints
-def test_rust_agent_browser_state_helper_type_hints_match_browser_use():
+def test_beta_agent_browser_state_helper_type_hints_match_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
for method_name in ('_finalize', '_get_next_action', '_log_step_context', '_make_history_item', '_prepare_context'):
browser_use_hints = get_type_hints(getattr(BrowserUseAgent, method_name))
- rust_hints = get_type_hints(getattr(RustAgent, method_name))
+ beta_hints = get_type_hints(getattr(BetaAgent, method_name))
- assert rust_hints == browser_use_hints
+ assert beta_hints == browser_use_hints
-def test_rust_agent_llm_message_helper_type_hints_match_browser_use():
+def test_beta_agent_llm_message_helper_type_hints_match_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
for method_name in (
'_get_model_output_with_retry',
@@ -212,24 +239,24 @@ def test_rust_agent_llm_message_helper_type_hints_match_browser_use():
'get_model_output',
):
browser_use_hints = get_type_hints(getattr(BrowserUseAgent, method_name))
- rust_hints = get_type_hints(getattr(RustAgent, method_name))
+ beta_hints = get_type_hints(getattr(BetaAgent, method_name))
- assert rust_hints == browser_use_hints
+ assert beta_hints == browser_use_hints
-def test_rust_agent_unannotated_helper_type_hints_match_browser_use():
+def test_beta_agent_unannotated_helper_type_hints_match_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
for method_name in ('_log_action', '_verify_and_setup_llm', 'close', 'load_and_rerun'):
browser_use_hints = get_type_hints(getattr(BrowserUseAgent, method_name))
- rust_hints = get_type_hints(getattr(RustAgent, method_name))
+ beta_hints = get_type_hints(getattr(BetaAgent, method_name))
- assert rust_hints == browser_use_hints
+ assert beta_hints == browser_use_hints
def test_rust_events_reconstruct_browser_use_history():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
events = [
{
@@ -266,7 +293,7 @@ def test_rust_events_reconstruct_browser_use_history():
def test_rust_history_ignores_internal_browser_connection_url():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -301,7 +328,7 @@ def test_rust_history_ignores_internal_browser_connection_url():
def test_rust_history_reconstructs_terminal_browser_script_urls():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
output_history = _history_from_events(
[
@@ -362,7 +389,7 @@ def test_rust_history_reconstructs_terminal_browser_script_urls():
def test_rust_history_reconstructs_terminal_browser_live_url():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -390,7 +417,7 @@ def test_rust_history_reconstructs_terminal_browser_live_url():
def test_rust_history_reconstructs_terminal_screenshot_paths(tmp_path):
import base64
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
screenshot_path = tmp_path / 'terminal-shot.png'
screenshot_bytes = b'\x89PNG\r\n\x1a\nterminal-shot'
@@ -428,7 +455,7 @@ def test_rust_history_reconstructs_terminal_screenshot_paths(tmp_path):
def test_rust_history_attaches_terminal_tool_images_to_actions(tmp_path):
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
screenshot_path = tmp_path / 'tool-image.png'
screenshot_path.write_bytes(b'\x89PNG\r\n\x1a\nterminal-image')
@@ -479,7 +506,7 @@ def test_rust_history_attaches_terminal_tool_images_to_actions(tmp_path):
def test_rust_history_compacts_large_terminal_tool_memory():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
large_output = 'large browser output\n' + ('row,value\n' * 200)
@@ -520,7 +547,7 @@ def test_rust_history_compacts_large_terminal_tool_memory():
def test_rust_history_reconstructs_terminal_tool_call_actions():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -571,7 +598,7 @@ def test_rust_history_reconstructs_terminal_tool_call_actions():
def test_rust_history_reconstructs_eval_visible_multi_turn_actions_and_usage():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -653,7 +680,7 @@ def test_rust_history_reconstructs_eval_visible_multi_turn_actions_and_usage():
def test_rust_history_reconstructs_terminal_model_tool_call_actions():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -711,7 +738,7 @@ def test_rust_history_reconstructs_terminal_model_tool_call_actions():
def test_rust_history_reconstructs_terminal_response_input_item_tool_results():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -758,7 +785,7 @@ def test_rust_history_reconstructs_terminal_response_input_item_tool_results():
def test_rust_history_reconstructs_terminal_tool_finished_results():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -821,7 +848,7 @@ def test_rust_history_reconstructs_terminal_tool_finished_results():
def test_rust_history_reconstructs_terminal_tool_output_deltas():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -878,7 +905,7 @@ def test_rust_history_reconstructs_terminal_tool_output_deltas():
def test_rust_history_reconstructs_terminal_exec_command_output_deltas():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -941,7 +968,7 @@ def test_rust_history_reconstructs_terminal_exec_command_output_deltas():
def test_rust_history_reconstructs_terminal_exec_command_end_output():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -985,7 +1012,7 @@ def test_rust_history_reconstructs_terminal_exec_command_end_output():
def test_rust_history_surfaces_terminal_exec_command_end_failure():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1032,7 +1059,7 @@ def test_rust_history_surfaces_terminal_exec_command_end_failure():
def test_rust_history_reconstructs_terminal_command_waiting_result():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1085,7 +1112,7 @@ def test_rust_history_reconstructs_terminal_command_waiting_result():
def test_rust_history_reconstructs_terminal_unkeyed_tool_results():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1140,7 +1167,7 @@ def test_rust_history_reconstructs_terminal_unkeyed_tool_results():
def test_rust_history_reconstructs_terminal_structured_tool_output_results():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1193,7 +1220,7 @@ def test_rust_history_reconstructs_terminal_structured_tool_output_results():
def test_rust_history_synthesizes_done_action_from_terminal_completion():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1232,7 +1259,7 @@ def test_rust_history_synthesizes_done_action_from_terminal_completion():
def test_rust_history_reconstructs_terminal_model_turn_steps():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
events = [
{'type': 'session.created', 'ts_ms': 1_000, 'payload': {}},
@@ -1299,7 +1326,7 @@ def test_rust_history_reconstructs_terminal_model_turn_steps():
def test_rust_history_prefers_done_tool_text_over_session_summary():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1337,7 +1364,7 @@ def test_rust_history_prefers_done_tool_text_over_session_summary():
def test_rust_history_applies_terminal_session_rollback():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1416,7 +1443,7 @@ def test_rust_history_applies_terminal_session_rollback():
def test_rust_history_applies_terminal_session_compaction_boundary():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1484,7 +1511,7 @@ def test_rust_history_applies_terminal_session_compaction_boundary():
def test_rust_history_reconstructs_terminal_streamed_model_thoughts():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1526,7 +1553,7 @@ def test_rust_history_reconstructs_terminal_streamed_model_thoughts():
def test_rust_history_reconstructs_terminal_response_item_model_text():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1578,7 +1605,7 @@ def test_rust_history_reconstructs_terminal_response_item_model_text():
def test_rust_history_reconstructs_terminal_response_item_reasoning():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1643,7 +1670,7 @@ def test_rust_history_reconstructs_terminal_response_item_reasoning():
def test_rust_history_reconstructs_terminal_token_count_usage():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1686,7 +1713,7 @@ def test_rust_history_reconstructs_terminal_token_count_usage():
def test_rust_history_sums_token_count_last_usage_when_latest_total_underreports():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1748,7 +1775,7 @@ def test_rust_history_sums_token_count_last_usage_when_latest_total_underreports
def test_rust_history_reconstructs_terminal_reasoning_token_usage():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1793,7 +1820,7 @@ def test_rust_history_reconstructs_terminal_reasoning_token_usage():
def test_rust_history_reconstructs_terminal_nested_model_usage():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1830,7 +1857,7 @@ def test_rust_history_reconstructs_terminal_nested_model_usage():
def test_rust_history_token_count_does_not_shrink_model_usage_totals():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -1882,7 +1909,7 @@ def test_rust_history_token_count_does_not_shrink_model_usage_totals():
async def test_rust_terminal_usage_prices_token_count_events(monkeypatch):
- from browser_use.rust.service import _usage_from_events_with_costs
+ from browser_use.beta.service import _usage_from_events_with_costs
from browser_use.tokens.service import TokenCost
async def fail_fetch(_self):
@@ -1948,7 +1975,7 @@ async def test_rust_terminal_usage_prices_token_count_events(monkeypatch):
async def test_rust_terminal_usage_prices_anthropic_raw_cache_reads(monkeypatch):
- from browser_use.rust.service import _usage_from_events_with_costs
+ from browser_use.beta.service import _usage_from_events_with_costs
from browser_use.tokens.service import TokenCost
async def fail_fetch(_self):
@@ -1987,7 +2014,7 @@ async def test_rust_terminal_usage_prices_anthropic_raw_cache_reads(monkeypatch)
async def test_rust_terminal_usage_sums_token_count_cache_creation(monkeypatch):
- from browser_use.rust.service import _usage_from_events_with_costs
+ from browser_use.beta.service import _usage_from_events_with_costs
from browser_use.tokens.service import TokenCost
async def fail_fetch(_self):
@@ -2074,7 +2101,7 @@ async def test_rust_terminal_usage_sums_token_count_cache_creation(monkeypatch):
async def test_rust_terminal_usage_priced_summary_sums_cache_read_tokens(monkeypatch):
- from browser_use.rust.service import _usage_from_events_with_costs
+ from browser_use.beta.service import _usage_from_events_with_costs
from browser_use.tokens.service import TokenCost
async def fail_fetch(_self):
@@ -2144,7 +2171,7 @@ async def test_rust_terminal_usage_priced_summary_sums_cache_read_tokens(monkeyp
def test_rust_terminal_usage_mixed_events_do_not_shrink_totals():
- from browser_use.rust.service import _usage_from_events
+ from browser_use.beta.service import _usage_from_events
summary = _usage_from_events(
[
@@ -2185,7 +2212,7 @@ def test_rust_terminal_usage_mixed_events_do_not_shrink_totals():
def test_rust_sdk_event_dedupe_removes_projected_usage_duplicates():
- from browser_use.rust.service import _dedupe_sdk_events, _usage_from_events
+ from browser_use.beta.service import _dedupe_sdk_events, _usage_from_events
usage_payload = {
'info': {
@@ -2227,7 +2254,7 @@ def test_rust_sdk_event_dedupe_removes_projected_usage_duplicates():
async def test_rust_terminal_priced_usage_prefers_model_usage_over_token_count(monkeypatch):
- from browser_use.rust.service import _usage_from_events_with_costs
+ from browser_use.beta.service import _usage_from_events_with_costs
from browser_use.tokens.service import TokenCost
async def fail_fetch(_self):
@@ -2319,7 +2346,7 @@ async def test_rust_token_summary_does_not_double_count_cache_reads(monkeypatch)
def test_rust_history_supports_structured_output():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
class Answer(BaseModel):
answer: str
@@ -2338,7 +2365,7 @@ def test_rust_history_supports_structured_output():
def test_rust_history_extracts_fenced_structured_output():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
class Answer(BaseModel):
answer: str
@@ -2358,7 +2385,7 @@ def test_rust_history_extracts_fenced_structured_output():
def test_rust_history_reconstructs_terminal_agent_completed_result():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -2405,7 +2432,7 @@ def test_rust_history_reconstructs_terminal_agent_completed_result():
def test_rust_history_exposes_result_file_attachments():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -2431,7 +2458,7 @@ def test_rust_history_exposes_result_file_attachments():
def test_rust_history_reconstructs_terminal_artifact_attachments():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -2494,7 +2521,7 @@ def test_rust_history_reconstructs_terminal_artifact_attachments():
def test_rust_history_reconstructs_terminal_capture_curation_gif_attachment():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -2534,7 +2561,7 @@ def test_rust_history_reconstructs_terminal_capture_curation_gif_attachment():
def test_rust_history_reconstructs_terminal_text_artifact_attachments():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -2580,8 +2607,8 @@ def test_rust_history_reconstructs_terminal_text_artifact_attachments():
}
-def test_rust_agent_translates_browser_use_args_to_terminal(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_use_args_to_terminal(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -2618,15 +2645,15 @@ def test_rust_agent_translates_browser_use_args_to_terminal(monkeypatch):
def test_rust_terminal_binary_missing_error_mentions_install(monkeypatch):
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
monkeypatch.delenv('BROWSER_USE_TERMINAL_BINARY', raising=False)
monkeypatch.setitem(sys.modules, 'browser_use_core', None)
- monkeypatch.setattr(rust_service.Path, 'exists', lambda self: False)
- monkeypatch.setattr(rust_service.shutil, 'which', lambda binary: None)
+ monkeypatch.setattr(beta_service.Path, 'exists', lambda self: False)
+ monkeypatch.setattr(beta_service.shutil, 'which', lambda binary: None)
- with pytest.raises(rust_service.RustAgentError) as exc_info:
- rust_service.find_browser_use_terminal_binary()
+ with pytest.raises(beta_service.BetaAgentError) as exc_info:
+ beta_service.find_browser_use_terminal_binary()
message = str(exc_info.value)
assert 'https://browser-use.com/terminal/install.sh' in message
@@ -2635,7 +2662,7 @@ def test_rust_terminal_binary_missing_error_mentions_install(monkeypatch):
def test_rust_terminal_binary_prefers_packaged_binary(monkeypatch):
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
class PackagedCore:
@staticmethod
@@ -2645,14 +2672,14 @@ def test_rust_terminal_binary_prefers_packaged_binary(monkeypatch):
monkeypatch.delenv('BROWSER_USE_TERMINAL_BINARY', raising=False)
monkeypatch.setitem(sys.modules, 'browser_use_core', PackagedCore)
- monkeypatch.setattr(rust_service.Path, 'exists', lambda self: False)
- monkeypatch.setattr(rust_service.shutil, 'which', lambda binary_name: None)
+ monkeypatch.setattr(beta_service.Path, 'exists', lambda self: False)
+ monkeypatch.setattr(beta_service.shutil, 'which', lambda binary_name: None)
- assert rust_service.find_browser_use_terminal_binary() == '/tmp/packaged-browser-use-terminal'
+ assert beta_service.find_browser_use_terminal_binary() == '/tmp/packaged-browser-use-terminal'
def test_rust_terminal_binary_finds_default_terminal_install(monkeypatch, tmp_path):
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
binary = tmp_path / '.browser-use-terminal' / 'packages' / 'standalone' / 'current' / 'bin' / 'browser-use-terminal'
binary.parent.mkdir(parents=True)
@@ -2663,18 +2690,18 @@ def test_rust_terminal_binary_finds_default_terminal_install(monkeypatch, tmp_pa
monkeypatch.chdir(tmp_path)
monkeypatch.setenv('BUT_HOME', str(tmp_path / '.browser-use-terminal'))
monkeypatch.setenv('BUT_INSTALL_DIR', str(tmp_path / '.local' / 'bin'))
- monkeypatch.setattr(rust_service.shutil, 'which', lambda binary_name: None)
+ monkeypatch.setattr(beta_service.shutil, 'which', lambda binary_name: None)
- assert rust_service.find_browser_use_terminal_binary() == str(binary)
+ assert beta_service.find_browser_use_terminal_binary() == str(binary)
def test_rust_terminal_binary_from_installed_browser_use_core_answers_ping(monkeypatch):
browser_use_core = pytest.importorskip('browser_use_core')
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
monkeypatch.delenv('BROWSER_USE_TERMINAL_BINARY', raising=False)
- binary = rust_service.find_browser_use_terminal_binary()
+ binary = beta_service.find_browser_use_terminal_binary()
assert binary == browser_use_core.binary_path('browser-use-terminal')
proc = subprocess.run(
@@ -2691,11 +2718,11 @@ def test_rust_terminal_binary_from_installed_browser_use_core_answers_ping(monke
async def test_rust_sdk_client_start_wraps_missing_binary_error():
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
- client = rust_service.RustSdkClient(['/definitely/missing-browser-use-terminal'], env={})
+ client = beta_service.RustSdkClient(['/definitely/missing-browser-use-terminal'], env={})
- with pytest.raises(rust_service.RustAgentError) as exc_info:
+ with pytest.raises(beta_service.BetaAgentError) as exc_info:
await client.start()
message = str(exc_info.value)
@@ -2703,8 +2730,8 @@ async def test_rust_sdk_client_start_wraps_missing_binary_error():
assert 'https://browser-use.com/terminal/install.sh' in message
-def test_rust_agent_sdk_params_leave_terminal_tools_unrestricted(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_sdk_params_leave_terminal_tools_unrestricted(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -2718,8 +2745,8 @@ def test_rust_agent_sdk_params_leave_terminal_tools_unrestricted(monkeypatch):
assert 'tool_allowlist' not in json.dumps(params)
-def test_rust_agent_sdk_browser_payload_includes_profile_domains_window_and_proxy(monkeypatch, tmp_path):
- from browser_use.rust import Agent
+def test_beta_agent_sdk_browser_payload_includes_profile_domains_window_and_proxy(monkeypatch, tmp_path):
+ from browser_use.beta import Agent
class BrowserProfile:
cdp_url = 'http://127.0.0.1:9222'
@@ -2743,8 +2770,8 @@ def test_rust_agent_sdk_browser_payload_includes_profile_domains_window_and_prox
assert params['browser']['state_dir'] == str(tmp_path)
-async def test_rust_agent_runs_through_sdk_and_reuses_session_for_followup(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_runs_through_sdk_and_reuses_session_for_followup(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -2813,8 +2840,8 @@ async def test_rust_agent_runs_through_sdk_and_reuses_session_for_followup(monke
assert fake_sdk.calls[1][1]['max_steps'] == 5
-async def test_rust_agent_prices_sdk_child_usage_events_without_overriding_parent_result(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_prices_sdk_child_usage_events_without_overriding_parent_result(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -2872,8 +2899,8 @@ async def test_rust_agent_prices_sdk_child_usage_events_without_overriding_paren
assert history.usage.entry_count == 2
-async def test_rust_agent_recovers_final_result_from_sdk_notifications_after_transport_error(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_recovers_final_result_from_sdk_notifications_after_transport_error(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -2918,8 +2945,8 @@ async def test_rust_agent_recovers_final_result_from_sdk_notifications_after_tra
assert [event['event_type'] for event in agent.last_events] == ['session.input', 'session.done']
-async def test_rust_agent_recovers_nested_sdk_notification_events(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_recovers_nested_sdk_notification_events(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -2977,8 +3004,8 @@ async def test_rust_agent_recovers_nested_sdk_notification_events(monkeypatch):
assert [event['event_type'] for event in agent.last_events] == ['session.input', 'session.done']
-async def test_rust_agent_recovers_projected_sdk_final_events(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_recovers_projected_sdk_final_events(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -3032,8 +3059,8 @@ async def test_rust_agent_recovers_projected_sdk_final_events(monkeypatch):
assert [event['event_type'] for event in agent.last_events] == ['session.input', 'session.done']
-async def test_rust_agent_prefers_notification_final_when_response_history_lacks_result(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_prefers_notification_final_when_response_history_lacks_result(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -3143,8 +3170,8 @@ async def test_rust_agent_prefers_notification_final_when_response_history_lacks
]
-async def test_rust_agent_uses_sdk_history_usage_when_events_do_not_include_usage(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_uses_sdk_history_usage_when_events_do_not_include_usage(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -3190,8 +3217,8 @@ async def test_rust_agent_uses_sdk_history_usage_when_events_do_not_include_usag
assert history.usage.total_tokens == 145
-async def test_rust_agent_preserves_sdk_notification_history_on_cancel(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_preserves_sdk_notification_history_on_cancel(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'fake'
@@ -3237,7 +3264,7 @@ async def test_rust_agent_preserves_sdk_notification_history_on_cancel(monkeypat
async def test_rust_sdk_client_reads_large_json_rpc_lines(monkeypatch):
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
monkeypatch.setenv('BROWSER_USE_SDK_STREAM_LIMIT_BYTES', '4096')
monkeypatch.setenv('BROWSER_USE_SDK_READ_CHUNK_BYTES', '1024')
@@ -3248,7 +3275,7 @@ import sys
sys.stdin.readline()
print(json.dumps({"jsonrpc": "2.0", "id": 1, "result": {"text": "x" * 70000}}), flush=True)
"""
- client = rust_service.RustSdkClient([sys.executable, '-c', script], {'PYTHONUNBUFFERED': '1'})
+ client = beta_service.RustSdkClient([sys.executable, '-c', script], {'PYTHONUNBUFFERED': '1'})
try:
result = await client.call('large.response')
@@ -3259,7 +3286,7 @@ print(json.dumps({"jsonrpc": "2.0", "id": 1, "result": {"text": "x" * 70000}}),
async def test_rust_sdk_client_queues_agent_notifications_before_response():
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
script = r"""
import json
@@ -3286,7 +3313,7 @@ print(json.dumps({
}), flush=True)
print(json.dumps({"jsonrpc": "2.0", "id": 1, "result": {"ok": True}}), flush=True)
"""
- client = rust_service.RustSdkClient([sys.executable, '-c', script], {'PYTHONUNBUFFERED': '1'})
+ client = beta_service.RustSdkClient([sys.executable, '-c', script], {'PYTHONUNBUFFERED': '1'})
try:
result = await client.call('run.with.notifications')
@@ -3299,13 +3326,13 @@ print(json.dumps({"jsonrpc": "2.0", "id": 1, "result": {"ok": True}}), flush=Tru
assert [item['method'] for item in client.notifications] == ['agent.event', 'agent.projected_event']
assert first_notification['params']['event']['kind'] == 'AgentStarted'
assert second_notification['params']['event']['kind'] == 'item_started'
- assert rust_service._sdk_notification_summary(first_notification) == 'AgentStarted task=inspect'
- assert rust_service._sdk_notification_summary(second_notification) == 'projected.item_started name=browser_script'
+ assert beta_service._sdk_notification_summary(first_notification) == 'AgentStarted task=inspect'
+ assert beta_service._sdk_notification_summary(second_notification) == 'projected.item_started name=browser_script'
-async def test_rust_agent_rejects_incompatible_sdk_protocol(monkeypatch):
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
+async def test_beta_agent_rejects_incompatible_sdk_protocol(monkeypatch):
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -3320,15 +3347,15 @@ print(json.dumps({"jsonrpc": "2.0", "id": request["id"], "result": {"ok": True}}
agent = Agent(task='answer', llm=LLM())
monkeypatch.setattr(agent, '_sdk_server_argv', lambda: [sys.executable, '-c', script])
- with pytest.raises(rust_service.RustAgentError) as exc_info:
+ with pytest.raises(beta_service.BetaAgentError) as exc_info:
await agent._ensure_sdk_client()
assert 'Unsupported browser-use-terminal SDK protocol' in str(exc_info.value)
-async def test_rust_agent_clears_sdk_client_when_protocol_ping_fails(monkeypatch):
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
+async def test_beta_agent_clears_sdk_client_when_protocol_ping_fails(monkeypatch):
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -3347,15 +3374,15 @@ print(json.dumps({
agent = Agent(task='answer', llm=LLM())
monkeypatch.setattr(agent, '_sdk_server_argv', lambda: [sys.executable, '-c', script])
- with pytest.raises(rust_service.RustAgentError) as exc_info:
+ with pytest.raises(beta_service.BetaAgentError) as exc_info:
await agent._ensure_sdk_client()
assert 'Failed to negotiate browser-use-terminal SDK protocol via runtime.ping' in str(exc_info.value)
assert agent._sdk_client is None
-def test_rust_agent_bridges_llm_credentials_to_terminal_env(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_bridges_llm_credentials_to_terminal_env(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
def __init__(self, provider, model, api_key=None, base_url=None):
@@ -3438,8 +3465,8 @@ def test_rust_agent_bridges_llm_credentials_to_terminal_env(monkeypatch):
}
-def test_rust_agent_requests_openai_compatible_usage_for_cost_calculation(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_requests_openai_compatible_usage_for_cost_calculation(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
def __init__(self, provider, model):
@@ -3478,8 +3505,8 @@ def test_rust_agent_requests_openai_compatible_usage_for_cost_calculation(monkey
assert 'LLM_BROWSER_OPENAI_COMPAT_INCLUDE_USAGE' not in openai_env
-def test_rust_agent_translates_browser_profile_cdp_url(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_cdp_url(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
cdp_url = 'http://127.0.0.1:9222'
@@ -3493,8 +3520,8 @@ def test_rust_agent_translates_browser_profile_cdp_url(monkeypatch):
assert env['LLM_BROWSER_BROWSER_MODE'] == 'remote-cdp'
-def test_rust_agent_translates_browser_profile_cdp_headers(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_cdp_headers(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
cdp_url = 'http://127.0.0.1:9222'
@@ -3514,8 +3541,8 @@ def test_rust_agent_translates_browser_profile_cdp_headers(monkeypatch):
assert json.loads(env['BU_CDP_HEADERS']) == agent.cdp_headers
-def test_rust_agent_translates_browser_profile_remote_user_agent(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_remote_user_agent(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
cdp_url = 'http://127.0.0.1:9222'
@@ -3531,8 +3558,8 @@ def test_rust_agent_translates_browser_profile_remote_user_agent(monkeypatch):
assert env['BU_BROWSER_USER_AGENT'] == 'BrowserUseRemote/2.0'
-def test_rust_agent_translates_browser_profile_highlights(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_highlights(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
highlight_elements = True
@@ -3562,8 +3589,8 @@ def test_rust_agent_translates_browser_profile_highlights(monkeypatch):
assert dom_env['BROWSER_USE_TERMINAL_AUTO_HIGHLIGHT'] == 'false'
-def test_rust_agent_translates_browser_profile_wait_timings(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_wait_timings(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
minimum_wait_page_load_time = 0.25
@@ -3586,8 +3613,8 @@ def test_rust_agent_translates_browser_profile_wait_timings(monkeypatch):
assert env['BU_BROWSER_WAIT_BETWEEN_ACTIONS_MS'] == '125'
-def test_rust_agent_translates_browser_profile_block_ip_addresses(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_block_ip_addresses(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
block_ip_addresses = True
@@ -3602,8 +3629,8 @@ def test_rust_agent_translates_browser_profile_block_ip_addresses(monkeypatch):
assert env['BU_BROWSER_BLOCK_IP_ADDRESSES'] == 'true'
-def test_rust_agent_translates_browser_profile_headless(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_headless(monkeypatch):
+ from browser_use.beta import Agent
class HeadedProfile:
headless = False
@@ -3624,8 +3651,8 @@ def test_rust_agent_translates_browser_profile_headless(monkeypatch):
assert headless._run_env()['LLM_BROWSER_BROWSER_MODE'] == 'managed-headless'
-def test_rust_agent_browser_mode_env_overrides_profile_headless(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_browser_mode_env_overrides_profile_headless(monkeypatch):
+ from browser_use.beta import Agent
class HeadedProfile:
headless = False
@@ -3639,8 +3666,8 @@ def test_rust_agent_browser_mode_env_overrides_profile_headless(monkeypatch):
assert agent._run_env()['LLM_BROWSER_BROWSER_MODE'] == 'cloud'
-def test_rust_agent_translates_browser_profile_cloud(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_cloud(monkeypatch):
+ from browser_use.beta import Agent
class CloudProfile:
use_cloud = True
@@ -3656,8 +3683,8 @@ def test_rust_agent_translates_browser_profile_cloud(monkeypatch):
assert agent._run_env()['LLM_BROWSER_BROWSER_MODE'] == 'cloud'
-def test_rust_agent_translates_browser_profile_managed_launch_args(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_managed_launch_args(monkeypatch):
+ from browser_use.beta import Agent
class Proxy:
server = 'http://proxy.example:8080'
@@ -3691,8 +3718,8 @@ def test_rust_agent_translates_browser_profile_managed_launch_args(monkeypatch):
assert '--user-agent=BrowserUseTest/1.0' in launch_args
-def test_rust_agent_translates_browser_profile_chromium_sandbox(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_chromium_sandbox(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
headless = True
@@ -3712,8 +3739,8 @@ def test_rust_agent_translates_browser_profile_chromium_sandbox(monkeypatch):
assert '--disable-dev-shm-usage' in launch_args
-def test_rust_agent_translates_browser_profile_window_position(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_window_position(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
headless = False
@@ -3734,8 +3761,8 @@ def test_rust_agent_translates_browser_profile_window_position(monkeypatch):
assert '--window-position=12,24' in json.loads(tuple_agent._run_env()['BU_MANAGED_BROWSER_ARGS'])
-def test_rust_agent_translates_browser_profile_devtools(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_devtools(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
headless = False
@@ -3753,8 +3780,8 @@ def test_rust_agent_translates_browser_profile_devtools(monkeypatch):
assert '--auto-open-devtools-for-tabs' in launch_args
-def test_rust_agent_translates_browser_profile_profile_directory(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_profile_directory(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
headless = False
@@ -3770,8 +3797,8 @@ def test_rust_agent_translates_browser_profile_profile_directory(monkeypatch):
assert '--profile-directory=Profile 7' in launch_args
-def test_rust_agent_translates_browser_profile_permissions(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_permissions(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
permissions = ['clipboardReadWrite', 'notifications', 'clipboardReadWrite']
@@ -3787,8 +3814,8 @@ def test_rust_agent_translates_browser_profile_permissions(monkeypatch):
assert json.loads(env['BU_BROWSER_PERMISSIONS']) == ['clipboardReadWrite', 'notifications']
-def test_rust_agent_translates_browser_profile_downloads(monkeypatch, tmp_path):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_downloads(monkeypatch, tmp_path):
+ from browser_use.beta import Agent
profile_downloads_path = tmp_path / 'downloads'
@@ -3809,8 +3836,8 @@ def test_rust_agent_translates_browser_profile_downloads(monkeypatch, tmp_path):
assert env['BU_BROWSER_DOWNLOADS_PATH'] == str(profile_downloads_path)
-def test_rust_agent_translates_browser_profile_viewport(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_viewport(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
viewport = {'width': 1024, 'height': 768}
@@ -3847,8 +3874,8 @@ def test_rust_agent_translates_browser_profile_viewport(monkeypatch):
assert 'BU_BROWSER_VIEWPORT' not in no_viewport_env
-def test_rust_agent_translates_browser_profile_storage_state(monkeypatch, tmp_path):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_storage_state(monkeypatch, tmp_path):
+ from browser_use.beta import Agent
profile_storage_state_path = tmp_path / 'storage_state.json'
storage_state = {
@@ -3883,8 +3910,8 @@ def test_rust_agent_translates_browser_profile_storage_state(monkeypatch, tmp_pa
assert json.loads(env['BU_BROWSER_STORAGE_STATE']) == storage_state
-def test_rust_agent_translates_browser_profile_user_data_dir(monkeypatch, tmp_path):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_user_data_dir(monkeypatch, tmp_path):
+ from browser_use.beta import Agent
profile_dir = tmp_path / 'browser profile'
@@ -3905,8 +3932,8 @@ def test_rust_agent_translates_browser_profile_user_data_dir(monkeypatch, tmp_pa
assert env['BU_MANAGED_BROWSER_PROFILE'] == str(profile_dir)
-def test_rust_agent_translates_browser_profile_executable_path(monkeypatch, tmp_path):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_executable_path(monkeypatch, tmp_path):
+ from browser_use.beta import Agent
chrome_path = tmp_path / 'custom chrome'
@@ -3934,8 +3961,8 @@ def test_rust_agent_translates_browser_profile_executable_path(monkeypatch, tmp_
assert cloud_env['CHROME_PATH'] == '/usr/bin/existing-chrome'
-def test_rust_agent_translates_browser_profile_env(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_translates_browser_profile_env(monkeypatch):
+ from browser_use.beta import Agent
class BrowserProfile:
headless = True
@@ -3974,8 +4001,8 @@ def test_rust_agent_translates_browser_profile_env(monkeypatch):
assert 'BU_BROWSER_BOOL' not in cloud_env
-def test_rust_agent_adds_browser_profile_domain_constraints():
- from browser_use.rust import Agent
+def test_beta_agent_adds_browser_profile_domain_constraints():
+ from browser_use.beta import Agent
class BrowserProfile:
allowed_domains = ['example.com', '*.browser-use.com']
@@ -3996,8 +4023,8 @@ def test_rust_agent_adds_browser_profile_domain_constraints():
assert '- ads.example.com' in agent.task
-def test_rust_agent_adds_sensitive_data_placeholders_without_values():
- from browser_use.rust import Agent
+def test_beta_agent_adds_sensitive_data_placeholders_without_values():
+ from browser_use.beta import Agent
agent = Agent(
task='Log in to the portal.',
@@ -4019,8 +4046,8 @@ def test_rust_agent_adds_sensitive_data_placeholders_without_values():
assert 'super-secret-password' not in agent.task
-def test_rust_agent_warns_about_sensitive_data_domain_constraints(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_warns_about_sensitive_data_domain_constraints(monkeypatch):
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -4067,10 +4094,10 @@ def test_rust_agent_warns_about_sensitive_data_domain_constraints(monkeypatch):
assert 'uncovered-secret' not in messages
-def test_rust_agent_sensitive_data_warnings_match_browser_use(monkeypatch):
+def test_beta_agent_sensitive_data_warnings_match_browser_use(monkeypatch):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
+ from browser_use.beta import Agent as BetaAgent
from browser_use.browser import BrowserProfile
- from browser_use.rust import Agent as RustAgent
class LLM:
model = 'gpt-test'
@@ -4105,21 +4132,21 @@ def test_rust_agent_sensitive_data_warnings_match_browser_use(monkeypatch):
},
):
browser_use_logger = RecordingLogger()
- rust_logger = RecordingLogger()
+ beta_logger = RecordingLogger()
monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self, logger=browser_use_logger: logger))
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self, logger=rust_logger: logger))
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self, logger=beta_logger: logger))
BrowserUseAgent(task='Use credentials safely.', llm=LLM(), directly_open_url=False, **kwargs)
- RustAgent(task='Use credentials safely.', llm=LLM(), directly_open_url=False, **kwargs)
+ BetaAgent(task='Use credentials safely.', llm=LLM(), directly_open_url=False, **kwargs)
- assert rust_logger.messages == browser_use_logger.messages
- message_text = '\n'.join(message for _level, message in rust_logger.messages)
+ assert beta_logger.messages == browser_use_logger.messages
+ message_text = '\n'.join(message for _level, message in beta_logger.messages)
assert 'unlocked-secret' not in message_text
assert 'uncovered-secret' not in message_text
-def test_rust_agent_mirrors_direct_url_startup():
- from browser_use.rust import Agent
+def test_beta_agent_mirrors_direct_url_startup():
+ from browser_use.beta import Agent
agent = Agent(task='Open example.com and report the title.')
@@ -4131,9 +4158,9 @@ def test_rust_agent_mirrors_direct_url_startup():
assert "First navigate to 'https://example.com'" in agent.task
-def test_rust_agent_logs_direct_url_startup_like_browser_use(monkeypatch):
+def test_beta_agent_logs_direct_url_startup_like_browser_use(monkeypatch):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
model = 'gpt-test'
@@ -4159,23 +4186,23 @@ def test_rust_agent_logs_direct_url_startup_like_browser_use(monkeypatch):
pass
browser_use_logger = RecordingLogger()
- rust_logger = RecordingLogger()
+ beta_logger = RecordingLogger()
monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self: browser_use_logger))
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self: rust_logger))
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self: beta_logger))
BrowserUseAgent(task='Open example.com and report the title.', llm=LLM())
- RustAgent(task='Open example.com and report the title.', llm=LLM())
+ BetaAgent(task='Open example.com and report the title.', llm=LLM())
BrowserUseAgent(task='Use https://XXX.XX only as an example price placeholder.', llm=LLM())
- RustAgent(task='Use https://XXX.XX only as an example price placeholder.', llm=LLM())
+ BetaAgent(task='Use https://XXX.XX only as an example price placeholder.', llm=LLM())
expected = ['🔗 Found URL in task: https://example.com, adding as initial action...']
assert browser_use_logger.infos == expected
- assert rust_logger.infos == expected
+ assert beta_logger.infos == expected
-def test_rust_agent_exposes_task_helper_methods():
+def test_beta_agent_exposes_task_helper_methods():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class Answer(BaseModel):
answer: str
@@ -4205,9 +4232,9 @@ def test_rust_agent_exposes_task_helper_methods():
assert browser_use_agent._extract_start_url(numbered_task) == 'https://elibrary.ferc.gov/eLibrary/search'
-def test_rust_agent_exposes_url_text_helper_methods():
+def test_beta_agent_exposes_url_text_helper_methods():
+ from browser_use.beta import Agent
from browser_use.llm.messages import ContentPartTextParam, UserMessage
- from browser_use.rust import Agent
class Nested(BaseModel):
url: str
@@ -4248,8 +4275,8 @@ def test_rust_agent_exposes_url_text_helper_methods():
assert model.pair == (original_url, 'untouched')
-def test_rust_agent_preserves_ordered_initial_actions_context():
- from browser_use.rust import Agent
+def test_beta_agent_preserves_ordered_initial_actions_context():
+ from browser_use.beta import Agent
agent = Agent(
task='Report what is visible after setup.',
@@ -4275,8 +4302,8 @@ def test_rust_agent_preserves_ordered_initial_actions_context():
assert 'Then complete the task.' in agent.task
-def test_rust_agent_skips_ambiguous_or_excluded_direct_urls():
- from browser_use.rust import Agent
+def test_beta_agent_skips_ambiguous_or_excluded_direct_urls():
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -4291,8 +4318,8 @@ def test_rust_agent_skips_ambiguous_or_excluded_direct_urls():
assert 'First navigate to' not in document.task
-def test_rust_agent_exposes_browser_use_settings():
- from browser_use.rust import Agent
+def test_beta_agent_exposes_browser_use_settings():
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -4319,8 +4346,8 @@ def test_rust_agent_exposes_browser_use_settings():
assert agent.include_recent_events is True
-def test_rust_agent_defaults_page_extraction_llm_to_main_llm():
- from browser_use.rust import Agent
+def test_beta_agent_defaults_page_extraction_llm_to_main_llm():
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -4352,22 +4379,22 @@ def test_rust_agent_defaults_page_extraction_llm_to_main_llm():
assert str(id(extraction_llm)) in override_agent.token_cost_service.registered_llms
-def test_rust_agent_default_llm_matches_browser_use_default(monkeypatch):
+def test_beta_agent_default_llm_matches_browser_use_default(monkeypatch):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
monkeypatch.setenv('ANTHROPIC_API_KEY', 'test-anthropic-key')
browser_use_agent = BrowserUseAgent(task='Use the default model.', directly_open_url=False)
- rust_agent = RustAgent(task='Use the default model.', directly_open_url=False)
+ beta_agent = BetaAgent(task='Use the default model.', directly_open_url=False)
assert browser_use_agent.llm.provider == 'browser-use'
- assert rust_agent.llm.provider == browser_use_agent.llm.provider
- assert rust_agent.model == browser_use_agent.llm.model
+ assert beta_agent.llm.provider == browser_use_agent.llm.provider
+ assert beta_agent.model == browser_use_agent.llm.model
-def test_rust_agent_default_llm_respects_default_llm_env(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_default_llm_respects_default_llm_env(monkeypatch):
+ from browser_use.beta import Agent
monkeypatch.setenv('OPENAI_API_KEY', 'test-openai-key')
monkeypatch.setenv('DEFAULT_LLM', 'openai_gpt_4_1_mini')
@@ -4378,8 +4405,8 @@ def test_rust_agent_default_llm_respects_default_llm_env(monkeypatch):
assert agent.llm.model == 'gpt-4.1-mini'
-def test_rust_agent_explicit_llm_ignores_default_llm_env(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_explicit_llm_ignores_default_llm_env(monkeypatch):
+ from browser_use.beta import Agent
monkeypatch.setenv('DEFAULT_LLM', 'openai_gpt_4_1_mini')
@@ -4393,9 +4420,9 @@ def test_rust_agent_explicit_llm_ignores_default_llm_env(monkeypatch):
assert agent.llm.model == 'gpt-test'
-def test_rust_agent_enables_flash_mode_for_browser_use_llm_provider():
+def test_beta_agent_enables_flash_mode_for_browser_use_llm_provider():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class BrowserUseLLM:
model = 'browser-use-test'
@@ -4413,18 +4440,18 @@ def test_rust_agent_enables_flash_mode_for_browser_use_llm_provider():
browser_use_llm = BrowserUseLLM()
browser_use_agent = BrowserUseAgent(task='Use Browser Use model.', llm=browser_use_llm, directly_open_url=False)
- rust_browser_use_agent = RustAgent(task='Use Browser Use model.', llm=browser_use_llm, directly_open_url=False)
- rust_other_agent = RustAgent(task='Use another model.', llm=OtherLLM(), directly_open_url=False)
+ beta_browser_use_agent = BetaAgent(task='Use Browser Use model.', llm=browser_use_llm, directly_open_url=False)
+ beta_other_agent = BetaAgent(task='Use another model.', llm=OtherLLM(), directly_open_url=False)
assert browser_use_agent.settings.flash_mode is True
- assert rust_browser_use_agent.settings.flash_mode is True
- assert rust_other_agent.settings.flash_mode is False
- assert rust_browser_use_agent.AgentOutput.__name__ == browser_use_agent.AgentOutput.__name__
+ assert beta_browser_use_agent.settings.flash_mode is True
+ assert beta_other_agent.settings.flash_mode is False
+ assert beta_browser_use_agent.AgentOutput.__name__ == browser_use_agent.AgentOutput.__name__
-def test_rust_agent_llm_timeout_defaults_match_browser_use_model_families():
+def test_beta_agent_llm_timeout_defaults_match_browser_use_model_families():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
provider = 'test'
@@ -4437,17 +4464,17 @@ def test_rust_agent_llm_timeout_defaults_match_browser_use_model_families():
for model in ['gpt-test', 'gemini-2.5-pro', 'groq-llama', 'o3-mini', 'claude-sonnet', 'deepseek-chat']:
browser_use_agent = BrowserUseAgent(task='Inspect timeout.', llm=LLM(model), directly_open_url=False)
- rust_agent = RustAgent(task='Inspect timeout.', llm=LLM(model), directly_open_url=False)
+ beta_agent = BetaAgent(task='Inspect timeout.', llm=LLM(model), directly_open_url=False)
- assert rust_agent.settings.llm_timeout == browser_use_agent.settings.llm_timeout
+ assert beta_agent.settings.llm_timeout == browser_use_agent.settings.llm_timeout
- override_agent = RustAgent(task='Override timeout.', llm=LLM('gemini-2.5-pro'), llm_timeout=12)
+ override_agent = BetaAgent(task='Override timeout.', llm=LLM('gemini-2.5-pro'), llm_timeout=12)
assert override_agent.settings.llm_timeout == 12
-def test_rust_agent_forces_vision_for_all_model_families():
- from browser_use.rust import Agent as RustAgent
+def test_beta_agent_forces_vision_for_all_model_families():
+ from browser_use.beta import Agent as BetaAgent
class LLM:
provider = 'test'
@@ -4459,17 +4486,17 @@ def test_rust_agent_forces_vision_for_all_model_families():
return type('Result', (), {'usage': None})()
for model in ['deepseek-chat', 'grok-3', 'grok-code']:
- rust_agent = RustAgent(task='Inspect vision.', llm=LLM(model), directly_open_url=False, use_vision=False)
+ beta_agent = BetaAgent(task='Inspect vision.', llm=LLM(model), directly_open_url=False, use_vision=False)
- assert rust_agent.settings.use_vision is True
+ assert beta_agent.settings.use_vision is True
- normal_agent = RustAgent(task='Inspect vision.', llm=LLM('gpt-test'), directly_open_url=False, use_vision=False)
+ normal_agent = BetaAgent(task='Inspect vision.', llm=LLM('gpt-test'), directly_open_url=False, use_vision=False)
assert normal_agent.settings.use_vision is True
-def test_rust_agent_does_not_warn_when_forcing_vision(monkeypatch):
- from browser_use.rust import Agent as RustAgent
+def test_beta_agent_does_not_warn_when_forcing_vision(monkeypatch):
+ from browser_use.beta import Agent as BetaAgent
class LLM:
provider = 'test'
@@ -4497,19 +4524,19 @@ def test_rust_agent_does_not_warn_when_forcing_vision(monkeypatch):
pass
for model in ['deepseek-chat', 'grok-2']:
- rust_logger = RecordingLogger()
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self, logger=rust_logger: logger))
+ beta_logger = RecordingLogger()
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self, logger=beta_logger: logger))
- RustAgent(task='Inspect vision warning.', llm=LLM(model), directly_open_url=False, use_vision=False)
+ BetaAgent(task='Inspect vision warning.', llm=LLM(model), directly_open_url=False, use_vision=False)
- assert rust_logger.warnings == []
+ assert beta_logger.warnings == []
-def test_rust_agent_constructor_debug_summary_matches_browser_use(monkeypatch):
+def test_beta_agent_constructor_debug_summary_matches_browser_use(monkeypatch):
import browser_use.agent.service as agent_service
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
model = 'gpt-test'
@@ -4526,22 +4553,22 @@ def test_rust_agent_constructor_debug_summary_matches_browser_use(monkeypatch):
self.debugs.append(message)
browser_use_logger = RecordingModuleLogger()
- rust_logger = RecordingModuleLogger()
+ beta_logger = RecordingModuleLogger()
monkeypatch.setattr(agent_service, 'logger', browser_use_logger)
- monkeypatch.setattr(rust_service, 'logger', rust_logger)
+ monkeypatch.setattr(beta_service, 'logger', beta_logger)
BrowserUseAgent(task='Inspect constructor setup.', llm=LLM(), directly_open_url=False)
- RustAgent(task='Inspect constructor setup.', llm=LLM(), directly_open_url=False)
+ BetaAgent(task='Inspect constructor setup.', llm=LLM(), directly_open_url=False)
expected = ' +vision extraction_model=gpt-test +file_system'
assert browser_use_logger.debugs[-1] == expected
- assert rust_logger.debugs[-1] == expected
+ assert beta_logger.debugs[-1] == expected
-def test_rust_agent_state_id_defaults_like_browser_use():
+def test_beta_agent_state_id_defaults_like_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
from browser_use.agent.views import AgentState
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
model = 'gpt-test'
@@ -4552,31 +4579,31 @@ def test_rust_agent_state_id_defaults_like_browser_use():
llm = LLM()
browser_use_task_id = 'browser_use_state'
- rust_task_id = 'rust_state_id'
+ beta_task_id = 'rust_state_id'
browser_use_agent = BrowserUseAgent(
task='Inspect state.',
llm=llm,
task_id=browser_use_task_id,
directly_open_url=False,
)
- rust_agent = RustAgent(task='Inspect state.', llm=llm, task_id=rust_task_id, directly_open_url=False)
+ beta_agent = BetaAgent(task='Inspect state.', llm=llm, task_id=beta_task_id, directly_open_url=False)
assert browser_use_agent.task_id == browser_use_task_id
- assert rust_agent.task_id == rust_task_id
+ assert beta_agent.task_id == beta_task_id
assert browser_use_agent.state.agent_id != browser_use_task_id
- assert rust_agent.state.agent_id != rust_task_id
- assert rust_agent.state.n_steps == browser_use_agent.state.n_steps == 1
+ assert beta_agent.state.agent_id != beta_task_id
+ assert beta_agent.state.n_steps == browser_use_agent.state.n_steps == 1
injected_state = AgentState(agent_id='restored-state-id')
- restored_agent = RustAgent(task='Restore state.', injected_agent_state=injected_state)
+ restored_agent = BetaAgent(task='Restore state.', injected_agent_state=injected_state)
assert restored_agent.state is injected_state
assert restored_agent.state.agent_id == 'restored-state-id'
-def test_rust_agent_eventbus_name_matches_browser_use_suffix_prefix():
+def test_beta_agent_eventbus_name_matches_browser_use_suffix_prefix():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
model = 'gpt-test'
@@ -4586,23 +4613,23 @@ def test_rust_agent_eventbus_name_matches_browser_use_suffix_prefix():
return type('Result', (), {'usage': None})()
browser_use_agent = BrowserUseAgent(task='Inspect event bus.', llm=LLM(), task_id='browseruseabcd', directly_open_url=False)
- rust_agent = RustAgent(task='Inspect event bus.', llm=LLM(), task_id='rustagentwxyz', directly_open_url=False)
+ beta_agent = BetaAgent(task='Inspect event bus.', llm=LLM(), task_id='rustagentwxyz', directly_open_url=False)
assert browser_use_agent.eventbus.name == 'Agent_abcd'
- assert rust_agent.eventbus.name == 'Agent_wxyz'
+ assert beta_agent.eventbus.name == 'Agent_wxyz'
- rust_agent_with_hyphen = RustAgent(task='Inspect event bus.', llm=LLM(), task_id='task-1', directly_open_url=False)
- initial_name = rust_agent_with_hyphen.eventbus.name
- rust_agent_with_hyphen.add_new_task('Follow up.')
+ beta_agent_with_hyphen = BetaAgent(task='Inspect event bus.', llm=LLM(), task_id='task-1', directly_open_url=False)
+ initial_name = beta_agent_with_hyphen.eventbus.name
+ beta_agent_with_hyphen.add_new_task('Follow up.')
assert initial_name == 'Agent_sk_1'
- assert rust_agent_with_hyphen.eventbus.name.startswith(f'{initial_name}_')
- assert rust_agent_with_hyphen.eventbus.name.isidentifier()
+ assert beta_agent_with_hyphen.eventbus.name.startswith(f'{initial_name}_')
+ assert beta_agent_with_hyphen.eventbus.name.isidentifier()
-def test_rust_agent_constructor_aliases_match_browser_use():
+def test_beta_agent_constructor_aliases_match_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
from browser_use.tools.service import Tools
class LLM:
@@ -4622,7 +4649,7 @@ def test_rust_agent_constructor_aliases_match_browser_use():
controller=controller,
directly_open_url=False,
)
- rust_agent = RustAgent(
+ beta_agent = BetaAgent(
task='Resolve aliases.',
llm=LLM(),
tools=tools,
@@ -4631,10 +4658,10 @@ def test_rust_agent_constructor_aliases_match_browser_use():
)
assert browser_use_agent.tools is tools
- assert rust_agent.tools is tools
+ assert beta_agent.tools is tools
expected_error = 'Cannot specify both "browser" and "browser_session" parameters. Use "browser" for the cleaner API.'
- for agent_class in (BrowserUseAgent, RustAgent):
+ for agent_class in (BrowserUseAgent, BetaAgent):
with pytest.raises(ValueError) as exc_info:
agent_class(
task='Conflicting browser aliases.',
@@ -4646,8 +4673,8 @@ def test_rust_agent_constructor_aliases_match_browser_use():
assert str(exc_info.value) == expected_error
-def test_rust_agent_initializes_tools_and_action_models():
- from browser_use.rust import Agent
+def test_beta_agent_initializes_tools_and_action_models():
+ from browser_use.beta import Agent
from browser_use.tools.service import Tools
class Answer(BaseModel):
@@ -4672,16 +4699,16 @@ def test_rust_agent_initializes_tools_and_action_models():
assert 'done' in str(done_schema)
-def test_rust_agent_setup_action_models_signature_matches_browser_use():
+def test_beta_agent_setup_action_models_signature_matches_browser_use():
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
browser_use_signature = inspect.signature(BrowserUseAgent._setup_action_models)
- rust_signature = inspect.signature(RustAgent._setup_action_models)
+ beta_signature = inspect.signature(BetaAgent._setup_action_models)
- assert list(rust_signature.parameters) == list(browser_use_signature.parameters) == ['self']
+ assert list(beta_signature.parameters) == list(browser_use_signature.parameters) == ['self']
- agent = RustAgent(task='Rebuild action models.')
+ agent = BetaAgent(task='Rebuild action models.')
agent.ActionModel = None
agent.DoneActionModel = None
agent.AgentOutput = None
@@ -4695,8 +4722,8 @@ def test_rust_agent_setup_action_models_signature_matches_browser_use():
assert agent.DoneAgentOutput is not None
-async def test_rust_agent_updates_action_models_for_page(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_updates_action_models_for_page(monkeypatch):
+ from browser_use.beta import Agent
agent = Agent(task='Use page-specific tools.')
registry = agent.tools.registry
@@ -4721,8 +4748,8 @@ async def test_rust_agent_updates_action_models_for_page(monkeypatch):
assert agent.DoneAgentOutput is not None
-def test_rust_agent_initializes_runtime_metadata_and_observability(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_initializes_runtime_metadata_and_observability(monkeypatch):
+ from browser_use.beta import Agent
from browser_use.tokens.service import TokenCost
monkeypatch.delenv('BU_USE_CALCULATE_COST', raising=False)
@@ -4760,11 +4787,11 @@ def test_rust_agent_initializes_runtime_metadata_and_observability(monkeypatch):
assert 'BU_USE_CALCULATE_COST' not in default_agent._run_env()
-async def test_rust_agent_logger_name_matches_browser_use(monkeypatch):
- import browser_use.rust.service as rust_service
+async def test_beta_agent_logger_name_matches_browser_use(monkeypatch):
+ import browser_use.beta.service as beta_service
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
+ from browser_use.beta import Agent as BetaAgent
from browser_use.browser import BrowserProfile, BrowserSession
- from browser_use.rust import Agent as RustAgent
class TestEventBus:
def __init__(self, name):
@@ -4773,7 +4800,7 @@ async def test_rust_agent_logger_name_matches_browser_use(monkeypatch):
def stop(self, *args, **kwargs):
return None
- monkeypatch.setattr(rust_service, 'EventBus', TestEventBus)
+ monkeypatch.setattr(beta_service, 'EventBus', TestEventBus)
class LLM:
model = 'gpt-test'
@@ -4800,7 +4827,7 @@ async def test_rust_agent_logger_name_matches_browser_use(monkeypatch):
browser_use_logger_name = browser_use_agent.logger.name
await stop_eventbus(browser_use_agent.eventbus)
- rust_agent = RustAgent(
+ beta_agent = BetaAgent(
task='Inspect logger name.',
llm=LLM(),
browser_session=BrowserSession(browser_profile=BrowserProfile(), id='browser-abcd'),
@@ -4808,17 +4835,17 @@ async def test_rust_agent_logger_name_matches_browser_use(monkeypatch):
directly_open_url=False,
)
- assert rust_agent.logger.name == browser_use_logger_name
- assert rust_agent.logger.name == 'browser_use.Agent🅰 1234 ⇢ 🅑 abcd 🅣 --'
- await stop_eventbus(rust_agent.eventbus)
+ assert beta_agent.logger.name == browser_use_logger_name
+ assert beta_agent.logger.name == 'browser_use.Agent🅰 1234 ⇢ 🅑 abcd 🅣 --'
+ await stop_eventbus(beta_agent.eventbus)
-async def test_rust_agent_exposes_logging_helper_methods(monkeypatch):
+async def test_beta_agent_exposes_logging_helper_methods(monkeypatch):
import time
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
from browser_use.agent.views import ActionResult
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -4854,7 +4881,7 @@ async def test_rust_agent_exposes_logging_helper_methods(monkeypatch):
def capture(self, event):
captured_events.append(event)
- monkeypatch.setattr(rust_service, 'check_latest_browser_use_version', no_latest_version)
+ monkeypatch.setattr(beta_service, 'check_latest_browser_use_version', no_latest_version)
agent = Agent(task='Log helper parity.', llm=LLM(), browser_session=BrowserSession())
agent.telemetry = Telemetry()
@@ -4864,7 +4891,7 @@ async def test_rust_agent_exposes_logging_helper_methods(monkeypatch):
agent._log_next_action_summary(Parsed())
agent._log_step_completion_summary(time.time() - 1, [ActionResult(extracted_content='ok')])
agent._log_action(FakeAction(), 'navigate', 1, 2)
- agent.history = rust_service._history_from_events(
+ agent.history = beta_service._history_from_events(
[
{'event_type': 'browser.state', 'payload': {'url': 'https://example.com', 'title': 'Example'}},
{
@@ -4899,9 +4926,9 @@ async def test_rust_agent_exposes_logging_helper_methods(monkeypatch):
assert captured_events[0].error_message == 'manual-error'
-def test_rust_agent_telemetry_filters_empty_reconstructed_urls():
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
+def test_beta_agent_telemetry_filters_empty_reconstructed_urls():
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -4915,7 +4942,7 @@ def test_rust_agent_telemetry_filters_empty_reconstructed_urls():
agent = Agent(task='Log telemetry URLs.', llm=cast(Any, LLM()), directly_open_url=False)
agent.telemetry = Telemetry()
- agent.history = rust_service._history_from_events(
+ agent.history = beta_service._history_from_events(
[
{'event_type': 'model.turn.request', 'payload': {'model': 'gpt-test'}},
{
@@ -4939,9 +4966,9 @@ def test_rust_agent_telemetry_filters_empty_reconstructed_urls():
assert captured_events[0].urls_visited == ['https://example.com']
-def test_rust_agent_telemetry_records_cloud_cdp_hostname():
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
+def test_beta_agent_telemetry_records_cloud_cdp_hostname():
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -4962,7 +4989,7 @@ def test_rust_agent_telemetry_records_cloud_cdp_hostname():
agent = Agent(task='Log cloud CDP telemetry.', llm=cast(Any, LLM()), browser_session=cast(Any, BrowserSession()))
agent.telemetry = Telemetry()
- agent.history = rust_service._history_from_events(
+ agent.history = beta_service._history_from_events(
[
{'event_type': 'browser.state', 'payload': {'url': 'https://example.com', 'title': 'Example'}},
{'event_type': 'session.done', 'payload': {'result': 'done'}},
@@ -4982,11 +5009,11 @@ def test_rust_agent_telemetry_records_cloud_cdp_hostname():
assert captured_events[0].urls_visited == ['https://example.com']
-async def test_rust_agent_run_metadata_logs_match_browser_use(monkeypatch):
+async def test_beta_agent_run_metadata_logs_match_browser_use(monkeypatch):
import browser_use.agent.service as agent_service
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
model = 'gpt-test'
@@ -5010,11 +5037,11 @@ async def test_rust_agent_run_metadata_logs_match_browser_use(monkeypatch):
return '99.99.99'
browser_use_logger = RecordingLogger()
- rust_logger = RecordingLogger()
+ beta_logger = RecordingLogger()
monkeypatch.setattr(agent_service, 'check_latest_browser_use_version', latest_version)
- monkeypatch.setattr(rust_service, 'check_latest_browser_use_version', latest_version)
+ monkeypatch.setattr(beta_service, 'check_latest_browser_use_version', latest_version)
monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self: browser_use_logger))
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self: rust_logger))
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self: beta_logger))
browser_use_agent = BrowserUseAgent(
task='Log run metadata parity.',
@@ -5022,7 +5049,7 @@ async def test_rust_agent_run_metadata_logs_match_browser_use(monkeypatch):
task_id='runmetadatabu',
directly_open_url=False,
)
- rust_agent = RustAgent(
+ beta_agent = BetaAgent(
task='Log run metadata parity.',
llm=LLM(),
task_id='runmetadatars',
@@ -5030,25 +5057,25 @@ async def test_rust_agent_run_metadata_logs_match_browser_use(monkeypatch):
)
browser_use_logger.infos.clear()
browser_use_logger.debugs.clear()
- rust_logger.infos.clear()
- rust_logger.debugs.clear()
+ beta_logger.infos.clear()
+ beta_logger.debugs.clear()
await browser_use_agent._log_agent_run()
- await rust_agent._log_agent_run()
+ await beta_agent._log_agent_run()
- assert rust_logger.infos == browser_use_logger.infos
- assert rust_logger.debugs == browser_use_logger.debugs
- assert rust_logger.infos[0] == '\033[34m🎯 Task: Log run metadata parity.\033[0m'
- assert rust_logger.debugs[0].startswith('🤖 Browser-Use Library Version')
- assert rust_logger.infos[1].startswith('📦 Newer version available: 99.99.99')
+ assert beta_logger.infos == browser_use_logger.infos
+ assert beta_logger.debugs == browser_use_logger.debugs
+ assert beta_logger.infos[0] == '\033[34m🎯 Task: Log run metadata parity.\033[0m'
+ assert beta_logger.debugs[0].startswith('🤖 Browser-Use Library Version')
+ assert beta_logger.infos[1].startswith('📦 Newer version available: 99.99.99')
-async def test_rust_agent_exposes_step_finalization_helper_methods(tmp_path):
+async def test_beta_agent_exposes_step_finalization_helper_methods(tmp_path):
import base64
import time
from browser_use.agent.views import ActionResult, AgentStepInfo
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class DomState:
selector_map = {}
@@ -5116,11 +5143,11 @@ async def test_rust_agent_exposes_step_finalization_helper_methods(tmp_path):
assert agent.AgentOutput is agent.DoneAgentOutput
-async def test_rust_agent_finalize_logs_step_completion_without_browser_state(monkeypatch, tmp_path):
+async def test_beta_agent_finalize_logs_step_completion_without_browser_state(monkeypatch, tmp_path):
import time
from browser_use.agent.views import ActionResult
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -5154,12 +5181,12 @@ async def test_rust_agent_finalize_logs_step_completion_without_browser_state(mo
assert any('Ran 1 action' in message and 'success=1' in message for message in logger.debugs)
-async def test_rust_agent_finalize_orders_summary_save_before_step_event(monkeypatch, tmp_path):
+async def test_beta_agent_finalize_orders_summary_save_before_step_event(monkeypatch, tmp_path):
import base64
import time
from browser_use.agent.views import ActionResult
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
calls = []
@@ -5209,9 +5236,9 @@ async def test_rust_agent_finalize_orders_summary_save_before_step_event(monkeyp
assert [type(event).__name__ for event in agent.eventbus.dispatched] == ['CreateAgentStepEvent']
-async def test_rust_agent_done_only_guidance_matches_browser_use(monkeypatch):
+async def test_beta_agent_done_only_guidance_matches_browser_use(monkeypatch):
from browser_use.agent.views import AgentStepInfo
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -5244,9 +5271,9 @@ async def test_rust_agent_done_only_guidance_matches_browser_use(monkeypatch):
assert 'set success in "done" to false! E.g. if not all steps are fully completed.' in messages[-1]
-async def test_rust_agent_post_process_logs_browser_use_result_messages(monkeypatch):
+async def test_beta_agent_post_process_logs_browser_use_result_messages(monkeypatch):
from browser_use.agent.views import ActionResult
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -5295,9 +5322,9 @@ async def test_rust_agent_post_process_logs_browser_use_result_messages(monkeypa
assert download_checks == ['after executing actions', 'after executing actions', 'after executing actions']
-async def test_rust_agent_handle_step_error_logs_browser_use_failure_prefix(monkeypatch):
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
+async def test_beta_agent_handle_step_error_logs_browser_use_failure_prefix(monkeypatch):
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -5324,7 +5351,7 @@ async def test_rust_agent_handle_step_error_logs_browser_use_failure_prefix(monk
agent_logger = RecordingLogger()
module_logger = RecordingLogger()
monkeypatch.setattr(Agent, 'logger', property(lambda self: agent_logger))
- monkeypatch.setattr(rust_service, 'logger', module_logger)
+ monkeypatch.setattr(beta_service, 'logger', module_logger)
agent = Agent(task='Handle normal step error.', llm=LLM())
await agent._handle_step_error(ValueError('bad step'))
@@ -5357,9 +5384,9 @@ async def test_rust_agent_handle_step_error_logs_browser_use_failure_prefix(monk
)
-def test_rust_agent_initializes_message_manager_and_followup_state():
+def test_beta_agent_initializes_message_manager_and_followup_state():
from browser_use.agent.message_manager.service import MessageManager
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
agent = Agent(
task='Initial task.',
@@ -5382,9 +5409,9 @@ def test_rust_agent_initializes_message_manager_and_followup_state():
assert agent.eventbus.name.isidentifier()
-def test_rust_agent_initializes_browser_use_session_and_file_system(tmp_path):
+def test_beta_agent_initializes_browser_use_session_and_file_system(tmp_path):
+ from browser_use.beta import Agent
from browser_use.browser import BrowserProfile, BrowserSession
- from browser_use.rust import Agent
file_system_path = tmp_path / 'agent-files'
downloads_path = tmp_path / 'downloads'
@@ -5405,8 +5432,8 @@ def test_rust_agent_initializes_browser_use_session_and_file_system(tmp_path):
assert agent.state.file_system_state is not None
-def test_rust_agent_exposes_setup_helper_methods(tmp_path):
- from browser_use.rust import Agent
+def test_beta_agent_exposes_setup_helper_methods(tmp_path):
+ from browser_use.beta import Agent
from browser_use.screenshots.service import ScreenshotService
class LLM:
@@ -5445,8 +5472,8 @@ def test_rust_agent_exposes_setup_helper_methods(tmp_path):
assert agent.file_system.base_dir == new_file_system_path
-def test_rust_agent_constructor_invokes_llm_verification(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_constructor_invokes_llm_verification(monkeypatch):
+ from browser_use.beta import Agent
class LLM:
model = 'gpt-test'
@@ -5462,8 +5489,8 @@ def test_rust_agent_constructor_invokes_llm_verification(monkeypatch):
assert llm._verified_api_keys is True
-def test_rust_agent_browser_profile_property_tracks_session_profile():
- from browser_use.rust import Agent
+def test_beta_agent_browser_profile_property_tracks_session_profile():
+ from browser_use.beta import Agent
class FirstProfile:
downloads_path = None
@@ -5485,8 +5512,8 @@ def test_rust_agent_browser_profile_property_tracks_session_profile():
assert agent.browser_profile.downloads_path == '/tmp/changed-downloads'
-async def test_rust_agent_tracks_downloaded_files_and_saves_file_system_state(tmp_path):
- from browser_use.rust import Agent
+async def test_beta_agent_tracks_downloaded_files_and_saves_file_system_state(tmp_path):
+ from browser_use.beta import Agent
class BrowserProfile:
downloads_path = tmp_path / 'downloads'
@@ -5515,10 +5542,10 @@ async def test_rust_agent_tracks_downloaded_files_and_saves_file_system_state(tm
assert agent.state.file_system_state.base_dir == str(tmp_path / 'agent-files')
-async def test_rust_agent_initializes_screenshot_service(tmp_path):
+async def test_beta_agent_initializes_screenshot_service(tmp_path):
import base64
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
from browser_use.screenshots.service import ScreenshotService
agent = Agent(task='Capture a screenshot.', file_system_path=str(tmp_path / 'agent-files'))
@@ -5536,8 +5563,8 @@ async def test_rust_agent_initializes_screenshot_service(tmp_path):
assert await agent.screenshot_service.get_screenshot(screenshot_path) == screenshot_b64
-def test_rust_agent_adds_available_files_to_task_context():
- from browser_use.rust import Agent
+def test_beta_agent_adds_available_files_to_task_context():
+ from browser_use.beta import Agent
agent = Agent(
task='Summarize the provided report.',
@@ -5550,9 +5577,9 @@ def test_rust_agent_adds_available_files_to_task_context():
assert '- ' in agent.task and 'notes.md' in agent.task
-def test_rust_agent_default_model_uses_browser_use_default_llm(monkeypatch):
+def test_beta_agent_default_model_uses_browser_use_default_llm(monkeypatch):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
monkeypatch.setenv('BROWSER_USE_RUST_MODEL', 'legacy-codex-default')
@@ -5563,10 +5590,10 @@ def test_rust_agent_default_model_uses_browser_use_default_llm(monkeypatch):
assert agent.model == browser_use_agent.llm.model
-async def test_rust_agent_log_completion_matches_browser_use(monkeypatch):
- import browser_use.rust.service as rust_service
+async def test_beta_agent_log_completion_matches_browser_use(monkeypatch):
+ import browser_use.beta.service as beta_service
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class RecordingLogger:
def __init__(self):
@@ -5593,7 +5620,7 @@ async def test_rust_agent_log_completion_matches_browser_use(monkeypatch):
def make_history(success: bool):
events = [{'event_type': 'session.done', 'payload': {'result': 'done'}}] if success else []
- return rust_service._history_from_events(
+ return beta_service._history_from_events(
events,
model='gpt-test',
started=1.0,
@@ -5604,9 +5631,9 @@ async def test_rust_agent_log_completion_matches_browser_use(monkeypatch):
for index, success in enumerate((True, False)):
browser_use_logger = RecordingLogger()
- rust_logger = RecordingLogger()
+ beta_logger = RecordingLogger()
monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self, logger=browser_use_logger: logger))
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self, logger=rust_logger: logger))
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self, logger=beta_logger: logger))
browser_use_agent = BrowserUseAgent(
task='Log completion parity.',
@@ -5614,23 +5641,23 @@ async def test_rust_agent_log_completion_matches_browser_use(monkeypatch):
task_id=f'browsercompletionbu{index}',
directly_open_url=False,
)
- rust_agent = RustAgent(
+ beta_agent = BetaAgent(
task='Log completion parity.',
llm=LLM(),
task_id=f'rustcompletionrs{index}',
directly_open_url=False,
)
browser_use_agent.history = make_history(success)
- rust_agent.history = make_history(success)
+ beta_agent.history = make_history(success)
await browser_use_agent.log_completion()
- await rust_agent.log_completion()
+ await beta_agent.log_completion()
- assert rust_logger.infos == browser_use_logger.infos
+ assert beta_logger.infos == browser_use_logger.infos
-def test_rust_agent_run_sync_delegates_to_async_run(monkeypatch):
- from browser_use.rust import Agent
+def test_beta_agent_run_sync_delegates_to_async_run(monkeypatch):
+ from browser_use.beta import Agent
agent = Agent(task='start')
@@ -5644,9 +5671,9 @@ def test_rust_agent_run_sync_delegates_to_async_run(monkeypatch):
assert agent.kwargs['seen_max_steps'] == 7
-def test_rust_agent_lifecycle_state_and_save_history(tmp_path):
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+def test_beta_agent_lifecycle_state_and_save_history(tmp_path):
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='start')
agent.pause()
@@ -5670,8 +5697,8 @@ def test_rust_agent_lifecycle_state_and_save_history(tmp_path):
assert 'saved answer' in history_file.read_text(encoding='utf-8')
-def test_rust_agent_control_methods_match_browser_use_user_feedback(monkeypatch, capsys):
- from browser_use.rust import Agent
+def test_beta_agent_control_methods_match_browser_use_user_feedback(monkeypatch, capsys):
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -5716,9 +5743,9 @@ def test_rust_agent_control_methods_match_browser_use_user_feedback(monkeypatch,
assert logger.infos == ['⏹️ Agent stopping']
-def test_rust_agent_sync_state_counts_terminal_histories_monotonically():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+def test_beta_agent_sync_state_counts_terminal_histories_monotonically():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
def history_from_result(result: str):
return _history_from_events(
@@ -5751,8 +5778,8 @@ def test_rust_agent_sync_state_counts_terminal_histories_monotonically():
assert agent.state.last_result[-1].extracted_content == 'follow-up answer'
-async def test_rust_agent_close_kills_non_keep_alive_browser_session():
- from browser_use.rust import Agent
+async def test_beta_agent_close_kills_non_keep_alive_browser_session():
+ from browser_use.beta import Agent
class BrowserProfile:
keep_alive = False
@@ -5785,8 +5812,8 @@ async def test_rust_agent_close_kills_non_keep_alive_browser_session():
assert keep_alive_session.kill_calls == 0
-async def test_rust_agent_close_logs_cleanup_errors_without_raising(monkeypatch):
- from browser_use.rust import Agent
+async def test_beta_agent_close_logs_cleanup_errors_without_raising(monkeypatch):
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -5813,8 +5840,8 @@ async def test_rust_agent_close_logs_cleanup_errors_without_raising(monkeypatch)
assert logger.errors == ['Error during cleanup: cleanup failed']
-async def test_rust_agent_check_stop_or_pause_matches_browser_use_lifecycle():
- from browser_use.rust import Agent
+async def test_beta_agent_check_stop_or_pause_matches_browser_use_lifecycle():
+ from browser_use.beta import Agent
seen = []
@@ -5839,9 +5866,9 @@ async def test_rust_agent_check_stop_or_pause_matches_browser_use_lifecycle():
assert paused_agent.state.paused is True
-async def test_rust_agent_rerun_history_delegates_to_rust_run():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_rerun_history_delegates_to_rust_run():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='rerun start', max_steps=8)
previous = _history_from_events(
@@ -5874,11 +5901,11 @@ async def test_rust_agent_rerun_history_delegates_to_rust_run():
assert results[0].extracted_content == 'rerun answer'
-async def test_rust_agent_rerun_history_honors_retry_and_skip_controls(monkeypatch):
- import browser_use.rust.service as rust_service
+async def test_beta_agent_rerun_history_honors_retry_and_skip_controls(monkeypatch):
+ import browser_use.beta.service as beta_service
from browser_use.agent.views import ActionResult
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
previous = _history_from_events(
[{'event_type': 'session.done', 'payload': {'result': 'previous answer'}}],
@@ -5901,7 +5928,7 @@ async def test_rust_agent_rerun_history_honors_retry_and_skip_controls(monkeypat
async def fake_sleep(delay):
sleeps.append(delay)
- monkeypatch.setattr(rust_service.asyncio, 'sleep', fake_sleep)
+ monkeypatch.setattr(beta_service.asyncio, 'sleep', fake_sleep)
class ErrorHistory:
def action_results(self):
@@ -5953,9 +5980,9 @@ async def test_rust_agent_rerun_history_honors_retry_and_skip_controls(monkeypat
assert results[-1].error == 'Rerun failed after 1 attempts: still broken'
-async def test_rust_agent_load_and_rerun_loads_saved_rust_history(tmp_path):
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_load_and_rerun_loads_saved_rust_history(tmp_path):
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='rerun saved')
history = _history_from_events(
@@ -5982,9 +6009,9 @@ async def test_rust_agent_load_and_rerun_loads_saved_rust_history(tmp_path):
assert results[0].extracted_content == 'loaded answer'
-async def test_rust_agent_take_step_runs_one_terminal_turn():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_take_step_runs_one_terminal_turn():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='step once')
seen = []
@@ -6009,8 +6036,8 @@ async def test_rust_agent_take_step_runs_one_terminal_turn():
assert is_valid is True
-async def test_rust_agent_take_step_matches_browser_use_non_final_status():
- from browser_use.rust import Agent
+async def test_beta_agent_take_step_matches_browser_use_non_final_status():
+ from browser_use.beta import Agent
agent = Agent(task='step once without finishing')
seen = []
@@ -6035,9 +6062,9 @@ async def test_rust_agent_take_step_matches_browser_use_non_final_status():
assert is_valid is False
-async def test_rust_agent_take_step_executes_initial_actions_on_first_step():
+async def test_beta_agent_take_step_executes_initial_actions_on_first_step():
from browser_use.agent.views import AgentStepInfo
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
agent = Agent(
task='step once after initial action',
@@ -6080,9 +6107,9 @@ async def test_rust_agent_take_step_executes_initial_actions_on_first_step():
assert is_valid is True
-async def test_rust_agent_run_executes_initial_actions_before_sdk():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_run_executes_initial_actions_before_sdk():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(
task='start on example',
@@ -6114,11 +6141,11 @@ async def test_rust_agent_run_executes_initial_actions_before_sdk():
assert history.final_result() == 'done'
-async def test_rust_agent_run_pre_navigates_cdp_session_before_sdk_by_default():
+async def test_beta_agent_run_pre_navigates_cdp_session_before_sdk_by_default():
from types import SimpleNamespace
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
class FakeBrowserSession:
id = 'browser-cdp'
@@ -6169,11 +6196,11 @@ async def test_rust_agent_run_pre_navigates_cdp_session_before_sdk_by_default():
assert "First navigate to 'https://example.com'" not in seen[0]
-async def test_rust_agent_run_keeps_initial_navigation_when_direct_state_mismatches():
+async def test_beta_agent_run_keeps_initial_navigation_when_direct_state_mismatches():
from types import SimpleNamespace
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
class FakeBrowserSession:
id = 'browser-cdp'
@@ -6222,7 +6249,7 @@ async def test_rust_agent_run_keeps_initial_navigation_when_direct_state_mismatc
def test_rust_history_uses_browser_script_lifecycle_outputs_as_result():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -6268,7 +6295,7 @@ def test_rust_history_uses_browser_script_lifecycle_outputs_as_result():
def test_rust_history_uses_printed_browser_script_page_info_as_state():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -6310,8 +6337,8 @@ def test_rust_history_uses_printed_browser_script_page_info_as_state():
assert state.tabs[0].target_id == 'target-1'
-async def test_rust_agent_multi_act_preserves_done_action():
- from browser_use.rust import Agent
+async def test_beta_agent_multi_act_preserves_done_action():
+ from browser_use.beta import Agent
agent = Agent(task='finish manually')
@@ -6324,9 +6351,9 @@ async def test_rust_agent_multi_act_preserves_done_action():
assert results[0].attachments == ['report.txt']
-async def test_rust_agent_multi_act_routes_actions_to_followup():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_multi_act_routes_actions_to_followup():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='act on current page')
agent.terminal_session_id = '12345678-1234-1234-1234-123456789abc'
@@ -6359,9 +6386,9 @@ async def test_rust_agent_multi_act_routes_actions_to_followup():
assert results[0].extracted_content == 'actions applied'
-async def test_rust_agent_multi_act_ignores_later_done_actions():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_multi_act_ignores_later_done_actions():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='act without premature done')
agent.terminal_session_id = '12345678-1234-1234-1234-123456789abc'
@@ -6396,10 +6423,10 @@ async def test_rust_agent_multi_act_ignores_later_done_actions():
assert results[0].extracted_content == 'clicked only'
-async def test_rust_agent_initial_actions_can_pre_navigate_existing_cdp_session(monkeypatch):
+async def test_beta_agent_initial_actions_can_pre_navigate_existing_cdp_session(monkeypatch):
from types import SimpleNamespace
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class FakeBrowserSession:
id = 'browser-cdp'
@@ -6437,10 +6464,10 @@ async def test_rust_agent_initial_actions_can_pre_navigate_existing_cdp_session(
assert agent.history.history[0].model_output.action == agent.initial_actions
-async def test_rust_agent_direct_initial_navigation_defaults_on_for_cdp(monkeypatch):
+async def test_beta_agent_direct_initial_navigation_defaults_on_for_cdp(monkeypatch):
from types import SimpleNamespace
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class FakeBrowserSession:
id = 'browser-cdp'
@@ -6476,10 +6503,10 @@ async def test_rust_agent_direct_initial_navigation_defaults_on_for_cdp(monkeypa
)
-async def test_rust_agent_direct_initial_navigation_can_be_disabled(monkeypatch):
+async def test_beta_agent_direct_initial_navigation_can_be_disabled(monkeypatch):
from types import SimpleNamespace
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class FakeBrowserSession:
id = 'browser-cdp'
@@ -6507,9 +6534,9 @@ async def test_rust_agent_direct_initial_navigation_can_be_disabled(monkeypatch)
assert agent.history.history == []
-async def test_rust_agent_records_initial_actions_in_history(monkeypatch):
+async def test_beta_agent_records_initial_actions_in_history(monkeypatch):
from browser_use.agent.views import ActionResult
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
class RecordingLogger:
def __init__(self):
@@ -6557,12 +6584,12 @@ async def test_rust_agent_records_initial_actions_in_history(monkeypatch):
]
-async def test_rust_agent_exposes_model_output_helper_methods(monkeypatch, tmp_path):
+async def test_beta_agent_exposes_model_output_helper_methods(monkeypatch, tmp_path):
from types import SimpleNamespace
from browser_use.agent.views import ActionResult
+ from browser_use.beta import Agent
from browser_use.llm.messages import UserMessage
- from browser_use.rust import Agent
class RecordingLogger:
def __init__(self):
@@ -6715,10 +6742,10 @@ async def test_rust_agent_exposes_model_output_helper_methods(monkeypatch, tmp_p
]
-async def test_rust_agent_get_model_output_logs_response_like_browser_use(monkeypatch):
+async def test_beta_agent_get_model_output_logs_response_like_browser_use(monkeypatch):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
+ from browser_use.beta import Agent as BetaAgent
from browser_use.llm.messages import UserMessage
- from browser_use.rust import Agent as RustAgent
class RecordingLogger:
def __init__(self):
@@ -6760,31 +6787,31 @@ async def test_rust_agent_get_model_output_logs_response_like_browser_use(monkey
)()
browser_use_logger = RecordingLogger()
- rust_logger = RecordingLogger()
+ beta_logger = RecordingLogger()
monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self: browser_use_logger))
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self: rust_logger))
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self: beta_logger))
browser_use_llm = LLM()
browser_use_agent = BrowserUseAgent(task='Log the model output.', llm=browser_use_llm, directly_open_url=False)
browser_use_llm.agent = browser_use_agent
await browser_use_agent.get_model_output([UserMessage(content='log response')])
- rust_llm = LLM()
- rust_agent = RustAgent(task='Log the model output.', llm=rust_llm, directly_open_url=False)
- rust_llm.agent = rust_agent
- await rust_agent.get_model_output([UserMessage(content='log response')])
+ beta_llm = LLM()
+ beta_agent = BetaAgent(task='Log the model output.', llm=beta_llm, directly_open_url=False)
+ beta_llm.agent = beta_agent
+ await beta_agent.get_model_output([UserMessage(content='log response')])
- assert rust_logger.infos == browser_use_logger.infos
- assert any('Eval: neutral' in message for message in rust_logger.infos)
- assert any('Memory: remember response logging' in message for message in rust_logger.infos)
- assert any('Next goal: finish response logging' in message for message in rust_logger.infos)
+ assert beta_logger.infos == browser_use_logger.infos
+ assert any('Eval: neutral' in message for message in beta_logger.infos)
+ assert any('Memory: remember response logging' in message for message in beta_logger.infos)
+ assert any('Next goal: finish response logging' in message for message in beta_logger.infos)
-async def test_rust_agent_exposes_prepare_context_helper_method(monkeypatch):
+async def test_beta_agent_exposes_prepare_context_helper_method(monkeypatch):
from types import SimpleNamespace
from browser_use.agent.views import AgentStepInfo
- from browser_use.rust import Agent
+ from browser_use.beta import Agent
state_requests = []
browser_state = SimpleNamespace(
@@ -6858,9 +6885,9 @@ async def test_rust_agent_exposes_prepare_context_helper_method(monkeypatch):
assert agent.AgentOutput is agent.DoneAgentOutput
-async def test_rust_agent_trace_and_cloud_auth_helpers():
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+async def test_beta_agent_trace_and_cloud_auth_helpers():
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
agent = Agent(task='Open example.com', llm=type('LLM', (), {'model': 'gpt-test'})(), task_id='task-1')
agent.history = _history_from_events(
@@ -6887,9 +6914,9 @@ async def test_rust_agent_trace_and_cloud_auth_helpers():
assert 'trace answer' in trace_object['trace_details']['complete_history']
-async def test_rust_agent_run_exposes_laminar_trace_id_for_eval_links(monkeypatch):
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
+async def test_beta_agent_run_exposes_laminar_trace_id_for_eval_links(monkeypatch):
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
class FakeLaminar:
@staticmethod
@@ -6903,8 +6930,8 @@ async def test_rust_agent_run_exposes_laminar_trace_id_for_eval_links(monkeypatc
async def fake_run_terminal(self, max_steps, on_step_start, on_step_end):
return self.history
- monkeypatch.setattr(rust_service, 'Laminar', FakeLaminar)
- monkeypatch.setattr(rust_service.Agent, '_run_terminal', fake_run_terminal)
+ monkeypatch.setattr(beta_service, 'Laminar', FakeLaminar)
+ monkeypatch.setattr(beta_service.Agent, '_run_terminal', fake_run_terminal)
agent = Agent(task='Trace link task.', llm=type('LLM', (), {'model': 'claude-sonnet-4-6'})())
@@ -6914,7 +6941,7 @@ async def test_rust_agent_run_exposes_laminar_trace_id_for_eval_links(monkeypatc
def test_rust_laminar_replay_flush_avoids_context_reset(monkeypatch):
- import browser_use.rust.service as rust_service
+ import browser_use.beta.service as beta_service
class FakeLaminar:
flushes = 0
@@ -6932,18 +6959,18 @@ def test_rust_laminar_replay_flush_avoids_context_reset(monkeypatch):
def force_flush(cls):
cls.force_flushes += 1
- monkeypatch.setattr(rust_service, 'Laminar', FakeLaminar)
+ monkeypatch.setattr(beta_service, 'Laminar', FakeLaminar)
- rust_service._laminar_force_flush()
+ beta_service._laminar_force_flush()
assert FakeLaminar.flushes == 1
assert FakeLaminar.force_flushes == 0
-def test_rust_agent_laminar_run_summary_populates_current_span(monkeypatch):
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+def test_beta_agent_laminar_run_summary_populates_current_span(monkeypatch):
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
class FakeLaminar:
attributes = []
@@ -6995,7 +7022,7 @@ def test_rust_agent_laminar_run_summary_populates_current_span(monkeypatch):
return Span()
- monkeypatch.setattr(rust_service, 'Laminar', FakeLaminar)
+ monkeypatch.setattr(beta_service, 'Laminar', FakeLaminar)
agent = Agent(task='Trace terminal observability.', llm=type('LLM', (), {'model': 'claude-sonnet-4-6'})())
agent.terminal_session_id = 'terminal-session-1'
@@ -7104,7 +7131,7 @@ def test_rust_agent_laminar_run_summary_populates_current_span(monkeypatch):
agent._record_laminar_run_observability(max_steps=7, duration_seconds=3.0)
- assert FakeLaminar.attributes[-1]['runtime'] == 'browser_use.rust'
+ assert FakeLaminar.attributes[-1]['runtime'] == 'browser_use.beta'
assert FakeLaminar.attributes[-1]['terminal_session_id'] == 'terminal-session-1'
assert FakeLaminar.outputs[-1]['final_result_preview'] == 'laminar answer'
assert FakeLaminar.outputs[-1]['steps'] == agent.history.number_of_steps()
@@ -7178,8 +7205,8 @@ def test_rust_agent_laminar_run_summary_populates_current_span(monkeypatch):
assert FakeLaminar.flushes == 2
-def test_rust_agent_laminar_tool_span_preserves_image_only_outputs(tmp_path):
- import browser_use.rust.service as rust_service
+def test_beta_agent_laminar_tool_span_preserves_image_only_outputs(tmp_path):
+ import browser_use.beta.service as beta_service
image_path = tmp_path / 'tool.png'
image_path.write_bytes(b'\x89PNG\r\n\x1a\n')
@@ -7244,21 +7271,21 @@ def test_rust_agent_laminar_tool_span_preserves_image_only_outputs(tmp_path):
return Span()
- original = rust_service.Laminar
+ original = beta_service.Laminar
try:
- rust_service.Laminar = FakeLaminar
- rust_service._record_laminar_terminal_tool_spans(events, max_spans=10)
+ beta_service.Laminar = FakeLaminar
+ beta_service._record_laminar_terminal_tool_spans(events, max_spans=10)
finally:
- rust_service.Laminar = original
+ beta_service.Laminar = original
output = FakeLaminar.spans[0]['outputs'][-1]
assert output[0]['content'] == [{'type': 'image_url', 'image_url': {'url': 'data:image/png;base64,iVBORw0KGgo='}}]
assert FakeLaminar.flushes == 1
-async def test_rust_agent_authenticate_cloud_sync_logs_browser_use_warning(monkeypatch):
+async def test_beta_agent_authenticate_cloud_sync_logs_browser_use_warning(monkeypatch):
from browser_use.agent.service import _PythonAgent as BrowserUseAgent
- from browser_use.rust import Agent as RustAgent
+ from browser_use.beta import Agent as BetaAgent
class LLM:
model = 'gpt-test'
@@ -7284,26 +7311,26 @@ async def test_rust_agent_authenticate_cloud_sync_logs_browser_use_warning(monke
pass
browser_use_logger = RecordingLogger()
- rust_logger = RecordingLogger()
+ beta_logger = RecordingLogger()
monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self: browser_use_logger))
- monkeypatch.setattr(RustAgent, 'logger', property(lambda self: rust_logger))
+ monkeypatch.setattr(BetaAgent, 'logger', property(lambda self: beta_logger))
browser_use_agent = BrowserUseAgent(task='Cloud sync warning parity.', llm=LLM(), directly_open_url=False)
- rust_agent = RustAgent(task='Cloud sync warning parity.', llm=LLM(), directly_open_url=False)
+ beta_agent = BetaAgent(task='Cloud sync warning parity.', llm=LLM(), directly_open_url=False)
assert await browser_use_agent.authenticate_cloud_sync(show_instructions=False) is False
- assert await rust_agent.authenticate_cloud_sync(show_instructions=False) is False
- assert rust_logger.warnings == browser_use_logger.warnings
- assert rust_logger.warnings == ['Cloud sync has been removed and is no longer available']
+ assert await beta_agent.authenticate_cloud_sync(show_instructions=False) is False
+ assert beta_logger.warnings == browser_use_logger.warnings
+ assert beta_logger.warnings == ['Cloud sync has been removed and is no longer available']
-def test_rust_agent_trace_metadata_matches_browser_use_helpers(monkeypatch):
- import browser_use.rust.service as rust_service
- from browser_use.rust import Agent
- from browser_use.rust.service import _history_from_events
+def test_beta_agent_trace_metadata_matches_browser_use_helpers(monkeypatch):
+ import browser_use.beta.service as beta_service
+ from browser_use.beta import Agent
+ from browser_use.beta.service import _history_from_events
- monkeypatch.setattr(rust_service, 'get_browser_use_version', lambda: '9.9.9-test')
- monkeypatch.setattr(rust_service, 'get_git_info', lambda: {'branch': 'trace-branch', 'commit_hash': 'abc123'})
+ monkeypatch.setattr(beta_service, 'get_browser_use_version', lambda: '9.9.9-test')
+ monkeypatch.setattr(beta_service, 'get_git_info', lambda: {'branch': 'trace-branch', 'commit_hash': 'abc123'})
agent = Agent(task='Trace metadata.', llm=type('LLM', (), {'model': 'gpt-test'})())
agent.history = _history_from_events(
@@ -7321,8 +7348,8 @@ def test_rust_agent_trace_metadata_matches_browser_use_helpers(monkeypatch):
assert json.loads(trace['git_info']) == {'branch': 'trace-branch', 'commit_hash': 'abc123'}
-def test_rust_agent_initializes_action_models_without_conversation_path():
- from browser_use.rust import Agent
+def test_beta_agent_initializes_action_models_without_conversation_path():
+ from browser_use.beta import Agent
agent = Agent(
task='Initialize action models without saving conversations.',
@@ -7336,7 +7363,7 @@ def test_rust_agent_initializes_action_models_without_conversation_path():
def test_rust_history_marks_process_failure_not_done():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[],
@@ -7354,7 +7381,7 @@ def test_rust_history_marks_process_failure_not_done():
def test_rust_history_process_failure_ignores_empty_stream_text():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -7375,7 +7402,7 @@ def test_rust_history_process_failure_ignores_empty_stream_text():
def test_rust_history_marks_missing_terminal_result_as_error():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[{'event_type': 'model.turn.request', 'payload': {'model': 'gpt-test'}}],
@@ -7392,7 +7419,7 @@ def test_rust_history_marks_missing_terminal_result_as_error():
def test_rust_history_surfaces_terminal_stream_error_message():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -7412,7 +7439,7 @@ def test_rust_history_surfaces_terminal_stream_error_message():
def test_rust_history_surfaces_terminal_operational_failure_events():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
failed = _history_from_events(
[
@@ -7465,7 +7492,7 @@ def test_rust_history_surfaces_terminal_operational_failure_events():
def test_rust_history_surfaces_terminal_subagent_failure_events():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
failed = _history_from_events(
[
@@ -7522,7 +7549,7 @@ def test_rust_history_surfaces_terminal_subagent_failure_events():
def test_rust_history_surfaces_terminal_tool_failure_message():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -7558,7 +7585,7 @@ def test_rust_history_surfaces_terminal_tool_failure_message():
def test_rust_history_surfaces_running_browser_script_observe_instruction():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -7601,7 +7628,7 @@ def test_rust_history_surfaces_running_browser_script_observe_instruction():
def test_rust_history_surfaces_terminal_cancellation_and_tool_abort_messages():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
cancelled = _history_from_events(
[
@@ -7655,7 +7682,7 @@ def test_rust_history_surfaces_terminal_cancellation_and_tool_abort_messages():
def test_rust_history_preserves_terminal_tool_abort_when_failed_event_follows():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[
@@ -7700,7 +7727,7 @@ def test_rust_history_preserves_terminal_tool_abort_when_failed_event_follows():
def test_rust_history_surfaces_terminal_session_interrupted_message():
- from browser_use.rust.service import _history_from_events
+ from browser_use.beta.service import _history_from_events
history = _history_from_events(
[