fix(native): auto_launch() honours AGENT_BROWSER_PROVIDER for cloud providers (#1126)

When a non-launch command (e.g. open, snapshot) triggers auto_launch()
before the explicit launch command is processed, auto_launch() now checks
AGENT_BROWSER_PROVIDER and connects via the provider API instead of
always falling back to a local Chrome instance.

Also redirects daemon stderr to /dev/null when not in debug mode to
prevent crashes from broken pipe after the CLI drops the piped stderr
handle. Cloud providers may write to stderr during connection setup.

Fixes #1125
Related: #979
This commit is contained in:
Hung-Che Lo
2026-04-04 10:29:04 -05:00
committed by GitHub
parent c52d25d576
commit 4b5ba9f245
2 changed files with 58 additions and 0 deletions
+16
View File
@@ -41,6 +41,22 @@ pub async fn run_daemon(session: &str) {
session
);
}
} else {
// Redirect stderr to /dev/null to prevent daemon crash when the
// parent CLI drops the piped stderr handle after startup. Cloud
// providers (AgentCore, Browserbase, etc.) may write to stderr
// during connection setup; a broken pipe would kill the daemon.
#[cfg(unix)]
{
use std::os::unix::io::IntoRawFd;
if let Ok(devnull) = fs::File::create("/dev/null") {
let fd = devnull.into_raw_fd();
unsafe {
libc::dup2(fd, 2);
libc::close(fd);
}
}
}
}
let pid_path = socket_dir.join(format!("{}.pid", session));