Skip to content

fix(browser): use AGENT_BROWSER_ARGS instead of AGENT_BROWSER_CHROME_FLAGS - #24198

Open
ambition0802 wants to merge 1 commit into
NousResearch:mainfrom
ambition0802:fix/browser-agent-browser-args-env-var
Open

fix(browser): use AGENT_BROWSER_ARGS instead of AGENT_BROWSER_CHROME_FLAGS#24198
ambition0802 wants to merge 1 commit into
NousResearch:mainfrom
ambition0802:fix/browser-agent-browser-args-env-var

Conversation

@ambition0802

Copy link
Copy Markdown
Contributor

Summary

The browser tool was setting AGENT_BROWSER_CHROME_FLAGS when sandbox bypass was needed, but agent-browser only reads AGENT_BROWSER_ARGS. This caused the --no-sandbox injection to be a silent no-op on Ubuntu 23.10+ / AppArmor systems, resulting in "No usable sandbox" errors.

Changes

  1. Fixed env var name in _run_browser_command():

  2. Added sandbox bypass to _run_chrome_fallback_command():

    • This function was missing the sandbox detection logic entirely
    • Now applies the same root/AppArmor detection and AGENT_BROWSER_ARGS injection
    • Uses consistent logger prefix (browser fallback:)

Root Cause

Commit 74c1b94 added sandbox bypass detection and wrote to AGENT_BROWSER_CHROME_FLAGS, but the agent-browser CLI only consumes AGENT_BROWSER_ARGS. The env var mismatch meant the flags were never actually passed to Chromium on launch.

Testing

  • Python syntax validation: ✅
  • Logic verified against agent-browser documented env vars

Affected Systems

  • Root user execution (Docker/VPS deployments)
  • Ubuntu 23.10+ with AppArmor userns restrictions
  • Non-root users under systemd or unprivileged containers

Fixes #23496
Related: #15765

…FLAGS

The browser tool was setting AGENT_BROWSER_CHROME_FLAGS when sandbox bypass
was needed, but agent-browser only reads AGENT_BROWSER_ARGS. This caused the
--no-sandbox injection to be a silent no-op on Ubuntu 23.10+ / AppArmor
systems, resulting in "No usable sandbox" errors.

Changes:
- Rename AGENT_BROWSER_CHROME_FLAGS → AGENT_BROWSER_ARGS in _run_browser_command()
- Add the same sandbox bypass logic to _run_chrome_fallback_command() which
  was missing it entirely
- Update comments to reference issue NousResearch#23496

Fixes NousResearch#23496
Related: NousResearch#15765
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/browser Browser automation (CDP, Playwright) labels May 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #21659 and #20014 for the same fix (AGENT_BROWSER_CHROME_FLAGS → AGENT_BROWSER_ARGS). All address #23496. #23532 was previously closed as duplicate.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the agent-browser environment-variable mismatch.

Problems

  • The primary replacement is already on current main: tools/browser_tool.py:2405-2416 injects comma-separated AGENT_BROWSER_ARGS; commit 8ed2ef6f46e9642acfba57b4b8da893a574ecfd0 made that correction.
  • The fallback half remains relevant, but it should be rebased conceptually rather than copied verbatim. Current main centralizes root/Docker/AppArmor detection in _needs_chromium_sandbox_bypass() at tools/browser_tool.py:301-314; the PR's duplicated fallback condition omits Docker and uses the pre-fix space-separated argument form.
  • Current tests cover the detection helper (tests/tools/test_browser_open_timeout.py:31-51) and fallback annotations, but not the fallback subprocess environment.

Suggested changes

  • Salvage the fallback-only fix at tools/browser_tool.py:1055: reuse _needs_chromium_sandbox_bypass() and inject AGENT_BROWSER_ARGS=--no-sandbox,--disable-dev-shm-usage with the same pre-set-variable guard as tools/browser_tool.py:2405-2416.
  • Add a regression test that captures the fallback subprocess.Popen(..., env=...) call.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

3 participants