Skip to content

Long-lived ChatGPT-auth CLI sessions can stall on codex_apps while fresh sessions load instantly (403 Cloudflare HTML on connectors/apps discovery) #19284

Open

Description

@GigiTiti-Kai

Description

I am seeing a session-age-dependent startup degradation on Codex CLI with ChatGPT login.

Fresh/lightweight sessions on the same machine/account/network initialize apps/MCP quickly, but long-lived sessions can stall for minutes showing:

Starting MCP servers (2/3): codex_apps

When that happens, local logs show apps/connectors discovery failing with 403 Forbidden and a Cloudflare challenge HTML page instead of JSON.

This does not appear to be a broken local install:

  • fresh sessions work immediately on the same machine/account/network
  • I upgraded to codex-cli 0.124.0 and re-ran codex logout / codex login
  • the problem still reproduces only on long-lived sessions

Environment

  • Codex CLI: 0.124.0
  • Auth mode: ChatGPT login (not API key)
  • Platform: WSL2 Linux
  • Kernel: Linux KAI 6.6.87.2-microsoft-standard-WSL2 x86_64
  • Node: v24.12.0
  • npm: 11.13.0

What I observe

Fresh / lightweight session

  • starts normally
  • apps/connectors load essentially immediately

Long-lived session

  • can hang for minutes at Starting MCP servers (2/3): codex_apps
  • local logs show full apps list load failing and falling back
  • the failing response is Cloudflare challenge HTML from chatgpt.com/backend-api/..., not JSON

Representative local evidence:

failed to load full apps list; falling back to installed apps snapshot: Failed to load apps: Request failed with status 403 Forbidden: <html>

The returned HTML includes the Cloudflare challenge text:

Enable JavaScript and cookies to continue

One failing path I captured locally was:

/backend-api//connectors/directory/list?external_logos=true

I also observed the same general Cloudflare/403 symptom family discussed in other issues, but the important isolation detail here is that a fresh new CLI session works immediately while the older long-running session degrades into this state.

Steps to reproduce

I do not have a tiny deterministic repro yet, but this is the pattern I can reproduce repeatedly:

  1. Start Codex CLI using ChatGPT auth
  2. Keep using the same session for a long time (multiple hours / heavy ongoing work)
  3. At some point, apps-related startup/initialization paths begin hanging for minutes
  4. Open a fresh/lightweight new session on the same machine/account/network
  5. Observe that the fresh session initializes apps immediately

Expected behavior

If apps/connectors discovery is blocked or challenged, Codex CLI should fail open quickly (or skip that discovery path) instead of looking hung on codex_apps. Also, long-lived sessions should not degrade this way while fresh sessions on the same machine still work.

Related issues

This looks related to the broader Cloudflare challenge / app discovery family, especially:

But this report adds a specific repro pattern: session age matters. Fresh sessions succeed; older long-lived sessions are the ones that degrade.

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    connectivityIssues involving networking or endpoint connectivity problems (disconnections)
    authIssues related to authentication and accounts
    on Apr 24, 2026
  2. qixuancao commented on Jul 15, 2026

    @qixuancao

    Additional controlled evidence from codex-cli 0.144.4 on native Ubuntu 26.04 x86_64 (ChatGPT auth).

    Original failure

    • The default TUI consistently reported:

      MCP client for codex_apps failed to start: timed out awaiting tools/list after 30s
      
    • Core Codex/model calls continued to work, and -c features.apps=false removed the startup delay, so the repository and core model path were not involved.

    • During the failure window, a separate app/list { forceRefetch: true } diagnostic returned JSON-RPC -32603 with an HTTP 403 Cloudflare Managed Challenge (Enable JavaScript and cookies to continue). A clean temporary CODEX_HOME did the same.

    • A same-account/same-egress Mac control using the real Codex Desktop identity succeeded. The client-identity experiment below shows that both the clean-home probe and this Mac/Linux comparison were confounded by clientInfo.name; neither should be treated as proof of a Linux TLS-only problem or of a stale-home problem.

    • The failing shared server was an unmanaged, code-mode-host-launched process (codex -c features.code_mode_host=true app-server --listen unix://). codex app-server daemon stop explicitly reported that it was not daemon-managed.

    Recovery after a Codex-only restart

    I terminated all Codex/TUI/app-server processes and their MCP children, without rebooting Ubuntu. I then started a CLI-managed app-server with codex app-server daemon start.

    Afterward:

    • a standard codex --no-alt-screen TUI stayed up for more than 35 seconds without the warning;
    • /mcp loaded the Apps tool inventory;
    • a real read-only codex_apps.gmail.get_profile call completed successfully (no profile data was retained or included here).

    This proves the failure is recoverable on the same Linux binary. The restart also changed the app-server launch/identity path (unmanaged code-mode-host server to CLI-managed daemon), so this is not evidence that clearing memory alone fixed it.

    Reproducible clientInfo.name / generated User-Agent A/B

    After recovery, I used a small stdio app-server client. Every run used the same Linux host, account, token, network path, clean temporary CODEX_HOME, binary, request (app/list with forceRefetch: true), and platformFamily=unix / platformOs=linux. Only initialize.params.clientInfo.name changed.

    Alternating A/B results:

    clientInfo.name Result Repeats Typical latency
    codex_cli HTTP 403 Managed Challenge 3/3 0.66-0.74 s
    codex_vscode Success 3/3 3.4-14.5 s

    Additional checks:

    clientInfo.name Result
    codex_cli_rs Success
    Codex Desktop Success
    codex_desktop HTTP 403 Managed Challenge
    codex-tui HTTP 403 Managed Challenge
    codex_tui HTTP 403 Managed Challenge
    my_product (the public app-server manual's example name) HTTP 403 Managed Challenge

    The initialize response confirms that the name is embedded in the generated upstream User-Agent, for example:

    codex_cli/0.144.4 (Ubuntu 26.4.0; x86_64) ...
    codex_vscode/0.144.4 (Ubuntu 26.4.0; x86_64) ...
    

    This does not establish whether the decision is an intended known-client allowlist, a WAF rule, or another server-side policy. It does establish that, on the same Linux host and at the same time, app/list is sensitive to the client identity/derived User-Agent rather than Linux/TLS alone. If arbitrary clients are not allowed to access Apps, the app-server should return an explicit authorization/unsupported-client error rather than a Cloudflare browser challenge.

    Highly relevant fixes already merged after 0.144.4

    Public source explains why the launch/identity change matters:

    • app-server initialization copies clientInfo.name into the process originator and generated User-Agent;
    • PR fix: forward originator to Codex Apps MCP #31481 / commit b58952b0fa889f7958af37d057b521f3fdab4d3c is titled "fix: forward originator to Codex Apps MCP". Its description says production showed the downstream Apps MCP identity being lost as CODEX_UNKNOWN_DEFAULT;
    • PR fix(mcp): default Apps product SKU to codex #31803 / commit 23a09eb3c3d00ab2a2b96b69aa81454a0a88cca1 adds a default X-OpenAI-Product-Sku: codex header for Apps;
    • neither commit is present in the rust-v0.144.4 tag used here.

    This makes missing/misforwarded Apps request identity the strongest current explanation for the original 0.144.4 failure and for why switching from an unmanaged code-mode-host app-server to a CLI-managed daemon restored it. The Cloudflare policy is server-side, so I cannot prove from public source which header or classification produced the challenge.

    The direct app/list 403 and the TUI's final tools/list timeout were observed in the same Apps failure investigation, but I have not proved they are the same HTTP request or retry chain.

    Related: #17860. That issue's Linux/rustls-only hypothesis is not sufficient to explain the identity-dependent A/B above.

    Suggested fixes:

    1. Backport or release the originator/SKU fixes from fix: forward originator to Codex Apps MCP #31481 and fix(mcp): default Apps product SKU to codex #31803 to the stable CLI.
    2. Preserve actionable Apps/Connectors failure details in diagnostics instead of only reporting a 30-second tools/list timeout when the underlying cause is available.
    3. Document and validate accepted clientInfo.name values for Apps, or make the documented generic app-server client path work consistently.
    4. Add an Apps/Connectors probe to codex doctor so this failure is distinguishable from core auth/model health.

    I intentionally did not attach raw auth files, tokens, account identifiers, IP addresses, or the full Cloudflare HTML response.

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

    authIssues related to authentication and accountsbugSomething isn't workingconnectivityIssues involving networking or endpoint connectivity problems (disconnections)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions