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
Mirror Rust control method feedback
Magnus Müller45cd74899416
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 2b3528f91..551310b9a 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -1031,10 +1031,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- Trace payloads now include serialized `get_git_info()` metadata, matching Browser Use's trace contract while preserving the existing Rust-backed history and structured-output trace fields.- Proof: `test_rust_agent_trace_metadata_matches_browser_use_helpers`.+204. Rust Agent control-method feedback parity+ - Rust-backed `pause()` and `resume()` now print the same Browser Use user-facing control messages while preserving their pause event-gate behavior.+ - Rust-backed `stop()` now logs Browser Use's stop message before setting the stopped state and unblocking paused runs.+ - Proof: `test_rust_agent_control_methods_match_browser_use_user_feedback`.+## 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` (172 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (173 tests)- `cargo build -q -p browser-use-cli` on terminal branch `magnus/browser-use-rust-main-integration`- `cargo test -q -p browser-use-cli run_codex_session_command_accepts_task_id_and_model -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 263a46726..aa829bf30 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -3967,16 +3967,20 @@ class Agent(Generic[Context, AgentStructuredOutput]):def pause(self) -> None:"""Pause the Rust-backed agent before the next terminal run."""+ print('\n\n⏸️ Paused the agent and left the browser open.\n\tPress [Enter] to resume or [Ctrl+C] again to quit.')self.state.paused = Trueself._external_pause_event.clear()def resume(self) -> None:"""Resume a paused Rust-backed agent."""+ print('----------------------------------------------------------------------')+ print('▶️ Resuming agent execution where it left off...\n')self.state.paused = Falseself._external_pause_event.set()def stop(self) -> None:"""Stop the Rust-backed agent before the next terminal run."""+ self.logger.info('⏹️ Agent stopping')self.state.stopped = Trueself._external_pause_event.set()diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 690ff936c..0e1b2df91 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -5335,6 +5335,52 @@ 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++ class RecordingLogger:+ def __init__(self):+ self.infos = []++ def info(self, message, *args, **kwargs):+ self.infos.append(message)++ def debug(self, message, *args, **kwargs):+ pass++ def warning(self, message, *args, **kwargs):+ pass++ def error(self, message, *args, **kwargs):+ pass++ logger = RecordingLogger()+ monkeypatch.setattr(Agent, 'logger', property(lambda self: logger))+ agent = Agent(task='Control lifecycle feedback.', directly_open_url=False)++ agent.pause()+ pause_output = capsys.readouterr().out++ assert agent.state.paused is True+ assert not agent._external_pause_event.is_set()+ assert 'Paused the agent and left the browser open.' in pause_output+ assert 'Press [Enter] to resume or [Ctrl+C] again to quit.' in pause_output++ agent.resume()+ resume_output = capsys.readouterr().out++ assert agent.state.paused is False+ assert agent._external_pause_event.is_set()+ assert '----------------------------------------------------------------------' in resume_output+ assert 'Resuming agent execution where it left off...' in resume_output++ agent.stop()++ assert agent.state.stopped is True+ assert agent._external_pause_event.is_set()+ assert logger.infos == ['⏹️ Agent stopping']++def test_rust_agent_sync_state_counts_terminal_histories_monotonically():from browser_use.rust import Agentfrom browser_use.rust.service import _history_from_events