Long-lived ChatGPT-auth CLI sessions can stall on codex_apps while fresh sessions load instantly (403 Cloudflare HTML on connectors/apps discovery)
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.0and re-rancodex 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:
- Start Codex CLI using ChatGPT auth
- Keep using the same session for a long time (multiple hours / heavy ongoing work)
- At some point, apps-related startup/initialization paths begin hanging for minutes
- Open a fresh/lightweight new session on the same machine/account/network
- 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:
- #16543
- #16341
- #16618
- #16808
- #17860
- #17880
But this report adds a specific repro pattern: session age matters. Fresh sessions succeed; older long-lived sessions are the ones that degrade.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Additional controlled evidence from
codex-cli 0.144.4on native Ubuntu 26.04 x86_64 (ChatGPT auth).Original failure
``
text
``MCP client for codex_apps failed to start: timed out awaiting tools/list after 30s
-c features.apps=falseremoved the startup delay, so the repository and core model path were not involved.app/list { forceRefetch: true }diagnostic returned JSON-RPC-32603with an HTTP 403 Cloudflare Managed Challenge (Enable JavaScript and cookies to continue). A clean temporaryCODEX_HOMEdid the same.Codex Desktopidentity succeeded. The client-identity experiment below shows that both the clean-home probe and this Mac/Linux comparison were confounded byclientInfo.name; neither should be treated as proof of a Linux TLS-only problem or of a stale-home problem.codex -c features.code_mode_host=true app-server --listen unix://).codex app-server daemon stopexplicitly 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:
codex --no-alt-screenTUI stayed up for more than 35 seconds without the warning;/mcploaded the Apps tool inventory;codex_apps.gmail.get_profilecall 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/BAfter 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/listwithforceRefetch: true), andplatformFamily=unix/platformOs=linux. Onlyinitialize.params.clientInfo.namechanged.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:
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/listis 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:
clientInfo.nameinto the process originator and generated User-Agent;b58952b0fa889f7958af37d057b521f3fdab4d3cis titled "fix: forward originator to Codex Apps MCP". Its description says production showed the downstream Apps MCP identity being lost asCODEX_UNKNOWN_DEFAULT;23a09eb3c3d00ab2a2b96b69aa81454a0a88cca1adds a defaultX-OpenAI-Product-Sku: codexheader for Apps;rust-v0.144.4tag 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/list403 and the TUI's finaltools/listtimeout 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:
tools/listtimeout when the underlying cause is available.clientInfo.namevalues for Apps, or make the documented generic app-server client path work consistently.codex doctorso 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.