The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(browser): a managed per-turn worker never owns its browser daemons
kshitijk4poorebbe223a4129
diff --git a/tests/tools/test_browser_use_cli_owned_daemon.py b/tests/tools/test_browser_use_cli_owned_daemon.pyindex 00155b9b0a0..c38e63d3954 100644--- a/tests/tools/test_browser_use_cli_owned_daemon.py+++ b/tests/tools/test_browser_use_cli_owned_daemon.py@@ -297,3 +297,17 @@ def test_a_long_first_browser_exec_owns_its_daemon_before_the_call_returns(monkebrowser_use_cli.browser_exec("print(page_info())", task_id="long-first-call")assert owned_during_call.is_set(), "the daemon was only owned after the CLI call returned"+++def test_a_managed_worker_never_owns_its_harness_daemon(fake_daemon, registered, monkeypatch):+ """A managed per-turn worker keeps its browser between turns (agent/managed_worker.py); owning+ the daemon would kill it with every turn's worker, as _owns_job already avoids for jobs."""+ from agent import runtime_session_store+ proc, runtime = fake_daemon+ _publish(runtime, "bu", proc.pid)+ monkeypatch.setattr(runtime_session_store, "_worker_process", True)++ browser_use_cli._own_harness_daemon({"BH_RUNTIME_DIR": str(runtime), "BU_NAME": "work"})++ assert registered == []+diff --git a/tools/browser_use_cli.py b/tools/browser_use_cli.pyindex af1f96612c5..d5578dd247c 100644--- a/tools/browser_use_cli.py+++ b/tools/browser_use_cli.py@@ -713,6 +713,9 @@ def _own_harness_daemon(env: dict) -> None:already owned for this daemon costs one file read."""if os.name != "posix":return # Windows: the harness daemon is outside this process's job; nothing to register.+ from agent.runtime_session_store import is_worker_process+ if is_worker_process():+ return # a managed per-turn worker: the next turn's worker keeps driving this daemonimport psutildaemon = daemon_identity(env)