openai / openai/codex

codex cli corrupts rollout jsonl during upgrade

Open
#45,150 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI exec session
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.154.0

What subscription do you have?

ChatGPT Pro 5x

Which model were you using?

gpt-5.6-sol

What platform is your computer?

Darwin 23.6.0 arm64 arm

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

Terminal.app

Codex doctor report
{
  "schemaVersion": 1,
  "generatedAt": "1789262198s since unix epoch",
  "overallStatus": "warning",
  "codexVersion": "0.154.0",
  "checks": {
    "app_server.status": {
      "id": "app_server.status",
      "category": "app-server",
      "status": "ok",
      "summary": "background server is not running",
      "details": {
        "control socket": "/Users/satishkumar/.codex/app-server-control/app-server-control.sock",
        "daemon state dir": "/Users/satishkumar/.codex/app-server-daemon",
        "mode": "ephemeral",
        "pid file": "/Users/satishkumar/.codex/app-server-daemon/app-server.pid (missing)",
        "settings": "/Users/satishkumar/.codex/app-server-daemon/settings.json (missing)",
        "status": "not running",
        "update-loop pid file": "/Users/satishkumar/.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 file": "/Users/satishkumar/.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": "/Users/satishkumar/.codex",
        "active thread overrides": "not inspected",
        "config.toml": "/Users/satishkumar/.codex/config.toml",
        "config.toml parse": "ok",
        "configuration load ms": "144",
        "configuration scope": "invocation config, including cloud-managed policy",
        "cwd": "/Users/satishkumar/MyFiles/thiligence-cortex",
        "enabled feature flags": "shell_tool, view_image, sleep_tool, unified_exec, unified_exec_tty, unified_exec_zsh_fork, shell_snapshot, content_item_kinds, code_mode_host, terminal_resize_reflow, sqlite, hooks, enable_request_compression, unbounded_connection_retries, multi_agent, apps, tool_search_always_defer_mcp_tools, tool_suggest, plugins, in_app_browser, in_app_chat, in_app_dictation, in_app_local_automation, in_app_updates, browser_use, browser_use_full_cdp_access, browser_use_external, computer_use, remote_plugin, plugin_sharing, image_generation, resize_all_images, item_ids, skill_mcp_dependency_install, skill_search, mentions_v2, steer, guardian_approval, goals, collaboration_modes, tool_call_mcp_elicitation, auth_elicitation, personality, fast_mode, tui_app_server, remote_compaction_v2, compaction_image_budget, workspace_dependencies",
        "feature flag overrides": "none",
        "feature flags enabled": "48",
        "log dir": "/Users/satishkumar/.codex/log",
        "mcp servers": "6",
        "model": "gpt-5.3-codex-spark",
        "model provider": "openai",
        "sqlite home": "/Users/satishkumar/.codex"
      },
      "remediation": null,
      "durationMs": 1
    },
    "desktop.app.version": {
      "id": "desktop.app.version",
      "category": "desktop",
      "status": "ok",
      "summary": "the desktop application is installed",
      "details": {
        "log directory": "$HOME/Library/Logs/com.openai.codex",
        "running": "false",
        "version": "26.825.51511"
      },
      "remediation": null,
      "durationMs": 0
    },
    "desktop.app_server.handshake": {
      "id": "desktop.app_server.handshake",
      "category": "desktop",
      "status": "ok",
      "summary": "the desktop application is not running",
      "details": {},
      "remediation": null,
      "durationMs": 0
    },
    "desktop.security.enforcement": {
      "id": "desktop.security.enforcement",
      "category": "desktop",
      "status": "ok",
      "summary": "the desktop application passed available macos security assessments",
      "details": {
        "gatekeeper": "accepted"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git executable found; execution not verified",
      "details": {
        ".git entry": "directory",
        "PATH git #1": "/usr/bin/git",
        "PATH git entries": "1",
        "git execution": "not inspected (PATH helpers are not executed)",
        "repo detected": "true",
        "repo root": "/Users/satishkumar/MyFiles/thiligence-cortex",
        "selected git": "/usr/bin/git"
      },
      "remediation": null,
      "durationMs": 1
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "/Users/satishkumar/.nvm/versions/node/v22.22.3/bin/codex",
        "PATH codex #2": "/opt/homebrew/bin/codex",
        "PATH codex entries": "2",
        "current executable": "/Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/bin/codex",
        "install context": "npm (package /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin, bin /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/bin, resources /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/codex-resources, path /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/codex-path)",
        "managed by Vite+": "false",
        "managed by bun": "false",
        "managed by npm": "true",
        "managed by pnpm": "false",
        "managed package root": "/Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex",
        "npm update target": "not inspected (PATH helpers are not executed)"
      },
      "remediation": null,
      "durationMs": 4
    },
    "mcp.config": {
      "id": "mcp.config",
      "category": "mcp",
      "status": "ok",
      "summary": "MCP configuration is locally consistent",
      "details": {
        "configured servers": "6",
        "disabled servers": "1",
        "stdio servers": "5",
        "streamable_http servers": "1"
      },
      "remediation": null,
      "durationMs": 340
    },
    "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",
        "system proxy": "direct"
      },
      "remediation": null,
      "durationMs": 10
    },
    "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)",
        "desktop assets CDN": "https://chatgpt.com/backend-api/<redacted> reachable (HTTP 200)",
        "reachability mode": "ChatGPT auth"
      },
      "remediation": null,
      "durationMs": 449
    },
    "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": 816
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running npm on macos-aarch64",
      "details": {
        "commit": "unknown",
        "current executable": "/Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/bin/codex",
        "install method": "npm (package /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin, bin /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/bin, resources /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/codex-resources, path /Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/codex-path)",
        "platform": "macos-aarch64",
        "version": "0.154.0"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search command found (bundled); execution not verified",
      "details": {
        "search command": "/Users/satishkumar/.nvm/versions/node/v22.22.3/lib/node_modules/@openai/codex/node_modules/@openai/codex-darwin-arm64/vendor/aarch64-apple-darwin/codex-path/rg",
        "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": "OnRequest",
        "codex-linux-sandbox helper": "none",
        "denied-read glob rules": "0",
        "denied-read rules": "0",
        "execve wrapper helper": "/Users/satishkumar/.codex/tmp/arg0/codex-arg0Q52plx/codex-execve-wrapper",
        "filesystem sandbox": "restricted",
        "glob scan max depth": "unbounded",
        "managed filesystem source": "none",
        "network sandbox": "restricted"
      },
      "remediation": null,
      "durationMs": 0
    },
    "security.endpoint": {
      "id": "security.endpoint",
      "category": "security",
      "status": "ok",
      "summary": "no supported endpoint protection detected",
      "details": {
        "endpoint products": "none detected"
      },
      "remediation": null,
      "durationMs": 98
    },
    "state.paths": {
      "id": "state.paths",
      "category": "state",
      "status": "ok",
      "summary": "state paths and databases are inspectable",
      "details": {
        "CODEX_HOME": "/Users/satishkumar/.codex (dir)",
        "active rollout files": "278 files, 2384731987 total bytes, 8578172 average bytes",
        "archived rollout files": "0 files, 0 total bytes, 0 average bytes",
        "goals DB": "/Users/satishkumar/.codex/goals_1.sqlite (file)",
        "goals DB integrity": "ok",
        "log DB": "/Users/satishkumar/.codex/logs_2.sqlite (file)",
        "log DB integrity": "ok",
        "log dir": "/Users/satishkumar/.codex/log (dir)",
        "memories DB": "/Users/satishkumar/.codex/memories_1.sqlite (file)",
        "memories DB integrity": "ok",
        "queue DB": "/Users/satishkumar/.codex/queue_1.sqlite (file)",
        "queue DB integrity": "ok",
        "sqlite home": "/Users/satishkumar/.codex (dir)",
        "state DB": "/Users/satishkumar/.codex/state_5.sqlite (file)",
        "state DB integrity": "ok",
        "thread history DB": "/Users/satishkumar/.codex/thread_history_1.sqlite (file)",
        "thread history DB integrity": "ok"
      },
      "remediation": null,
      "durationMs": 2465
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "warning",
      "summary": "rollout files and state DB thread inventory differ",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "278",
        "rollout DB active rows": "276",
        "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": "2",
        "rollout DB missing active sample": [
          "/Users/satishkumar/.codex/sessions/2026/04/15/rollout-2026-04-15T10-24-05-019d8f7d-46c4-76b0-8ca0-5ddcd5f30193.jsonl",
          "/Users/satishkumar/.codex/sessions/2026/04/15/rollout-2026-04-15T10-25-14-019d8f7e-5576-7302-a267-7ee29d92d82f.jsonl"
        ],
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "openai=276",
        "rollout DB rows": "276",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "subagent:other=80, vscode=71, exec=52, cli=40, subagent:review=29, subagent:thread_spawn=4",
        "rollout DB stale rows": "0"
      },
      "issues": [
        {
          "severity": "warning",
          "cause": "rollout files are missing from the state DB",
          "measured": "2 active, 0 archived",
          "expected": "every rollout file has a matching threads row",
          "remedy": null,
          "fields": []
        }
      ],
      "remediation": null,
      "durationMs": 642
    },
    "system.disk": {
      "id": "system.disk",
      "category": "disk",
      "status": "ok",
      "summary": "sufficient free disk space (70.8 GiB)",
      "details": {
        "CODEX_HOME available": "70.8 GiB",
        "failure threshold": "1.0 GiB",
        "warning threshold": "5.0 GiB",
        "worktree available": "70.8 GiB"
      },
      "remediation": null,
      "durationMs": 2
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language en-US",
      "details": {
        "EDITOR": "not set",
        "LC_CTYPE": "UTF-8",
        "VISUAL": "not set",
        "os": "Mac OS 14.7.4 [64-bit]",
        "os language": "en-US",
        "os type": "Mac OS",
        "os version": "14.7.4"
      },
      "remediation": null,
      "durationMs": 6
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "ok",
      "summary": "terminal metadata was detected",
      "details": {
        "TERM_PROGRAM": "Apple_Terminal",
        "color output": "enabled",
        "effective locale": "UTF-8",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout is terminal": "true",
        "terminal": "Apple Terminal",
        "terminal size": "185x57",
        "terminal version": "453"
      },
      "remediation": null,
      "durationMs": 1
    },
    "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": "thiligence-cortex",
        "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.154.0",
        "check for update on startup": "true",
        "last checked at": "2026-09-12T01:36:11.886220Z",
        "latest version": "0.154.0",
        "latest version status": "current version is not older",
        "npm update target": "not inspected (PATH helpers are not executed)",
        "update action": "npm install -g @openai/codex",
        "version cache": "/Users/satishkumar/.codex/version.json"
      },
      "remediation": null,
      "durationMs": 599
    }
  }
}
What issue are you seeing?

claude cli was invoking "codex exec resume ''" command to review its changes till the time codex signs off. During 19th iteration codex messed up rollout jsonl file that it failed to review the code as it could not resume the session.

Error Reported:
command used: codex resume 01a09341-f5f7-74f1-aa57-68067ca99805

Error:
Error: Failed to resume session from /Users/satishkumar/.codex/sessions/2026/09/12/rollout-2026-09-12T07-06-08-01a09341-f5f7-74f1-aa57-68067ca99805.jsonl: thread/resume failed during
TUI bootstrap: thread/resume failed: error resuming thread: Fatal error: Failed to initialize session: thread-store internal error: failed to resume local thread recorder: final
paginated rollout record at /Users/satishkumar/.codex/sessions/2026/09/12/rollout-2026-09-12T07-06-08-01a09341-f5f7-74f1-aa57-68067ca99805.jsonl is missing an ordinal (code -32603)

How I fixed it:

Root cause confirmed

The command is valid; codex resume <SESSION_ID> is the documented syntax. Official Codex command reference (https://developers.openai.com/codex/cli/reference)

The session’s rollout JSONL (/Users/satishkumar/.codex/sessions/2026/09/12/rollout-2026-09-12T07-06-08-01a09341-f5f7-74f1-aa57-68067ca99805.jsonl:4453) is structurally inconsistent:

  • Lines 1–4452 are valid paginated records. The last ordinal is 4448.
  • Lines 4453–4457 form an unanswered “Round 19” turn.
  • All five tail records lack the required top-level ordinal.
  • The final record is therefore a complete JSON object, but invalid for a paginated rollout. It is not ordinary file truncation.

The likely trigger was upgrading Codex while this session was being resumed:

  • Session created with Codex 0.153.4.
  • Last healthy turn completed at 06:23:55 UTC.
  • Global installation of 0.154.0 began at 06:26:17 UTC.
  • A new Codex invocation/turn began at 06:26:28 UTC, while the installation was completing.
  • The five ordinal-free records were written from 06:26:28 through 06:26:36.

This points to an upgrade/resume race or cross-version recorder bug. It is isolated: I checked 34 paginated sessions, and this was the only one whose final record lacked an ordinal.
The 0.154.0 release also contained resume/history-related changes, although its official changelog (https://learn.chatgpt.com/docs/changelog) does not list this particular defect.

Verified recovery

I tested a disposable copy after removing only lines 4453–4457. Codex 0.154.0 resumed it successfully, including the previous completed turn. No SQLite changes were needed.

Safe recovery commands:

session="/Users/satishkumar/.codex/sessions/2026/09/12/rollout-2026-09-12T07-06-08-01a09341-f5f7-74f1-aa57-68067ca99805.jsonl"

cp -p "$session" "$session.bak-20260912"
repair_file=$(mktemp "${session}.repair.XXXXXX")
head -n 4452 "$session" > "$repair_file"
mv "$repair_file" "$session"

codex resume 01a09341-f5f7-74f1-aa57-68067ca99805

Stop any process currently using that session before running these commands. The unanswered Round 19 prompt will be removed and should be resubmitted after resuming; it remains
available in the backup.

I did not modify the original session. I deleted only the disposable /private/tmp test copies; those temporary copies are not recoverable.

What steps can reproduce the bug?

It reproduced during invocation of codex exec resume 'prompt' command. It offered upgrade post which neither I or claude could resume the session as rollout jsonl was corrupted. Upgrade has to be offered to reproduce the step.

What is the expected behavior?

Session shall be resumed instead of this error:
Error: Failed to resume session from /Users/satishkumar/.codex/sessions/2026/09/12/rollout-2026-09-12T07-06-08-01a09341-f5f7-74f1-aa57-68067ca99805.jsonl: thread/resume failed during
TUI bootstrap: thread/resume failed: error resuming thread: Fatal error: Failed to initialize session: thread-store internal error: failed to resume local thread recorder: final
paginated rollout record at /Users/satishkumar/.codex/sessions/2026/09/12/rollout-2026-09-12T07-06-08-01a09341-f5f7-74f1-aa57-68067ca99805.jsonl is missing an ordinal (code -32603)

Additional information

No response

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

Start with the state.paths doctor check and the active rollout files under CODEX_HOME, then reproduce the upgrade from codex-cli 0.154.0 on macOS. Determine when the rollout JSONL becomes invalid during the upgrade; done means existing rollout files remain valid and readable afterward, with a regression test covering the failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.