fix(container): reclaim abandoned browser sessions

Each agent-browser session is a separate Chromium (~340 MB, ~12 processes)
and nothing owns a browser's lifecycle, so finished, stopped and crashed
agents strand theirs for the life of the sandbox. Enable the daemon's idle
timeout and stop telling agents each of them has its own browser.
This commit is contained in:
Ahmed Allam
2026-08-09 23:33:04 +00:00
committed by Devin AI
parent ae07af6159
commit 55e15f89fd
3 changed files with 39 additions and 3 deletions
+11
View File
@@ -117,6 +117,17 @@ ENV AGENT_BROWSER_EXECUTABLE_PATH=/usr/bin/chromium
ENV AGENT_BROWSER_USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
ENV AGENT_BROWSER_ARGS="--disable-blink-features=AutomationControlled,--no-first-run,--no-default-browser-check,--lang=en-US"
ENV AGENT_BROWSER_SCREENSHOT_DIR=/workspace/.agent-browser-screenshots
# Reclaim abandoned browsers. Each `--session` name is a separate daemon owning its
# own Chromium process group — measured at ~340 MB and ~12 processes with one page
# open — and nothing in the engine owns a browser's lifecycle: agents drive
# `agent-browser` through exec_command, so an agent that finishes, is stopped, or
# crashes leaves its browser resident for the life of the sandbox. Upstream
# disables the idle timeout by default, which turns a wide fan-out into gigabytes
# of stranded Chromium. The daemon relaunches transparently on the next command, so
# the only cost of reclamation is losing browser state (see the skill's note on
# persisting it). Three minutes is longer than the gap between two browser commands
# in an active agent turn; override the env var to tune.
ENV AGENT_BROWSER_IDLE_TIMEOUT_MS=180000
RUN /home/pentester/.npm-global/bin/agent-browser doctor --offline --quick
RUN set -eux; \