openai / openai/codex

GPT-6 Astra: WebSocket reconnect loop continuously consumes purchased credits until HTTPS fallback

Open
#43,045 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI connectivity exec rate-limits
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

codex-cli 0.153.4

What subscription do you have?

ChatGPT Plus with purchased Codex credits

Which model were you using?

gpt-6-astra

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

VS Code

Codex doctor report
{
  "schemaVersion": 1,
  "generatedAt": "1788623592s since unix epoch",
  "overallStatus": "warning",
  "codexVersion": "0.153.4",
  "checks": {
    "app_server.status": {
      "id": "app_server.status",
      "category": "app-server",
      "status": "ok",
      "summary": "background server is not running",
      "details": {
        "control socket": "C:\\Users\\okamo\\.codex\\app-server-control\\app-server-control.sock",
        "daemon state dir": "C:\\Users\\okamo\\.codex\\app-server-daemon",
        "mode": "ephemeral",
        "pid file": "C:\\Users\\okamo\\.codex\\app-server-daemon\\app-server.pid (missing)",
        "settings": "C:\\Users\\okamo\\.codex\\app-server-daemon\\settings.json (missing)",
        "status": "not running",
        "update-loop pid file": "C:\\Users\\okamo\\.codex\\app-server-daemon\\app-server-updater.pid (missing)"
      },
      "remediation": null,
      "durationMs": 0
    },
    "auth.credentials": {
      "id": "auth.credentials",
      "category": "auth",
      "status": "ok",
      "summary": "auth is configured",
      "details": {
        "auth env vars present": "OPENAI_API_KEY",
        "auth file": "C:\\Users\\okamo\\.codex\\auth.json",
        "auth storage mode": "File",
        "stored API key": "false",
        "stored ChatGPT tokens": "true",
        "stored agent identity": "false",
        "stored auth mode": "chatgpt"
      },
      "remediation": null,
      "durationMs": 0
    },
    "config.load": {
      "id": "config.load",
      "category": "config",
      "status": "ok",
      "summary": "config loaded",
      "details": {
        "CODEX_HOME": "C:\\Users\\okamo\\.codex",
        "config.toml": "C:\\Users\\okamo\\.codex\\config.toml",
        "config.toml parse": "ok",
        "cwd": "C:\\repository\\auto-codex",
        "enabled feature flags": "<redacted>",
        "feature flag overrides": "none",
        "feature flags enabled": "48",
        "log dir": "C:\\Users\\okamo\\.codex\\log",
        "mcp servers": "1",
        "model": "gpt-6-astra",
        "model provider": "openai",
        "sqlite home": "C:\\Users\\okamo\\.codex"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git version 2.40.0.windows.1",
      "details": {
        ".git entry": "directory",
        "PATH git #1": "C:\\Program Files\\Git\\cmd\\git.exe",
        "PATH git entries": "1",
        "git branch": "_c/20260905-1",
        "git build options": "git version 2.40.0.windows.1; cpu: x86_64; built from commit: 1d90ca2906dd4b7ddaf0669a13c173ec579d794a; sizeof-long: 4; sizeof-size_t: 8; shell-path: /bin/sh; feature: fsmonitor--daemon",
        "git exec path": "C:/Program Files/Git/mingw64/libexec/git-core",
        "git version": "git version 2.40.0.windows.1",
        "repo detected": "true",
        "repo root": "C:\\repository\\auto-codex",
        "selected git": "C:\\Program Files\\Git\\cmd\\git.exe"
      },
      "remediation": null,
      "durationMs": 51
    },
    "git.worktree.dev_drive": {
      "id": "git.worktree.dev_drive",
      "category": "git",
      "status": "warning",
      "summary": "this worktree is not on a Windows Dev Drive; moving it to a trusted Dev Drive can significantly improve repository and filesystem performance",
      "details": {},
      "remediation": "create a trusted Windows Dev Drive for source repositories: https://learn.microsoft.com/en-us/<redacted>",
      "durationMs": 0
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\codex",
        "PATH codex #2": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\codex.cmd",
        "PATH codex entries": "2",
        "current executable": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\bin\\codex.exe",
        "install context": "npm (package C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc, bin C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\bin, resources C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\codex-resources, path C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\codex-path)",
        "managed by Vite+": "false",
        "managed by bun": "false",
        "managed by npm": "true",
        "managed by pnpm": "false",
        "managed package root": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex",
        "npm update target": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex"
      },
      "remediation": null,
      "durationMs": 131
    },
    "mcp.config": {
      "id": "mcp.config",
      "category": "mcp",
      "status": "ok",
      "summary": "MCP configuration is locally consistent",
      "details": {
        "configured servers": "1",
        "disabled servers": "0",
        "streamable_http servers": "1"
      },
      "remediation": null,
      "durationMs": 93
    },
    "network.env": {
      "id": "network.env",
      "category": "network",
      "status": "ok",
      "summary": "network-related environment looks readable",
      "details": {
        "managed proxy": "not configured",
        "proxy env vars": "none",
        "respect system proxy": "disabled"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.provider_reachability": {
      "id": "network.provider_reachability",
      "category": "reachability",
      "status": "ok",
      "summary": "active provider endpoints are reachable over HTTP",
      "details": {
        "ChatGPT inference URL": "https://chatgpt.com/backend-api/<redacted> reachable (HTTP 405)",
        "reachability mode": "ChatGPT auth"
      },
      "remediation": null,
      "durationMs": 91
    },
    "network.websocket_reachability": {
      "id": "network.websocket_reachability",
      "category": "websocket",
      "status": "ok",
      "summary": "Responses WebSocket handshake succeeded",
      "details": {
        "DNS": "2 IPv4, 2 IPv6, first IPv6",
        "auth mode": "chatgpt",
        "connect timeout": "15000 ms",
        "endpoint": "wss://chatgpt.com/backend-api/<redacted>",
        "handshake result": "HTTP 101 Switching Protocols",
        "model provider": "openai",
        "provider name": "OpenAI",
        "proxy env vars": "none",
        "reasoning header": "false",
        "server model present": "false",
        "supports websockets": "true",
        "wire API": "responses"
      },
      "remediation": null,
      "durationMs": 835
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running npm on windows-x86_64",
      "details": {
        "commit": "unknown",
        "current executable": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\bin\\codex.exe",
        "install method": "npm (package C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc, bin C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\bin, resources C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\codex-resources, path C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\codex-path)",
        "platform": "windows-x86_64",
        "version": "0.153.4"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search is OK (bundled)",
      "details": {
        "search command": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\codex-path\\rg.exe",
        "search command readiness": "file exists",
        "search provider": "bundled"
      },
      "remediation": null,
      "durationMs": 0
    },
    "sandbox.helpers": {
      "id": "sandbox.helpers",
      "category": "sandbox",
      "status": "ok",
      "summary": "sandbox configuration is readable",
      "details": {
        "approval policy": "Never",
        "codex-linux-sandbox helper": "none",
        "denied-read restrictions": "false",
        "execve wrapper helper": "none",
        "filesystem sandbox": "unrestricted",
        "network sandbox": "enabled",
        "sandbox backend": "<redacted>"
      },
      "remediation": null,
      "durationMs": 0
    },
    "security.endpoint": {
      "id": "security.endpoint",
      "category": "security",
      "status": "warning",
      "summary": "endpoint protection detected; Codex exclusions are unverified",
      "details": {
        "Codex exclusions": "not verified",
        "endpoint products": "Microsoft Defender",
        "exclusion targets": "signed Codex app; codex.exe; codex-windows-sandbox-setup.exe; codex-command-runner.exe; codex-code-mode-host.exe" 
      },
      "issues": [
        {
          "severity": "warning",
          "cause": "Microsoft Defender can interfere with Codex. Verify Codex exclusions.",
          "measured": "not verified",
          "expected": "Codex application and helper exclusions",
          "remedy": "Microsoft Defender: Add a certificate or executable-path exclusion for Codex and its helpers. If Attack Surface Reduction blocks Codex, add a rule exclusion. If Controlled Folder Access blocks Codex, allow the app.",
          "fields": [
            "Codex exclusions"
          ]
        }
      ],
      "remediation": "ask your security administrator to verify Codex exclusions and required helper allowances",
      "durationMs": 11
    },
    "state.paths": {
      "id": "state.paths",
      "category": "state",
      "status": "ok",
      "summary": "state paths and databases are inspectable",
      "details": {
        "CODEX_HOME": "C:\\Users\\okamo\\.codex (dir)",
        "active rollout files": "3546 files, 2411753571 total bytes, 680133 average bytes",
        "archived rollout files": "0 files, 0 total bytes, 0 average bytes",
        "goals DB": "C:\\Users\\okamo\\.codex\\goals_1.sqlite (file)",
        "goals DB integrity": "ok",
        "log DB": "C:\\Users\\okamo\\.codex\\logs_2.sqlite (file)",
        "log DB integrity": "ok",
        "log dir": "C:\\Users\\okamo\\.codex\\log (dir)",
        "memories DB": "C:\\Users\\okamo\\.codex\\memories_1.sqlite (file)",
        "memories DB integrity": "ok",
        "queue DB": "C:\\Users\\okamo\\.codex\\queue_1.sqlite (file)",
        "queue DB integrity": "ok",
        "sqlite home": "C:\\Users\\okamo\\.codex (dir)",
        "state DB": "C:\\Users\\okamo\\.codex\\state_5.sqlite (file)",
        "state DB integrity": "ok",
        "thread history DB": "C:\\Users\\okamo\\.codex\\thread_history_1.sqlite (file)",
        "thread history DB integrity": "ok"
      },
      "remediation": null,
      "durationMs": 181
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "ok",
      "summary": "rollout files and state DB thread inventory agree",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "3546",
        "rollout DB active rows": "3546",
        "rollout DB archive mismatches": "0",
        "rollout DB archived files": "0",
        "rollout DB archived rows": "0",
        "rollout DB duplicate DB paths": "0",
        "rollout DB duplicate rollout thread ids": "0",
        "rollout DB malformed file names": "0",
        "rollout DB missing active rows": "0",
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "openai=3511, amazon-bedrock=35",
        "rollout DB rows": "3546",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "exec=3443, cli=93, subagent:thread_spawn=9, vscode=1",
        "rollout DB stale rows": "0"
      },
      "remediation": null,
      "durationMs": 20384
    },
    "system.disk": {
      "id": "system.disk",
      "category": "disk",
      "status": "ok",
      "summary": "sufficient free disk space (679.4 GiB)",
      "details": {
        "CODEX_HOME available": "679.4 GiB",
        "failure threshold": "1.0 GiB",
        "warning threshold": "5.0 GiB",
        "worktree available": "679.4 GiB"
      },
      "remediation": null,
      "durationMs": 0
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language ja-JP",
      "details": {
        "EDITOR": "not set",
        "LANG": "ja_JP.UTF-8",
        "VISUAL": "not set",
        "os": "Windows 10.0.26200 (Windows 11 Core) [64-bit]",
        "os language": "ja-JP",
        "os type": "Windows",
        "os version": "10.0.26200"
      },
      "remediation": null,
      "durationMs": 0
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "warning",
      "summary": "height 22 rows - content may scroll off (recommended >=24)",
      "details": {
        "COLORTERM": "truecolor",
        "TERM_PROGRAM": "vscode",
        "VSCODE_INJECTION": "present",
        "color output": "enabled",
        "console input code page": "932",
        "console output code page": "932",
        "effective locale": "ja_JP.UTF-8",
        "stderr console mode": "0x00000007 (VT processing: true)",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout console mode": "0x00000007 (VT processing: true)",
        "stdout is terminal": "true",
        "terminal": "VS Code",
        "terminal size": "144x22",
        "terminal version": "1.109.0"
      },
      "issues": [
        {
          "severity": "warning",
          "cause": "height 22 rows - content may scroll off (recommended >=24)",
          "measured": "144 x 22",
          "expected": ">= 24 rows",
          "remedy": "resize the window to at least 24 rows",
          "fields": [
            "terminal size"
          ]
        }
      ],
      "remediation": null,
      "durationMs": 0
    },
    "terminal.title": {
      "id": "terminal.title",
      "category": "title",
      "status": "ok",
      "summary": "terminal title default",
      "details": {
        "terminal title activity": "true",
        "terminal title items": "activity, project-name",
        "terminal title project source": "git repo root",
        "terminal title project value": "auto-codex",
        "terminal title source": "default"
      },
      "remediation": null,
      "durationMs": 0
    },
    "updates.status": {
      "id": "updates.status",
      "category": "updates",
      "status": "ok",
      "summary": "update configuration is locally consistent",
      "details": {
        "cached latest version": "0.153.4",
        "check for update on startup": "true",
        "last checked at": "2026-09-05T02:14:21.973748600Z",
        "latest version": "0.153.4",
        "latest version status": "current version is not older",
        "npm update target": "C:\\Users\\okamo\\AppData\\Roaming\\npm\\node_modules\\@openai\\codex",
        "update action": "npm install -g @openai/codex",
        "version cache": "C:\\Users\\okamo\\.codex\\version.json"
      },
      "remediation": null,
      "durationMs": 299
    }
  }
}
What issue are you seeing?

Since switching to GPT-6 Astra, Codex CLI frequently enters a WebSocket reconnection loop during codex exec.

The following messages are repeatedly displayed:

ERROR: Reconnecting... 2/5
ERROR: Reconnecting... 2/5
ERROR: Reconnecting... 3/5
ERROR: Reconnecting... 4/5
ERROR: Reconnecting... 5/5
warning: Falling back from WebSockets to HTTPS transport. stream disconnected before completion: idle timeout waiting for websocket

Once this happens, Codex can remain in the reconnect loop for approximately 10 minutes before finally falling back from WebSockets to HTTPS.

The serious problem is that purchased Codex credits continue to be consumed while Codex is stuck in the reconnect loop.

In my observations, approximately 3 credits are consumed every 10 seconds during the reconnect loop, even though no useful output is being produced and no files are being modified.

This means a single ~10-minute reconnect incident can potentially consume a very large number of purchased credits without making any visible progress.

After the retries finally reach 5/5 and Codex prints:

warning: Falling back from WebSockets to HTTPS transport.

the behavior changes immediately: Codex starts producing output and modifying/generating files normally over the HTTPS transport.

The observed sequence is:

GPT-6 Astra starts a task
    ↓
WebSocket becomes idle/disconnected
    ↓
Reconnecting... 1/5 ... 5/5
    ↓
Purchased credits continuously decrease
    ↓
No useful progress for ~10 minutes
    ↓
Codex falls back to HTTPS
    ↓
The task immediately starts progressing normally
How I am monitoring the credit consumption

This issue is easiest to observe after the included 5-hour or weekly usage limit has already been exhausted, so that subsequent usage is charged against purchased Codex credits.

I am specifically monitoring the purchased credit balance, not estimating consumption from the 5-hour/weekly percentage shown by Codex CLI.

There is an important difference between the two monitoring methods:

Codex CLI /status

Running /status during the reconnect loop does not show the purchased credit balance decreasing.

From the CLI's perspective, nothing visibly changes while the reconnect loop is occurring.

Therefore, /status does not expose the credit consumption described in this report.

ChatGPT Codex usage page

Instead, I monitor the purchased credit balance using the official Codex usage page:

https://chatgpt.com/codex/settings/usage

While ERROR: Reconnecting... is repeatedly displayed in the terminal, refreshing the usage page shows the purchased credit balance continuously decreasing.

I observe approximately:

~3 purchased credits consumed every ~10 seconds

during the reconnect loop.

This continues even though:

  • Codex is only displaying ERROR: Reconnecting...
  • no useful model output is appearing
  • no files are being modified/generated
  • /status does not indicate any corresponding change
  • the task does not appear to make useful progress

The correlation is especially noticeable because the rapid credit consumption stops once the WebSocket retry loop ends and Codex falls back to HTTPS, at which point normal task progress resumes.

Therefore, the reproduction/measurement procedure is:

  1. Exhaust the included 5-hour or weekly Codex usage allowance so that purchased credits are being used.
  2. Ensure the account has a purchased Codex credit balance.
  3. Open the official usage page and note the current purchased credit balance:
    https://chatgpt.com/codex/settings/usage
  4. Start a task using GPT-6 Astra (medium) with codex exec.
  5. Wait until Codex enters the WebSocket reconnect loop.
  6. While ERROR: Reconnecting... x/5 is displayed, periodically refresh the official usage page.
  7. Observe the purchased credit balance decreasing approximately every 10 seconds.
  8. At the same time, observe that Codex is producing no useful output or file modifications.
  9. Optionally run /status; it does not show this purchased-credit depletion.
  10. Wait until Codex reaches 5/5 and falls back to HTTPS.
  11. Observe that the task then immediately begins making normal progress.

This makes the unexpected consumption directly observable from OpenAI's own usage page rather than being inferred from local token counts or the CLI /status display.

What steps can reproduce the bug?
  1. Use an account where the included 5-hour or weekly Codex usage limit has been exhausted and purchased credits are now being consumed.
  2. Note the purchased credit balance at https://chatgpt.com/codex/settings/usage.
  3. Use GPT-6 Astra with medium reasoning.
  4. Run a relatively long task using codex exec.
  5. Wait until the WebSocket stream hits an idle timeout.
  6. Observe repeated ERROR: Reconnecting... x/5 messages.
  7. Refresh the Codex usage page periodically while the reconnect loop is running.
  8. Observe that purchased credits continue decreasing, approximately 3 credits every 10 seconds in my case, even though the task is making no visible progress.
  9. After 5/5, Codex falls back to HTTPS.
  10. Observe that normal task execution then immediately resumes.
What is the expected behavior?

A transport-level WebSocket failure should not repeatedly consume significant purchased Codex credits.

In particular, retrying a failed transport should not cause repeated billable model inference for the same unfinished turn.

Ideally:

  1. A failed WebSocket connection should fall back to HTTPS/SSE quickly.
  2. Transport retries should not create new billable inference requests unnecessarily.
  3. If repeating the model request is unavoidable, Codex should not automatically perform multiple expensive retries without warning the user.
  4. Failed/retried requests should not repeatedly charge purchased credits when no useful response is delivered.
  5. There should be an option to disable WebSockets entirely and use HTTPS/SSE from the beginning.

For example:

codex exec --transport https

or an equivalent configuration option.

Additional information

The most important part of this issue is not simply that WebSockets are unstable.

The critical issue is:

Purchased Codex credits are continuously depleted while Codex is stuck in an automatic WebSocket reconnect loop, despite no useful work being produced.

This is directly observable by refreshing the official Codex usage page while the reconnect loop is occurring.

With GPT-6 Astra, the rate of consumption can be substantial. At approximately 3 credits every 10 seconds, a reconnect loop lasting around 10 minutes could consume roughly 180 purchased credits while apparently making no useful progress.

Once Codex gives up on WebSockets and switches to HTTPS, the same task begins working normally.

Related discussion about forcing HTTPS transport:

https://github.com/openai/codex/issues/27381#issuecomment-5514150210

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce on Windows with Codex CLI 0.153.4, model gpt-6-astra, and ChatGPT authentication, focusing on the WebSocket reconnect path and HTTPS fallback described in the report. Trace how failed WebSocket attempts trigger requests and verify that completion stops retries without consuming additional credits before falling back to HTTPS.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.