Skip to content

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

Match Rust run metadata messages

Magnus Müller10c8c05fd341
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.md
index daabd975c..71354f0ac 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/RUST_AGENT_INTEGRATION_FEATURES.md
@@ -1086,10 +1086,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai
- This preserves the visible task-completion status feedback for direct helper calls and run-level done-callback ordering.
- Proof: `test_rust_agent_log_completion_matches_browser_use`.
+215. Rust Agent run metadata message parity
+ - Rust-backed `_log_agent_run()` now emits Browser Use's exact task, library-version, and newer-version messages.
+ - This preserves the visible run-start metadata and upgrade prompt formatting for direct helper calls and normal Rust-backed runs.
+ - Proof: `test_rust_agent_run_metadata_logs_match_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` (183 tests)
+- `uv run pytest -q tests/ci/test_rust_agent.py` (184 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.py
index 662b8496c..13ed387a9 100644
--- a/browser_use/rust/service.py
+++ b/browser_use/rust/service.py
@@ -2729,12 +2729,12 @@ class Agent(Generic[Context, AgentStructuredOutput]):
async def _log_agent_run(self) -> None:
"""Log Browser Use run metadata for the Rust-backed wrapper."""
- self.logger.info(f'\033[34mTask: {self.task}\033[0m')
- self.logger.debug(f'Browser-Use Library Version {self.version} ({self.source})')
+ self.logger.info(f'\033[34m🎯 Task: {self.task}\033[0m')
+ self.logger.debug(f'🤖 Browser-Use Library Version {self.version} ({self.source})')
latest_version = await check_latest_browser_use_version()
if latest_version and latest_version != self.version:
self.logger.info(
- f'Newer version available: {latest_version} (current: {self.version}). Upgrade with: uv add browser-use@{latest_version}'
+ f'📦 Newer version available: {latest_version} (current: {self.version}). Upgrade with: uv add browser-use@{latest_version}'
)
def _log_agent_setup(self) -> None:
diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.py
index de4d090a1..f2aed3240 100644
--- a/tests/ci/test_rust_agent.py
+++ b/tests/ci/test_rust_agent.py
@@ -3414,8 +3414,8 @@ async def test_rust_agent_run_logs_browser_use_run_metadata(monkeypatch):
agent = Agent(task='Log run metadata.', llm=type('LLM', (), {'model': 'gpt-test'})())
async def fake_run_process(argv, timeout_seconds=None):
- assert any(message.endswith('Task: Log run metadata.\033[0m') for message in logger.infos)
- assert any('Browser-Use Library Version' in message for message in logger.debugs)
+ assert any(message == '\033[34m🎯 Task: Log run metadata.\033[0m' for message in logger.infos)
+ assert any(message.startswith('🤖 Browser-Use Library Version') for message in logger.debugs)
return 0, 'Session: 12345678-1234-1234-1234-123456789abc\n', ''
async def fake_load_events():
@@ -3430,6 +3430,67 @@ async def test_rust_agent_run_logs_browser_use_run_metadata(monkeypatch):
assert logger.errors == []
+async def test_rust_agent_run_metadata_logs_match_browser_use(monkeypatch):
+ import browser_use.agent.service as agent_service
+ import browser_use.rust.service as rust_service
+ from browser_use.agent.service import _PythonAgent as BrowserUseAgent
+ from browser_use.rust import Agent as RustAgent
+
+ class LLM:
+ model = 'gpt-test'
+ provider = 'test'
+
+ async def ainvoke(self, messages, output_format=None, **kwargs):
+ return type('Result', (), {'usage': None})()
+
+ class RecordingLogger:
+ def __init__(self):
+ self.infos = []
+ self.debugs = []
+
+ def info(self, message, *args, **kwargs):
+ self.infos.append(message)
+
+ def debug(self, message, *args, **kwargs):
+ self.debugs.append(message)
+
+ async def latest_version():
+ return '99.99.99'
+
+ browser_use_logger = RecordingLogger()
+ rust_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(BrowserUseAgent, 'logger', property(lambda self: browser_use_logger))
+ monkeypatch.setattr(RustAgent, 'logger', property(lambda self: rust_logger))
+
+ browser_use_agent = BrowserUseAgent(
+ task='Log run metadata parity.',
+ llm=LLM(),
+ task_id='runmetadatabu',
+ directly_open_url=False,
+ )
+ rust_agent = RustAgent(
+ task='Log run metadata parity.',
+ llm=LLM(),
+ task_id='runmetadatars',
+ directly_open_url=False,
+ )
+ browser_use_logger.infos.clear()
+ browser_use_logger.debugs.clear()
+ rust_logger.infos.clear()
+ rust_logger.debugs.clear()
+
+ await browser_use_agent._log_agent_run()
+ await rust_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')
+
+
async def test_rust_agent_run_logs_first_step_startup(monkeypatch):
from browser_use.rust import Agent