Skip to content

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

Log Rust initial action lifecycle

Magnus Mülleraf2bca36344f
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.md
index e70d7cf31..46443987f 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/RUST_AGENT_INTEGRATION_FEATURES.md
@@ -966,6 +966,11 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai
- The helpers also emit the same debug markers before switching `AgentOutput` to `DoneAgentOutput`.
- Proof: `test_rust_agent_done_only_guidance_matches_browser_use`.
+191. Rust Agent initial-action logging parity
+ - Rust-backed `_execute_initial_actions(...)` now emits the same Browser Use debug markers for executing configured initial actions, saving them as step 0, and completing initial-action processing.
+ - Step-0 history recording, long-term-memory annotation, and action replay behavior remain unchanged.
+ - Proof: `test_rust_agent_exposes_action_replay_helper_methods`.
+
## 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`
diff --git a/browser_use/rust/service.py b/browser_use/rust/service.py
index b6fe5c5da..b44dfdbb2 100644
--- a/browser_use/rust/service.py
+++ b/browser_use/rust/service.py
@@ -3719,6 +3719,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
"""Execute configured Browser Use initial actions through the Rust-backed action path."""
if not self.initial_actions or self.state.follow_up_task:
return
+ self.logger.debug(f'⚡ Executing {len(self.initial_actions)} initial actions...')
result = await self.multi_act(self.initial_actions)
if result and self.initial_url and result[0].long_term_memory:
result[0].long_term_memory = f'Found initial url and automatically loaded it. {result[0].long_term_memory}'
@@ -3759,6 +3760,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):
metadata=metadata,
)
)
+ self.logger.debug('📝 Saved initial actions to history as step 0')
+ self.logger.debug('Initial actions completed')
async def _execute_history_step(self, history_item: AgentHistory, delay: float) -> list[ActionResult]:
"""Replay a Browser Use history step when Python action models are available."""
diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.py
index a9827755a..13b4a9805 100644
--- a/tests/ci/test_rust_agent.py
+++ b/tests/ci/test_rust_agent.py
@@ -5385,12 +5385,25 @@ async def test_rust_agent_multi_act_ignores_later_done_actions():
assert results[0].extracted_content == 'clicked only'
-async def test_rust_agent_exposes_action_replay_helper_methods():
+async def test_rust_agent_exposes_action_replay_helper_methods(monkeypatch):
from types import SimpleNamespace
from browser_use.agent.views import ActionResult
from browser_use.rust import Agent
+ class RecordingLogger:
+ def __init__(self):
+ self.debugs = []
+
+ def debug(self, message, *args, **kwargs):
+ self.debugs.append(message)
+
+ def info(self, message, *args, **kwargs):
+ pass
+
+ logger = RecordingLogger()
+ monkeypatch.setattr(Agent, 'logger', property(lambda self: logger))
+
class BrowserProfile:
downloads_path = None
@@ -5436,6 +5449,11 @@ async def test_rust_agent_exposes_action_replay_helper_methods():
assert agent.history.history[0].metadata.step_number == 0
assert agent.history.history[0].state.url == 'https://example.com'
assert agent.history.history[0].model_output.action == agent.initial_actions
+ assert logger.debugs == [
+ '⚡ Executing 1 initial actions...',
+ '📝 Saved initial actions to history as step 0',
+ 'Initial actions completed',
+ ]
action = FakeAction()
replay_calls = []