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
Log Rust model outputs like Browser Use
Magnus Müllera7b3d98c2db2
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex ce38e1d9d..24616d47f 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -1071,10 +1071,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- Secret values remain excluded from the warning text while matching Browser Use's public error/warning messages.- Proof: `test_rust_agent_sensitive_data_warnings_match_browser_use`.+212. Rust Agent model-output response logging parity+ - Rust-backed `get_model_output(...)` now calls Browser Use's shared `log_response(...)` helper after URL restoration and action trimming.+ - This preserves the public evaluation, memory, and next-goal log lines that callers see when using Python Agent helper methods against the Rust-backed interface.+ - Proof: `test_rust_agent_get_model_output_logs_response_like_browser_use`.+## 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` (180 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (181 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 41c62c6fb..d9a22feb0 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -3521,6 +3521,12 @@ class Agent(Generic[Context, AgentStructuredOutput]):if actions and len(actions) > self.settings.max_actions_per_step:parsed.action = actions[: self.settings.max_actions_per_step]+ if not (hasattr(self.state, 'paused') and (self.state.paused or self.state.stopped)):+ from browser_use.agent.service import log_response++ registry = getattr(getattr(self.tools, 'registry', None), 'registry', None)+ log_response(parsed, registry, self.logger)+self._log_next_action_summary(parsed)return parseddiff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 454963dae..3e3a48072 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -6458,6 +6458,71 @@ 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):+ from browser_use.agent.service import _PythonAgent as BrowserUseAgent+ from browser_use.llm.messages import UserMessage+ from browser_use.rust import Agent as RustAgent++ class RecordingLogger:+ def __init__(self):+ self.debugs = []+ self.infos = []++ def debug(self, message, *args, **kwargs):+ self.debugs.append(message)++ def info(self, message, *args, **kwargs):+ self.infos.append(message)++ def warning(self, message, *args, **kwargs):+ pass++ def isEnabledFor(self, level):+ return False++ class LLM:+ model = 'gpt-test'+ provider = 'test-provider'++ def __init__(self):+ self.agent = None++ async def ainvoke(self, messages, output_format=None, **kwargs):+ return type(+ 'Result',+ (),+ {+ 'usage': None,+ 'completion': self.agent.AgentOutput(+ evaluation_previous_goal='neutral',+ memory='remember response logging',+ next_goal='finish response logging',+ action=[self.agent.ActionModel(done={'text': 'logged', 'success': True})],+ ),+ },+ )()++ browser_use_logger = RecordingLogger()+ rust_logger = RecordingLogger()+ monkeypatch.setattr(BrowserUseAgent, 'logger', property(lambda self: browser_use_logger))+ monkeypatch.setattr(RustAgent, 'logger', property(lambda self: rust_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')])++ 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)++async def test_rust_agent_exposes_prepare_context_helper_method(monkeypatch):from types import SimpleNamespace