fix(browser): set AGENT_BROWSER_ARGS for --no-sandbox bypass - #22582
fix(browser): set AGENT_BROWSER_ARGS for --no-sandbox bypass#22582pasevin wants to merge 2 commits into
Conversation
|
Looks like the |
49b7eb9 to
8f79835
Compare
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
8f79835 to
f625001
Compare
|
Sorry, should have looked more before submitting. Feel free to close if redundant! |
|
This looks implemented on current main by the later browser sandbox-bypass fix. This is an automated hermes-sweeper review. Evidence:
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. |
Problem
The existing AppArmor/root sandbox detection (commit
74c1b946e, issue #15765) setsAGENT_BROWSER_CHROME_FLAGSin the subprocess env when--no-sandboxis needed.AGENT_BROWSER_CHROME_FLAGSis 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:A secondary issue:
_needs_sandbox_bypasswas declared inside theAGENT_BROWSER_CHROME_FLAGSguard, leaving it uninitialized when that guard is skipped.cmd_partswas also constructed beforebrowser_envexisted.Fix
AGENT_BROWSER_ARGS=--no-sandbox,--disable-dev-shm-usagewhen sandbox bypass is detected (alongsideAGENT_BROWSER_CHROME_FLAGSwhich is retained as a Hermes-internal skip guard for backward compat)._needs_sandbox_bypass = Falseoutside theAGENT_BROWSER_CHROME_FLAGSguard.cmd_partsconstruction inside thetryblock wherebrowser_envis 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_navigatesucceeds using the native agent-browser daemon path without any CDP workaround.The agent-browser binary itself correctly inherits
AGENT_BROWSER_ARGSfrom the caller's environment into the daemon child — confirmed via/proc/<pid>/environon a clean reproduction. The entire issue was the wrong variable name on the Hermes side.