Skip to content

Expose a supported way to disable browser-use ambient network initialization #21722

Open

Description

@zhanglg12

Environment

Summary

There appears to be an existing internal browser-use request metadata flag that can disable the ambient network/account initialization path:

x-codex-browser-use-disable-ambient-network: true

When this flag is present in nodeRepl.requestMeta, the bundled browser-client.mjs skips the ambient branch that starts Sentry/Statsig/account initialization and eventually calls:

nodeRepl.fetch("https://chatgpt.com/backend-api/me")

That is useful for cases like #21704, where the Chrome extension backend is healthy but setupAtlasRuntime() hangs because the non-browser nodeRepl.fetch() path gets stuck on the ambient /backend-api/me probe.

The problem is that there does not appear to be a supported way for a packaged Codex Desktop user to set this request metadata flag.

What I observed

browser-client.mjs contains the gate:

var j2 = "x-codex-browser-use-disable-ambient-network";
function Ps() {
  return globalThis.nodeRepl?.requestMeta?.[j2] === true;
}

var Ry = async () => {
  let e = await (await Sn("https://chatgpt.com/backend-api/me")).json();
  ...
};

var Dy = () => {
  Ps() || (Og(), Iy(), ep());
};

So when Ps() is true, the ambient network/account path is skipped.

The node_repl binary also appears to recognize BROWSER_USE_DISABLE_AMBIENT_NETWORK=1 when launched directly. In a standalone MCP probe, launching node_repl with:

BROWSER_USE_DISABLE_AMBIENT_NETWORK=1

produced:

{
  "x-codex-browser-use-disable-ambient-network": true
}

However, setting this for Codex Desktop did not make the packaged app's built-in node_repl receive the flag. After restart, the node_repl process still only received request metadata similar to:

{
  "x-codex-browser-use-available-backends": ["chrome", "iab"]
}

I also tried shell_environment_policy.set in ~/.codex/config.toml; it parsed successfully but did not affect the built-in node_repl MCP server environment/request metadata.

Local validation of a possible fix

Without modifying the app bundle or browser-client.mjs, I tested a local wrapper via CODEX_NODE_REPL_PATH that:

  1. preserves the NODE_REPL_REQUEST_META generated by Codex Desktop;
  2. adds "x-codex-browser-use-disable-ambient-network": true;
  3. execs the official bundled node_repl binary.

With that metadata present, Chrome browser-use setup started working again:

{
  "disableAmbient": true,
  "backend": "extension",
  "tabCount": 4
}

setupAtlasRuntime() no longer timed out on the ambient /backend-api/me path, and browser.user.openTabs() returned promptly.

This is only a local diagnostic workaround, not a supported fix, but it suggests that the existing metadata flag is sufficient to unblock Chrome extension discovery for this failure mode.

Suggested fixes

Any of these would make the internal flag usable without local wrappers:

  1. In the packaged app's browser-use node_repl MCP configuration, honor BROWSER_USE_DISABLE_AMBIENT_NETWORK=1 by adding:
{
  "x-codex-browser-use-disable-ambient-network": true
}

to the generated NODE_REPL_REQUEST_META.

  1. Expose a supported Codex config key for this behavior, for example a browser-use setting that maps to the same request metadata flag.

  2. Make the ambient /backend-api/me initialization non-blocking or bounded by a short timeout, so Chrome extension discovery can proceed even when the ambient account probe fails, returns HTML, returns a Cloudflare challenge, or otherwise cannot complete.

Expected behavior

If the Chrome extension/native host is healthy, setupAtlasRuntime() should be able to discover and use the Chrome extension backend even when optional ambient account/analytics initialization cannot complete.

Actual behavior

Without the metadata flag, setupAtlasRuntime() can hang until the JS execution kernel times out:

js execution timed out; kernel reset, rerun your request

This happens before any browser tab work, even though the extension-host socket can be healthy.

Activity

  1. added
    bugSomething isn't working
    appIssues related to the Codex desktop app
    connectivityIssues involving networking or endpoint connectivity problems (disconnections)
    mcpIssues related to the use of model context protocol (MCP) servers
    on May 8, 2026
  2. github-actions commented on May 8, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. Anonymousnake commented on May 8, 2026

    @Anonymousnake

    帅的哥们,这个方法修好了

  4. tavaresgmg commented on May 18, 2026

    @tavaresgmg

    I hit a related macOS case on a newer Codex Desktop build. Sanitized details below.

    Environment:

    • Codex Desktop: 26.513.31313 / build 2867
    • macOS: 26.5 (25F71)
    • Google Chrome: 148.0.7778.168
    • Chrome plugin: chrome@openai-bundled / 0.1.7
    • Codex Chrome Extension: 1.1.4_0
    • Extension ID: hehggadaopoacecdllhhajmbjkdcmajg
    • Native host: com.openai.codexextension

    Config/runtime signals:

    • ~/.codex/config.toml has [plugins."chrome@openai-bundled"] enabled = true.
    • The Node REPL request metadata advertised x-codex-browser-use-available-backends: ["chrome"].
    • The local config also had [features] browser_use = false; I am not sure whether that is relevant because the turn metadata still advertised the Chrome backend.

    Plugin health checks passed:

    • Chrome was running.
    • check-extension-installed.js --json reported the extension installed, registered, and enabled in the Chrome Default profile.
    • check-native-host-manifest.js --json reported the manifest exists, host name matches, and allowed_origins contains chrome-extension://hehggadaopoacecdllhhajmbjkdcmajg/.
    • The native host process existed and held a /tmp/codex-browser-use/<uuid>.sock.

    Observed failure:

    • Browser bootstrap initially could not acquire the Chrome backend and returned Browser is not available: extension.
    • A direct agent.browsers.list() call returned [] even though the same turn metadata advertised ["chrome"].
    • This happened before page-specific work, so it did not look like a Gmail/site issue.

    Recovery observation:

    • After resetting the JS runtime and re-running the official bundled Chrome browser-client.mjs bootstrap, agent.browsers.list() returned a Chrome backend with type: "extension".
    • After that, agent.browsers.get("extension") succeeded.
    • A direct nodeRepl.fetch("https://chatgpt.com/backend-api/me") returned HTTP 200 JSON in this environment, so my case may not be the exact Cloudflare/ambient-fetch hang from Chrome/browser-use setupAtlasRuntime can hang when ambient /backend-api/me probe does not complete #21704. It still looks like the Chrome backend can be advertised in request metadata while discovery temporarily returns no backend until the JS runtime is reset/rebootstrapped.

    Why I think this belongs here:

    • The local Chrome extension/native-host checks were healthy.
    • The failure was in browser backend discovery/availability, not Chrome installation and not a target website.
    • The successful recovery after JS runtime reset suggests a runtime/bootstrap state issue around the same browser-use/native-pipe path discussed here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbrowserbugSomething isn't workingconnectivityIssues involving networking or endpoint connectivity problems (disconnections)mcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions