Skip to content

fix(browser): set AGENT_BROWSER_ARGS for --no-sandbox bypass - #22582

Closed
pasevin wants to merge 2 commits into
NousResearch:mainfrom
pasevin:fix/browser-agent-browser-args-sandbox-bypass
Closed

fix(browser): set AGENT_BROWSER_ARGS for --no-sandbox bypass#22582
pasevin wants to merge 2 commits into
NousResearch:mainfrom
pasevin:fix/browser-agent-browser-args-sandbox-bypass

Conversation

@pasevin

@pasevin pasevin commented May 9, 2026

Copy link
Copy Markdown
Contributor

Problem

The existing AppArmor/root sandbox detection (commit 74c1b946e, issue #15765) sets AGENT_BROWSER_CHROME_FLAGS in the subprocess env when --no-sandbox is needed. AGENT_BROWSER_CHROME_FLAGS is not a variable that agent-browser reads — it is a Hermes-internal guard variable and is silently ignored by the binary.

agent-browser 0.26+ reads AGENT_BROWSER_ARGS (comma-separated) for Chrome launch flags. That variable was never being set by the auto-detection code.

Result: on Ubuntu 23.10+ and other AppArmor-restricted hosts (/proc/sys/kernel/apparmor_restrict_unprivileged_userns == 1), the detection fires correctly but Chrome still exits with:

FATAL: No usable sandbox! ... unprivileged user namespaces disabled

A secondary issue: _needs_sandbox_bypass was declared inside the AGENT_BROWSER_CHROME_FLAGS guard, leaving it uninitialized when that guard is skipped. cmd_parts was also constructed before browser_env existed.

Fix

  • Set AGENT_BROWSER_ARGS=--no-sandbox,--disable-dev-shm-usage when sandbox bypass is detected (alongside AGENT_BROWSER_CHROME_FLAGS which is retained as a Hermes-internal skip guard for backward compat).
  • Move _needs_sandbox_bypass = False outside the AGENT_BROWSER_CHROME_FLAGS guard.
  • Move cmd_parts construction inside the try block where browser_env is available.

Verification

Tested on Ubuntu 24.04 with apparmor_restrict_unprivileged_userns = 1, no system Chrome, Playwright Chromium at ~/.cache/ms-playwright. After the fix, browser_navigate succeeds using the native agent-browser daemon path without any CDP workaround.

The agent-browser binary itself correctly inherits AGENT_BROWSER_ARGS from the caller's environment into the daemon child — confirmed via /proc/<pid>/environ on a clean reproduction. The entire issue was the wrong variable name on the Hermes side.

@pasevin

pasevin commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

Looks like the ruff + ty diff check failure is unrelated to the code changes — it's a GitHub Actions permissions issue where fork PRs can't post comments back to the upstream repo (Resource not accessible by integration). The actual lint step passed cleanly, as confirmed by ruff enforcement (blocking) being green. Happy to rebase or squash if that helps the merge.

@pasevin
pasevin force-pushed the fix/browser-agent-browser-args-sandbox-bypass branch from 49b7eb9 to 8f79835 Compare May 9, 2026 14:10
pasevin added 2 commits May 9, 2026 14:49
The existing AppArmor/root detection code sets AGENT_BROWSER_CHROME_FLAGS
in the subprocess env, but that is a Hermes-internal variable — agent-browser
0.26+ reads AGENT_BROWSER_ARGS (comma-separated) to pass flags to Chrome.

Fix: also set AGENT_BROWSER_ARGS when sandbox bypass is detected, and move
_needs_sandbox_bypass outside the AGENT_BROWSER_CHROME_FLAGS guard so it is
always initialised. Also move cmd_parts inside the try block where browser_env
is available.

Fixes: NousResearch#15765
@pasevin
pasevin force-pushed the fix/browser-agent-browser-args-sandbox-bypass branch from 8f79835 to f625001 Compare May 9, 2026 14:50
@pasevin pasevin changed the title fix(browser): use AGENT_BROWSER_ARGS and --args for --no-sandbox bypass fix(browser): set AGENT_BROWSER_ARGS for --no-sandbox bypass May 9, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround tool/browser Browser automation (CDP, Playwright) comp/tools Tool registry, model_tools, toolsets labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #20014, #21659, #23517 for the same fix (issue #23496). All address AGENT_BROWSER_CHROME_FLAGS → AGENT_BROWSER_ARGS env var rename.

@pasevin

pasevin commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, should have looked more before submitting. Feel free to close if redundant!

@teknium1

Copy link
Copy Markdown
Contributor

This looks implemented on current main by the later browser sandbox-bypass fix. This is an automated hermes-sweeper review.

Evidence:

  • tools/browser_tool.py now injects AGENT_BROWSER_ARGS=--no-sandbox,--disable-dev-shm-usage when root/AppArmor sandbox bypass is needed, while respecting pre-set AGENT_BROWSER_ARGS or legacy AGENT_BROWSER_CHROME_FLAGS.
  • Commit 8ed2ef6f46e9642acfba57b4b8da893a574ecfd0 changed the bypass from the unused AGENT_BROWSER_CHROME_FLAGS variable to the agent-browser-consumed AGENT_BROWSER_ARGS variable.
  • Commit 4695d2716f60da89152bdc9dfa7d96e54ea7c22e added the pre-set AGENT_BROWSER_ARGS guard and documentation.
  • The fix is contained in v2026.5.16 and later tags.

Thanks for the clean report and verification notes. The maintainer thread also called out that this PR was competing with the same AGENT_BROWSER_ARGS fix from other PRs, so closing this as redundant with main.

@teknium1 teknium1 closed this Jun 11, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P1 High — major feature broken, no workaround sweeper:implemented-on-main Sweeper: behavior already present on current main 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