Skip to content

The agent that grows with you

fix(browser): claim the Chrome-fallback socket dir before using it

Adrià Arrufat2e2cdc292723
diff --git a/tools/browser_tool.py b/tools/browser_tool.py
index da04ca1c478..438e7a64ce3 100644
--- a/tools/browser_tool.py
+++ b/tools/browser_tool.py
@@ -1357,6 +1357,10 @@ def _run_chrome_fallback_command(
task_socket_dir = os.path.join(_socket_safe_tmpdir(), f"agent-browser-{tmp_session}")
os.makedirs(task_socket_dir, mode=0o700, exist_ok=True)
+ # Claim the dir before using it: another hermes process's orphan reaper
+ # rmtree's any agent-browser-* dir in the shared tmpdir that carries no
+ # live owner, which otherwise deletes this one mid-command.
+ _write_owner_pid(task_socket_dir, tmp_session)
browser_env = _build_browser_env()
browser_env["AGENT_BROWSER_SOCKET_DIR"] = task_socket_dir
browser_env["PATH"] = _merge_browser_path(browser_env.get("PATH", ""))