The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-desktop): cap the dock browser's disk cache
teknium1e8473ae5e469
diff --git a/tests/tools/test_bot_desktop_browser.py b/tests/tools/test_bot_desktop_browser.pyindex 5ad84ec6b2c..d73c1e08eda 100644--- a/tests/tools/test_bot_desktop_browser.py+++ b/tests/tools/test_bot_desktop_browser.py@@ -36,6 +36,14 @@ def test_dock_browser_advertises_a_devtools_port():assert "--remote-debugging-port=" in browser.dock_argv("/opt/chrome", "/p/dir")[2]+def test_dock_browser_caps_its_disk_cache():+ """The persistent profile lives on the gateway's disk (6 GB on a hosted instance); the HTTP cache+ must not be allowed to grow without bound there."""+ argv = browser.dock_argv("/opt/chrome", "/p/dir")+ cap = next(a for a in argv if a.startswith("--disk-cache-size="))+ assert 0 < int(cap.split("=", 1)[1]) <= 512 * 1024 * 1024++def _fake_running_instance(user_data_dir, pid: int, port: int) -> None:(user_data_dir / "DevToolsActivePort").write_text(f"{port}\n/devtools/browser/abc\n", encoding="utf-8")os.symlink(f"host-{pid}", user_data_dir / "SingletonLock")diff --git a/tools/bot_desktop/browser.py b/tools/bot_desktop/browser.pyindex cb77cb62d34..1da06ad41a3 100644--- a/tools/bot_desktop/browser.py+++ b/tools/bot_desktop/browser.py@@ -20,6 +20,8 @@ from typing import Optional, Tuplefrom tools.bot_desktop import runtime+DISK_CACHE_BYTES = 256 * 1024 * 1024+_SYSTEM_BROWSERS = ("google-chrome", "google-chrome-stable", "chromium", "chromium-browser")@@ -93,8 +95,10 @@ def dock_argv(exe: str, user_data_dir: str) -> list[str]:# human's Browser is the bot's browser, in the same container; a stricter rule here just made the dock# icon die with 'No usable sandbox!' in the official image while the agent's own Chromium ran fine.from tools.browser_tool_session import CHROMIUM_SANDBOX_BYPASS_ARGS, _needs_chromium_sandbox_bypass+ # The profile is persistent by design (logins survive handoffs); its HTTP cache is not worth a+ # gateway's disk: uncapped it grows for months toward a hosted instance's 6 GB.return [exe, f"--user-data-dir={user_data_dir}", "--remote-debugging-port=0", "--no-first-run",- "--no-default-browser-check", "--test-type",+ "--no-default-browser-check", "--test-type", f"--disk-cache-size={DISK_CACHE_BYTES}",*(CHROMIUM_SANDBOX_BYPASS_ARGS if _needs_chromium_sandbox_bypass() else ())]