From 7b3c8f9b74b8ee5311d0b80c2f2a4cc9228f519a Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 9 Aug 2026 16:57:51 -0700 Subject: [PATCH] fix(container): reclaim abandoned browser sessions (#1034) Co-authored-by: Ahmed Allam --- containers/Dockerfile | 1 + strix/agents/prompts/system_prompt.jinja | 8 ++++- strix/skills/tooling/agent_browser.md | 37 ++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/containers/Dockerfile b/containers/Dockerfile index 9943266a..61c1a21e 100644 --- a/containers/Dockerfile +++ b/containers/Dockerfile @@ -117,6 +117,7 @@ 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 +ENV AGENT_BROWSER_IDLE_TIMEOUT_MS=180000 RUN /home/pentester/.npm-global/bin/agent-browser doctor --offline --quick RUN set -eux; \ diff --git a/strix/agents/prompts/system_prompt.jinja b/strix/agents/prompts/system_prompt.jinja index 3efc07af..23493d2d 100644 --- a/strix/agents/prompts/system_prompt.jinja +++ b/strix/agents/prompts/system_prompt.jinja @@ -263,7 +263,13 @@ Remember: A single well-validated high-impact vulnerability is worth more than d AGENT ISOLATION & SANDBOXING: - All agents run in the same shared Docker container for efficiency -- Each agent has its own: browser sessions, terminal sessions +- Each agent has its own terminal sessions +- Browsers are NOT per-agent by default: `agent-browser` with no `--session` is one + shared browser, so a concurrent agent's navigation invalidates your page and refs. + Pass `--session ` for any browser work of your own — then it is + yours alone. Each session is a full Chromium (~340 MB) on this shared box, so keep + one, not several, and `agent-browser --session close` when you're done with + the target; an idle browser is reclaimed automatically after 3 minutes - All agents share the same /workspace directory and proxy history - Agents can see each other's files and proxy traffic for better collaboration diff --git a/strix/skills/tooling/agent_browser.md b/strix/skills/tooling/agent_browser.md index db074e86..a254bfaf 100644 --- a/strix/skills/tooling/agent_browser.md +++ b/strix/skills/tooling/agent_browser.md @@ -58,6 +58,26 @@ agent-browser screenshot The browser stays running across commands so these feel like a single session. Use `agent-browser close` (or `close --all`) when you're done. +The default session is **shared with every other agent in the sandbox** — if +another agent navigates it, your page and your refs are gone from under you. So +claim your own by passing `--session ` on **every** command: + +```bash +agent-browser --session recon-3 open https://example.com +agent-browser --session recon-3 snapshot -i +agent-browser --session recon-3 close # when done with the target +``` + +The examples in the rest of this skill omit `--session` to keep them readable; +keep passing yours. Each session is a separate Chromium (~340 MB) on a shared +box, so hold one rather than several, and close it when you're finished. + +A browser left idle for 3 minutes is reclaimed automatically to free memory for +the other agents; the next command relaunches it, but the page, tabs, refs and +cookies are gone. If you're authenticated and about to go do something else for a +while, save the state first (see +[Persist session across runs](#persist-session-across-runs)). + ## Reading a page ```bash @@ -307,6 +327,16 @@ agent-browser --session b fill @e1 "bob@test.com" `AGENT_BROWSER_SESSION=myapp` sets the default session for the current shell. +Use a session named after yourself for your own work — that's what keeps a +concurrent agent from navigating the page out from under you. Every session is a +separate Chromium though, so hold one at a time rather than a collection, and +close each one when its flow is finished: + +```bash +agent-browser --session a close +agent-browser --session b close +``` + ### Mock network requests ```bash @@ -368,8 +398,11 @@ agent-browser dialog dismiss # cancel ## Readiness & recovery The first `agent-browser open` in a session launches the headless-Chrome -daemon; later commands reuse it. Distinguish the two failure modes and react -differently — do **not** blindly re-run the same failing command in a loop: +daemon; later commands reuse it. A daemon left idle for 3 minutes shuts itself +down to free memory for the other agents, so an `open` after a long gap is a +fresh browser rather than a resumed one — expect to re-navigate, and re-`state +load` if you were logged in. Distinguish the failure modes and react differently +— do **not** blindly re-run the same failing command in a loop: - **Daemon / connection failure** (`Failed to connect`, `connection refused`, socket missing, `browser not running`): the daemon isn't up or has died. Run