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
Avoid resetting Laminar context during Rust replay
Magnus Müller90dc15fc0ffa
diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex f4f2a63c1..cd18a0d4c 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -159,7 +159,7 @@ def _laminar_start_span(name: str, *, input: Any = None, span_type: str = 'DEFAUdef _laminar_force_flush() -> None:if not _laminar_ready():return- for method_name in ('force_flush', 'flush'):+ for method_name in ('flush', 'force_flush'):method = getattr(Laminar, method_name, None)if method is None:continuediff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 5f675b164..037c5aa3d 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -7493,6 +7493,33 @@ async def test_rust_agent_run_exposes_laminar_trace_id_for_eval_links(monkeypatcassert agent.laminar_trace_id == '01234567-89ab-cdef-0123-456789abcdef'+def test_rust_laminar_replay_flush_avoids_context_reset(monkeypatch):+ import browser_use.rust.service as rust_service++ class FakeLaminar:+ flushes = 0+ force_flushes = 0++ @staticmethod+ def is_initialized():+ return True++ @classmethod+ def flush(cls):+ cls.flushes += 1++ @classmethod+ def force_flush(cls):+ cls.force_flushes += 1++ monkeypatch.setattr(rust_service, 'Laminar', FakeLaminar)++ rust_service._laminar_force_flush()++ assert FakeLaminar.flushes == 1+ assert FakeLaminar.force_flushes == 0++def test_rust_agent_laminar_run_summary_populates_current_span(monkeypatch):from browser_use.rust import Agentimport browser_use.rust.service as rust_service