Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Match Rust agent runtime signatures
Magnus Müllerfe84f1a5ce62
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex a0f69b46a..68b70dc0e 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -603,10 +603,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- Proof: `browser-use-terminal run-codex-session --help` exposes `<TASK_ID>` and `--model`.- Proof: Python `Agent.run()` followed by `Agent.follow_up()` against the rebuilt current-main terminal binary completed successfully.+119. Rust Agent runtime signature parity+ - The service export now copies Browser Use's original Agent `inspect.signature` metadata onto the Rust-backed replacement for the class constructor and common callable methods.+ - This removes string-annotation drift from the Rust wrapper and keeps docs, runtime introspection, and dependency-injection tooling aligned with the Browser Use Agent interface after the redirect.+ - Proof: `test_rust_agent_runtime_signatures_match_browser_use_callable_surface`.+## Current Verification- `python3 -m py_compile browser_use/agent/service.py browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`-- `uv run pytest -q tests/ci/test_rust_agent.py` (91 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (92 tests)- `cargo build -q -p browser-use-cli` on terminal branch `magnus/browser-use-rust-main-integration`- `cargo test -q -p browser-use-cli run_codex_session_command_accepts_task_id_and_model -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex e65c08a32..4b480d0bb 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -2314,3 +2314,23 @@ class Agent(Generic[Context, AgentStructuredOutput]):_PythonAgent = Agentfrom browser_use.rust.service import Agent as Agent+++def _align_rust_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):+ continue+ try:+ rust_method.__signature__ = inspect.signature(browser_use_method)+ except (TypeError, ValueError, AttributeError):+ continue+ try:+ Agent.__signature__ = inspect.signature(_PythonAgent)+ except (TypeError, ValueError, AttributeError):+ pass+++_align_rust_agent_signatures()diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex ea9b0863b..59c6ae1f5 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -107,6 +107,24 @@ def test_rust_agent_constructor_signature_matches_browser_use_order(tmp_path):assert agent.task_id == 'signature-task-id'+def test_rust_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++ assert inspect.signature(RustAgent) == inspect.signature(BrowserUseAgent)+ assert inspect.signature(RustAgent.__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('__')}++ for method_name in sorted(browser_use_callables & rust_callables):+ assert inspect.signature(getattr(RustAgent, method_name)) == inspect.signature(+ getattr(BrowserUseAgent, method_name)+ )++def test_rust_agent_constructor_type_hints_match_browser_use_core_params():from browser_use.agent.service import _PythonAgent as BrowserUseAgentfrom browser_use.rust import Agent as RustAgent