Skip to content

Shared models_cache.json oscillates between originator-specific catalogs across app-server processes #33593

Open

Description

@nerdchanii

What version of Codex CLI is running?

codex-cli 0.144.5

What subscription do you have?

ChatGPT authentication. The exact subscription tier is not relevant to the
reproduction.

Which model were you using?

gpt-5.6-sol

What platform is your computer?

macOS 26.5.2, Darwin 25.5.0, Apple Silicon.

What issue are you seeing?

Two long-lived app-server processes built from the exact same Codex binary and using the same CODEX_HOME, provider, auth mode, and ChatGPT account receive different model catalogs when only their app-server originator differs.

Both processes persist their originator-specific response to the same global $CODEX_HOME/models_cache.json. The file therefore alternates between two
valid, but semantically incompatible, catalogs:

  • Codex Desktop / codex_cli_rs: gpt-5.6-sol has
    multi_agent_version = v1 and tool_mode = direct.
  • codex-chrome-extension-sidepanel: the same model has
    multi_agent_version = v2 and tool_mode = code_mode_only.

The app-server background refresh worker repeats the overwrite approximately
every three minutes. Depending on which process wrote last, newly started
sessions and runtime metadata consumers can see a different multi-agent/tool
configuration.

This is not a corrupt server response and is not explained by a CLI version,
provider, or account mismatch. It is a cache-identity and cross-process storage
problem.

Confirmed A/B measurements

The two app-server processes had:

  • the same executable SHA-256;
  • Codex CLI 0.144.5;
  • the same CODEX_HOME, auth file, provider, token, account, request URL, and
    User-Agent;
  • different app-server client identities/originators.

Direct /models?client_version=0.144.5 requests changing only originator
returned:

Originator Models ETag Sol multi-agent Sol tool mode
Codex Desktop W/"6cbd9267ee12889ea6614486cc5879ff" v1 direct
codex_cli_rs W/"6cbd9267ee12889ea6614486cc5879ff" v1 direct
codex-chrome-extension-sidepanel W/"68e28197d956a749f12435108b07ff25" v2 code_mode_only

Observed cache writes included:

Time (UTC) Writer Request ID Result
11:33:36 Codex Desktop 25cc13a9-0991-4bc8-a5e6-ed9a125bd759 V1/direct catalog written
11:34:03 Chrome sidepanel bb12724f-9a1d-4ef3-a256-1fa3c9fe3b1e V2/code-mode catalog written
about 3 minutes later Chrome sidepanel cfaa5c42-34e5-4600-8e1e-73df23bb9132 the alternating pattern repeated

No token, account identifier, raw session transcript, or auth file is included
in this report.

What steps can reproduce the bug?

Reproduction A: two app-server clients

  1. Use one Codex binary, one CODEX_HOME, and one ChatGPT account.
  2. Start app-server A and initialize it with
    clientInfo.name = "Codex Desktop".
  3. Start app-server B and initialize it with
    clientInfo.name = "codex-chrome-extension-sidepanel".
  4. Request the model catalog from both processes.
  5. Record the request originator, ETag, and the gpt-5.6-sol fields
    multi_agent_version, tool_mode, and use_responses_lite.
  6. Observe that the server returns different ETags/catalog metadata.
  7. Observe both processes writing to the same
    $CODEX_HOME/models_cache.json.
  8. Wait for multiple app-server refresh intervals and observe the file
    alternating again.

Reproduction B: Desktop plus Chrome extension

  1. Fully quit ChatGPT Desktop and Chrome.
  2. Start ChatGPT Desktop and create a Codex task.
  3. Record app-server ancestry, initialize identity, /models originator, ETag,
    and the cache hash/content.
  4. Start Chrome and open the ChatGPT extension side panel.
  5. Confirm that the extension's native host starts another Codex app-server.
  6. Record the same data and monitor models_cache.json.
  7. Close only the side panel, then Chrome, and repeat to determine the precise
    native-host lifecycle.

In the observed run, the second app-server was a child of the ChatGPT for
Chrome native extension host, not a browser tab merely visiting chatgpt.com.

Reproduction C: deterministic regression test

Use two model managers sharing one temporary CODEX_HOME. Mock /models so
the same provider/account/version returns catalog A for originator A and
catalog B for originator B. Alternate online refreshes, drop both managers,
recreate them offline, and verify that each surface can recover its own
catalog. Current single-file behavior cannot preserve both.

Root cause

The request identity and cache identity do not match.

/models uses the app-server originator, and the service can return a different
catalog and ETag for each client surface. The persisted cache is nevertheless a
single global file. Cache eligibility on current main does not include
originator/client surface, and the file is last-writer-wins.

There are three interacting layers:

  1. Semantic isolation: originator-specific catalogs share one cache slot.
  2. Cross-process coordination: independent app-servers have separate
    in-memory ETag/catalog state but overwrite the same disk file.
  3. Write safety/amplification: the cache is rewritten as a complete file,
    including matching-ETag TTL renewal, without a per-identity slot. Related
    reports also show truncated/EOF reads and excessive write churn.

The app-server refresh worker makes the latent design issue persistent: each
long-lived process refreshes immediately and then approximately every three
minutes.

How the code reached this state

Related reports:

The last distinction matters: cache isolation explains why a surface/session
can unexpectedly receive V1 versus V2 metadata. If the server intentionally
returns V1/Responses Lite to a surface, #32086 still needs its own fix.

What is the expected behavior?

Different catalog identities must not overwrite or reuse one another's model
metadata. A client surface should consistently receive and recover the catalog
that was fetched for its own request identity, including after process restart
or while temporarily offline.

Suggested fix

Treat the catalog scope as a first-class identity derived from the same
snapshot used to make the request:

provider_id
endpoint identity/fingerprint
effective auth mode
account/principal
exact originator/client surface
client-version compatibility

The smallest robust storage change is independent per-identity cache slots,
preferably separate files keyed by a hash of that tuple. Each slot should own
its catalog, ETag, and freshness. Storing the account ID directly in the
filename is unnecessary.

Also recommended:

  • snapshot auth and originator once per fetch, then use that snapshot for both
    the HTTP request and cache key;
  • start the refresh worker only after the app-server initialize identity is
    fixed;
  • use atomic temporary-file replacement;
  • use a same-key cross-process lock or another conflict-safe strategy;
  • avoid rewriting the full catalog for every equal-ETag freshness renewal,
    for example by using a small freshness sidecar or coalescing writes;
  • keep in-memory catalog/ETag state partitioned by the same identity.

Adding only an originator validation field to the existing single file would prevent applying a mismatched catalog, but it would still cause eviction, repeated network fetches, and loss of the previous surface's offline state.

Validation plan

Please include regression coverage for:

  1. Same binary/provider/account/version, two originators, different ETags/catalogs.
  2. Alternating online writes in one CODEX_HOME.
  3. Dropping and recreating both managers, followed by offline lookup for each originator.
  4. Multiple background-worker cycles.
  5. Concurrent writers always leaving parseable, complete JSON.
  6. Failure injection during atomic replacement.
  7. Matching-ETag renewal affecting only the correct identity and obeying a write-rate bound.
  8. Initialization races where a worker starts before client identity is known.
  9. A separate Regression: Responses Lite makes deferred MultiAgentV1 tools unreachable because tool_search is hidden in AdditionalTools #32086 regression proving that V1/Responses Lite retains a usable top-level tool_search route.

Why this is a separate root-cause report

Existing issues cover symptoms or adjacent dimensions: V1 tool serialization, MCP tools disappearing, version skew, provider/account contamination, write amplification, and truncated files. This reproduction isolates a missing cache dimension that is not covered by those reports: the exact same binary, provider, auth mode, account, and client version receive different catalogs
solely because their originators differ, then continuously overwrite one shared cache file.

Activity

  1. added
    bug
    app-server
    on Jul 16, 2026
  2. github-actions commented on Jul 16, 2026

    @github-actions
    Contributor
  3. nerdchanii commented on Jul 16, 2026

    @nerdchanii
    Author

    Follow-up: this is not an app-server version mismatch

    I rechecked the two live processes and their executable files directly.

    Surface Executable Reported version SHA-256
    Codex Desktop /Applications/ChatGPT.app/Contents/Resources/codex codex-cli 0.144.5 bdcb530615d44fcc7b35d12fe00f30c3025c25fc22a21193591dcdb064304385
    Chrome extension native host ~/.codex/plugins/.plugin-appserver/codex codex-cli 0.144.5 bdcb530615d44fcc7b35d12fe00f30c3025c25fc22a21193591dcdb064304385

    cmp also reports that the two executable files are byte-for-byte identical. Both processes use the same ~/.codex/models_cache.json.

    The catalog is returned by the remote ChatGPT Codex backend endpoint:

    GET https://chatgpt.com/backend-api/codex/models?client_version=0.144.5
    

    This is not a locally generated catalog and it is not a request to api.openai.com. The observed HTTP response is served through the chatgpt.com backend (the edge response identifies Cloudflare). The exact internal OpenAI service name behind that endpoint is not visible from client
    logs.

    The live sequence makes the identity mismatch explicit:

    1. At 2026-07-16 13:13:16 UTC, Chrome app-server PID 60805 requested
      /models?client_version=0.144.5 and received:

      ETag: W/"68e28197d956a749f12435108b07ff25"
      

      This is the Chrome-sidepanel V2 / code_mode_only catalog.

    2. At 13:13:29 UTC, Desktop app-server PID 57870 loaded that freshly written cache. It accepted it because the cached and expected client_version were both 0.144.5, then applied ETag 68e28197....

    3. At 13:13:30 UTC, Desktop requested the same URL with the same client_version and received:

      ETag: W/"6cbd9267ee12889ea6614486cc5879ff"
      

      This is the Desktop V1 / direct catalog, which was then persisted back to
      the same cache file.

    The material request difference is the client originator:

    Codex Desktop
    codex-chrome-extension-sidepanel
    

    Therefore multi_agent_version = v1 versus v2 is not the version of the app-server executable. It is server-provided model runtime metadata inside two originator-specific catalogs.

    The failure condition is consequently:

    same app-server binary and client_version
    + different originator
    -> different server catalog and ETag
    + one cache slot validated only by client_version
    -> cross-surface catalog reuse and last-writer-wins oscillation
    

    If the two processes received identical catalog content and ETags, sharing the cache would not create this semantic contamination. Here, however, executable version equality does not protect the cache because originator affects the server response but is absent from the cache identity.

  4. nerdchanii commented on Jul 17, 2026

    @nerdchanii
    Author

    I put together a reference implementation of the originator-scoped cache described above:

    https://github.com/nerdchanii/codex/tree/models-cache-originator-scope (single commit: nerdchanii/codex@78060a7)

    What it does:

    • Stores the cache per originator at CODEX_HOME/models_cache/<sha256(originator)>.json
    • Records the originator inside each cache entry and rejects legacy or mismatched entries on load and TTL renewal
    • Writes via a temp file and atomic rename
    • Adds a regression test where two managers with different originators keep independent catalogs across restarts (targeted model-manager and core TTL tests pass)

    Known limitations, intentionally out of scope for this PoC:

    • No migration or cleanup of the legacy models_cache.json
    • No cross-process locking for same-originator read-modify-write
    • The full-file rewrite on TTL renewal is unchanged
    • Originator alone is not the complete identity — provider, auth mode and account still belong in the key. Long term this probably folds into the ModelsCacheKey proposed in [codex] Scope model cache by provider and account #30984 rather than living as a separate path scheme.

    Happy to turn this into a PR if the direction looks reasonable to the maintainers.

  5. shiwandehongbai commented on Oct 12, 2026

    @shiwandehongbai

    Confirmed on Windows on 2026-10-12. The same shared-cache problem also affects the new GPT-6.1 Sol 500k default context.

    Environment:

    • Desktop 26.1007.21434, build 13901, prod channel; configured updater reports up to date.
    • Desktop-bundled official app-server 0.162.0-alpha.17.2.
    • Windows 10.0.19045 x86_64; ChatGPT authentication.
    • Model: gpt-6.1-sol.
    • No model_context_window, model_auto_compact_token_limit, or model_catalog_json override.

    A controlled test used the same official binary and account, fresh isolated CODEX_HOME/model caches, the same minimal config and clientInfo.version, and initialize -> initialized -> model/list. Only clientInfo.name changed, so the generated originator/User-Agent also changed:

    UTC time clientInfo.name context_window effective percentage catalog ETag
    09:01:48 codex_context_probe 500000 95 8c738ab04e48347ae79447c852c6adb5
    09:01:49 Codex Desktop 272000 95 9184452a30ef3eea566baa934b6238a9
    09:01:51 codex_context_probe 500000 95 8c738ab04e48347ae79447c852c6adb5

    The serialized provider/auth identity was equal across all three tests. A separate native test with codex_cli_rs also returned 272000.

    The actual shared models_cache.json was observed at 08:50:01 UTC with context_window=500000 after an independent client fetched the catalog. At 08:50:16 UTC, the Desktop process replaced it with context_window=272000 following another successful official GET /backend-api/codex/models?client_version=0.162.0. Desktop session token_count telemetry remained model_context_window=258400 (272000 * 95%).

    Selected Desktop requests returning the 272k-catalog ETag:

    • 08:50:15 UTC: req_094c28ed01b745ca8a113d115a9d234a
    • 08:52:31 UTC: req_d4de98f60944402682bee722c38368ab
    • 08:57:02 UTC: req_5a34d6a71ed641f3a961f866ea3ac910

    The independent client's 08:50:00 UTC request returned the 500k-catalog ETag:

    • req_3bac28cdee0443a3a59fc646d3c6f44d

    There are two distinct issues to resolve:

    1. Catalog storage should include the exact client surface/originator in its identity and use separate slots, preventing cross-surface overwrites.
    2. Even with a fresh isolated cache, Desktop still receives 272k directly from the server. Cache isolation alone will not make the announced 500k Desktop default take effect. Please check the server-side catalog rollout/routing for first-party Desktop/CLI identities.

    No credentials, account IDs, local usernames/paths, or raw conversation transcripts are included. The isolated tests made no model-generation calls and did not modify the real app configuration or client identity.

  6. gudabing commented on Oct 12, 2026

    @gudabing

    macOS reproduction: GPT-6.1 Sol 500K/272K oscillation (2026-10-12, UTC+08:00)

    Adding an independent macOS reproduction to the existing cross-originator shared-cache report. This is the actual context window used by a live session, not merely a stale UI label.

    Environment

    • macOS, official Codex Desktop bundled runtime 0.162.0-alpha.17.2; another browser-assistant app-server uses the same CODEX_HOME.
    • ChatGPT authentication; same account, model gpt-6.1-sol, catalog request client_version=0.162.0.
    • No model_catalog_json, model_context_window, or model_auto_compact_token_limit override. Third-party OpenCodex routing was not active.
    • Both client processes use the same ~/.codex/models_cache.json. No configuration/cache modifications were made during the investigation.

    Actual oscillation within one existing session (2026-10-12, Beijing time; transitions at task_started, followed by token_count.info.model_context_window):

    Transition time (UTC+8) Window change Later token_count confirmation
    13:10:54 258,400 → 475,000 13:11:51 = 475,000
    15:09:23 475,000 → 258,400 15:09:50 = 258,400
    15:35:12 258,400 → 475,000 15:36:34 = 475,000
    16:06:52 475,000 → 258,400 16:11:47 = 258,400

    All of these turns used GPT-6.1 Sol; the effective window changed in runtime telemetry as well as in the UI.

    Controlled official catalog A/B

    Authenticated requests to https://chatgpt.com/backend-api/codex/models?client_version=0.162.0, with the same account and client_version, changed only the originator header. Both responses were HTTP 200:

    Time (UTC+8) originator context_window max_context_window ETag prefix
    17:04:07 codex_cli_rs 272,000 872,000 fab6ce39…
    17:04:09 codex-browser-use 500,000 872,000 8c738ab0…

    Both catalogs specify effective_context_window_percent = 95, explaining the exact observed values 272000 × .95 = 258400 and 500000 × .95 = 475000.

    Desktop and browser-assistant processes were observed using the respective catalog ETags, and both share the global model-cache file. Cache reloads occurred near the session transitions. This strongly supports originator-dependent server catalogs + cross-process shared-cache contamination. The complete catalog snapshot was not captured at every transition, so the exact overwrite chain for each individual flip remains an inference; random variation for identical requests was not established.

    Two issues to address

    1. Server-side catalog/routing: after the announced GPT-6.1 Sol 500K default, the first-party coding codex_cli_rs originator still receives a 272K default, even in a successful fresh authenticated response.
    2. Client-side cache identity: originator-specific server catalogs must not overwrite/reuse the same unscoped cache entry across app-server processes. Ideally the cache key includes the exact originator together with provider/auth/account/version identity.

    Expected result: a consistent 500K default (475K effective) for eligible first-party coding clients and a stable effective context window across successive turns, regardless of simultaneous browser-assistant and Desktop app-server activity.

    No credentials, account identifiers, local usernames, raw session transcripts, or private files are included in this report.

  7. Roland0511 commented on Oct 12, 2026

    @Roland0511

    Independent macOS reproduction: Sol Ultrafast repeatedly disappears from the shared catalog

    I am a $500 Pro subscription user, using ChatGPT sign-in. This adds a service-tier reproduction to the cache-identity problem in this issue and connects it to #52839.

    Environment and scope

    • Codex Desktop 26.1007.30912, build 20156 (installed bundle verified).
    • Official desktop-bundled CLI 0.162.0-alpha.17.2; managed daemon CLI 0.162.1.
    • macOS, Apple Silicon; model gpt-6.1-sol.
    • Observations collected on 2026-10-12 (UTC+08:00), before subsequent local mitigation.
    • The desktop main service, managed daemon, and desktop Computer Use auxiliary app-server share $CODEX_HOME/models_cache.json.

    Fresh official catalog comparisons

    Using the same account and both official binaries, fresh catalog reads reproduced the selected comparisons below. Probe processes were denied reads of the shared model cache and writes anywhere in the real CODEX_HOME, with read/write denial controls verified.

    Exact request originator Sol advertises Ultrafast
    Codex Desktop (desktop main service's observed override) No
    codex_cli_rs No
    codex-browser-use (Computer Use helper initialize name) Yes
    codex_desktop (underscore spelling) Yes

    A separate four-request control held User-Agent identity constant and changed only the originator header. For both binary versions, originator=codex-browser-use returned service_tiers IDs ["priority","ultrafast"] and additional_speed_tiers=["fast","ultrafast"]; originator=Codex Desktop returned only ["priority"] / ["fast"]. Thus the space-versus-underscore identity difference is reproducible; binary version alone does not explain the returned capabilities.

    Actual file writers

    A five-minute filesystem trace attributed successful replacements of the real shared cache to these process roles:

    Time, 2026-10-12 UTC+08:00 Writer Sol Ultrafast after write
    23:17:16.377154 Desktop main app-server Absent
    23:17:47.182729 Managed daemon Absent
    23:18:41.370083 Desktop Computer Use auxiliary app-server Present

    The daemon's historical GET and writer PID were correlated, but its exact outgoing originator header was not logged.

    Deterministic local fixture controls

    Both binaries preserve a synthetic catalog's Ultrafast fields when writing the cache, with features.ultrafast_mode either true or false. The field is not being removed by a local serialization filter.

    With two identities sharing one temporary cache:

    1. Desktop binary + helper originator fetched a catalog with Ultrafast (one HTTP request).
    2. Same binary + Desktop originator reused that cache without fetching (zero HTTP requests).
    3. Daemon binary fetched a catalog without Ultrafast after client-version mismatch and replaced the cache.
    4. Desktop binary fetched again after the opposite version mismatch and restored Ultrafast.

    This demonstrates both cross-originator cache reuse at the same version and repeated full replacement when the two installed versions alternate.

    Requested upstream behavior

    Please partition persisted catalog/ETag/freshness by the request's exact effective originator together with provider/endpoint/auth/account and version compatibility, rather than allowing independent clients to reuse/evict one global slot. Also please investigate why normal first-party identities omit Sol Ultrafast for affected $500 subscribers; cache isolation alone does not change a fresh server response.

    Limits and privacy

    The backend rollout/eligibility rule is unknown. Catalog metadata is not proof of inference entitlement, served tier, or billing. These probes started no inference tasks and did not parse/copy auth tokens or modify the real cache. The observed cache replacements came from the existing services. Only this sanitized summary is posted; no account IDs, credentials, raw account responses, private transcripts, or local personal paths are attached. Subsequent local mitigation is separate from the observations above.

    Related service-tier report: #52839

  8. javadavado-svg commented on Nov 10, 2026

    @javadavado-svg

    I’m seeing similar context-window instability in a long-running Codex Desktop conversation on Windows, using GPT-6 Astra with High reasoning effort.

    On November 10, 2026, the local rollout recorded:

    Time (UTC) Recorded event
    08:01:09.540 last_token_usage: 274,037 input tokens, 285 output tokens, 274,322 total tokens; model_context_window: 475,000
    08:01:09.608 Turn completed
    08:07:22.404 Next turn started with model_context_window: 258,400
    08:14:01.321 A completed compaction record was persisted

    The previous request’s reported usage was about 58% of the larger window, leaving approximately 42% remaining. The next turn’s reported capacity was about 46% smaller. These percentages are calculated from log fields, not synchronized UI measurements.

    Earlier that day, another turn contained five completed compaction markers. The first compaction record was timestamped 07:36:21.669 UTC; the turn ran from approximately 07:35:44 to 07:43:33 UTC and eventually delivered its result. I also observed the context indicator falling from over 40% remaining to roughly 1% across a response, and subsequently saw another drop from a window above 400k into the mid-200k range.

    Impact: relatively straightforward follow-up requests are sometimes taking more than five minutes while compaction repeats. The earlier five-compaction turn lasted approximately 7 minutes 49 seconds; the later turn lasted approximately 7 minutes 18 seconds. These are total turn durations—not measurements of time spent exclusively compacting—but the interruptions materially slow interactive work.

    The work eventually continued, so I am reporting unstable context capacity, repeated compaction and latency, rather than claiming permanent work loss.

    The 475,000 ↔ 258,400 values closely match reports already in this issue. However, I have not established that shared-cache contamination caused my case, or that the window change alone caused each compaction.

    Could OpenAI investigate why the reported context capacity changes between turns and expose the effective window, compaction threshold and reason for changes? A stable, predictable context window matters for paid interactive use.

  9. littletaro97-arch commented on Nov 19, 2026

    @littletaro97-arch

    Additional Windows Codex Desktop data point: the same conversation changed from an effective context window of 258,400 to 475,000 tokens between successive turns, with gpt-6.2-sol and max reasoning recorded in both turns.

    • The affected turn started with model_context_window: 258400. Five automatic compactions completed in about eight minutes. The first measured input after each one was still 255,466–256,212 tokens.
    • Before the last compaction loop was interrupted, the three shell-command results totaled about 14.7K characters. The last recorded input was 256,212 tokens, of which 252,032 were cached. The last automatic compaction kept 27 image inputs in its replacement history; their individual token costs are unknown. This may also be relevant to Local compaction v2 retains unbounded input_image payloads, causing repeated auto-compaction #33493.
    • After interruption, the manual /compact turn started with model_context_window: 475000 before compaction completed. The next ordinary turn also started at 475,000; its first measured input was 96,430 tokens.

    This confirms the window change in runtime records and the repeated-compaction symptom for this session. I did not capture the catalog responses or cache history at the transition, so I cannot attribute it to the same cache mechanism.

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

    app-serverbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions