Skip to content

fix(browser): use correct env var for --no-sandbox bypass - #24821

Closed
Jaggia wants to merge 1 commit into
NousResearch:mainfrom
Jaggia:fix/browser-sandbox-env-var
Closed

Jaggia wants to merge 1 commit into
NousResearch:mainfrom
Jaggia:fix/browser-sandbox-env-var

Conversation

@Jaggia

@Jaggia Jaggia commented May 13, 2026

Copy link
Copy Markdown
Contributor

Bug

On Ubuntu 23.10+ (and other distros with AppArmor unprivileged user namespace restrictions), browser_navigate crashes with:

FATAL: No usable sandbox! ... No usable sandbox!

The detection logic in tools/browser_tool.py correctly identifies the AppArmor restriction and attempts to inject --no-sandbox, but passes it via the wrong environment variable.

Root Cause

Lines 1873-1876 set AGENT_BROWSER_CHROME_FLAGS, but agent-browser CLI reads AGENT_BROWSER_ARGS (see agent-browser --help: --args <args> Browser launch args (or AGENT_BROWSER_ARGS)).

Additionally, the value uses space-separation ("--no-sandbox --disable-dev-shm-usage") but agent-browser expects comma-separated values.

Fix

Two-line change in tools/browser_tool.py:

-                browser_env["AGENT_BROWSER_CHROME_FLAGS"] = (
-                    "--no-sandbox --disable-dev-shm-usage"
+                browser_env["AGENT_BROWSER_ARGS"] = (
+                    "--no-sandbox,--disable-dev-shm-usage"
                 )

Testing

# Before fix (AGENT_BROWSER_CHROME_FLAGS):
$ AGENT_BROWSER_CHROME_FLAGS="--no-sandbox --disable-dev-shm-usage" npx agent-browser navigate "https://example.com" --json
# → FATAL: No usable sandbox!

# After fix (AGENT_BROWSER_ARGS):
$ AGENT_BROWSER_ARGS="--no-sandbox,--disable-dev-shm-usage" npx agent-browser navigate "https://example.com" --json
# → {"success":true,"data":{"title":"Example Domain","url":"https://example.com/"}}

Tested on Ubuntu with apparmor_restrict_unprivileged_userns = 1, Playwright Chromium 147.0.7727.15, agent-browser 0.27.0.

Checklist

  • Bug fix (non-breaking change which fixes an issue)
  • Verified the fix resolves the issue on the affected platform

AGENT_BROWSER_CHROME_FLAGS is not read by agent-browser CLI.
The correct env var is AGENT_BROWSER_ARGS, with comma-separated values.

This fixes Chrome 'No usable sandbox' crash on Ubuntu 23.10+ systems
where AppArmor restricts unprivileged user namespaces. The detection
logic was correct but the fix used the wrong environment variable name
and space-separated instead of comma-separated args.
@alt-glitch alt-glitch added type/bug Something isn't working tool/browser Browser automation (CDP, Playwright) P2 Medium — degraded but workaround exists labels May 13, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Duplicate of #24198 (and competing with #21659, #22582 for the same fix to issue #23496). Same two-line change: AGENT_BROWSER_CHROME_FLAGSAGENT_BROWSER_ARGS with comma separation.

@teknium1

Copy link
Copy Markdown
Collaborator

Salvaged in PR #25988 (merged as 8ed2ef6 + follow-up 4695d27). Your authorship is preserved in git log — thanks for spotting the right env var. The follow-up just extends the opt-out gate so a user-set AGENT_BROWSER_ARGS isn't overwritten, plus docs and an AUTHOR_MAP entry.

#25988

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 tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants