Skip to content

Managed Codex model-catalog refresh never renews its token, so new sessions fall back to a 258k window and ~230k-token startup #33701

Open

Description

@CyMule

What happened

My Codex threads on one machine started compacting constantly, several times within a few minutes, even in brand-new threads. Claude threads on the same machine and Codex on my other machine were fine.

Diagnosis

T3 launches managed Codex with auth={…,refresh_interval_ms=0} (apps/server/src/provider/CodexManagedRuntime.ts, unchanged on main). In Codex, 0 means no interval: login/src/auth/external_bearer.rs resolve() reuses the first helper token forever (None => true). Only refresh() re-runs the helper, and only the Responses 401-recovery path calls it, for its own auth manager. The catalog request (OpenAiModelsEndpoint::list_models) keeps its own cached token and has no 401 recovery.

Once the launch token expires, every /v1/models refresh returns 401. After the 5-minute cache TTL, new turns hit Unknown model gpt-6.1-sol and use fallback metadata: 272k window (258,400 usable) and supports_search_tool=false. Every MCP/app tool schema then goes inline on each request (~215k tokens here). That overhead survives compaction, so threads compact after nearly every tool call.

The credential itself is fine: the current token from the same __managed-chatgpt-token helper gets 200 from GET /v1/models, including gpt-6.1-sol metadata. Proxies, env overrides and ~/.codex/auth.json (unused in managed mode) are ruled out. The same code is in Codex 0.166.0, 0.167.0 and main.

Likely fix: set refresh_interval_ms well under the token lifetime (e.g. 300000, as Codex's own command-auth tests use). Untested here (verifying needs a run of over an hour). Catalog retry on 401 is a separate upstream Codex improvement.

Steps to reproduce

  1. Desktop app, Codex provider in managed (Connect with ChatGPT) mode, model gpt-6.1-sol, app/MCP integrations enabled.
  2. Leave the Codex app-server running until the managed token it launched with expires. Here that was ~30 min after launch, because the process inherited an already-issued token.
  3. Make sure nothing else (e.g. the Codex desktop app) rewrites ~/.codex/models_cache.json within 5 minutes. Then start a new Codex thread and send a short prompt.
  4. Codex logs a catalog 401 and Unknown model … fallback model metadata. The first request reports ~230k input tokens and a 258,400 window, and the thread compacts every few tool calls.

Version

0.1.9-nightly.20261109.4443

Environment

macOS 27.2 arm64, T3 Code (Nightly) desktop with local server, Codex app-server 0.163.0, provider openai_token_sharing, gpt-6.1-sol

Evidence

# one Codex app-server process, launched at T+0
T+23m  last successful catalog fetch (models_cache.json fetched_at)
T+30m  WARN  get_model_info: Unknown model gpt-6.1-sol is used. This will use fallback model metadata.
T+30m  ERROR failed to refresh available models: unexpected status 401 Unauthorized: Unknown error  (every refresh after this)
T+80m  feedback_tags auth_401_error_code="token_expired" auth_recovery_outcome="recovery_succeeded"  (Responses path)
T+80m+ ERROR failed to refresh available models: unexpected status 401 Unauthorized  (catalog still failing)

sessions in that process    first request   window    compactions
  before catalog 401s       ~25k            475,000   0
  after (5 sessions)        232k-400k       258,400   3-18 each
after T3 restart + workaround: 25.4k, 475,000, 0 catalog errors

Related issues

#27939 (closed for the outdated-runtime cause; maintainer asked to track the catalog-refresh 401 separately, and 3 of its comments describe it). #25891 (same compaction symptom, undiagnosed). #24536 (expired-token family). #29946/#29950 fix Responses-path renewal only, not the catalog request.

Fix applied or workaround

Restarting T3 gets a fresh token but the problem recurs. Durable workaround applied: top-level model_catalog_json = "<saved {\"models\":[…]} file>" in ~/.codex/config.toml. Codex then uses StaticModelsManager and never calls /v1/models. Downside: the model list stays frozen until the file is re-saved.

Filed by

Claude Code (claude-opus-5-5) with a GPT-6.1-Sol subagent; triage playbook followed manually, not via t3 triage

Activity

  1. everywhereautorepair-hue commented on Nov 11, 2026

    @everywhereautorepair-hue

    Windows corroboration and a working workaround, reported with the affected user's authorization.

    I checked the local Codex session telemetry and the prior repair record. The historical symptom matches this issue:

    • 2026-11-10 02:45:12 UTC: a new T3 Code gpt-6.1-sol session's first usage event recorded 218,519 input tokens and model_context_window=258400.
    • 2026-11-10 02:46:34 UTC: another new Sol session recorded 218,525 input tokens and the same 258400 window.
    • Two other first-request records from the same incident were 217,866 and 217,876 input tokens with the same window.

    The earlier repair switched the provider from managed to existing, pointing to the Codex desktop executable and using its existing ChatGPT sign-in. Its recorded verification was 25,715 first-request input tokens, model_context_window=475000, with code mode enabled.

    Current state, checked on 2026-11-11 UTC:

    • Windows x64; installed T3 server reports 0.1.9-nightly.20261111.4501. This is the version installed at today's verification, not a confirmed version for the historical incident.
    • Provider remains setupMode="existing".
    • A first-turn, no-tools "Reply with the single word READY" test recorded 27,933 input tokens and model_context_window=475000. The severe startup bloat is currently avoided.
    • Both current local model-cache files contain gpt-6.1-sol with context_window=500000 and effective_context_window_percent=95.

    A practical caveat to the workaround: the desktop executable path included an update-specific directory. That executable later disappeared, preventing Codex from starting in T3. Repointing existing mode to T3's already-installed Codex 0.166.0 executable restored the connection while retaining the existing login and the 475000 usable window. No return to managed mode was needed.

    I have not independently reproduced or validated the exact token-renewal root cause proposed above, and have not tested a managed-mode code fix over a token-expiry interval. This comment corroborates the observed fallback/startup symptom and the existing-mode workaround. No credentials, account identifiers, private prompts, or raw session logs are attached.

    Filed by Codex (GPT-6.1 Sol High) on the affected user's behalf.

  2. iamsoft-tech commented on Nov 14, 2026

    @iamsoft-tech

    Windows corroboration, with a different visible symptom.

    Environment: Windows 11, T3 Code (Beta) desktop 0.1.6 with local server, Codex in managed "Connect with ChatGPT" mode (openai_token_sharing), Codex 0.167.0 (version recorded in the affected rollouts), models gpt-6-astra and gpt-6.1-sol.

    What we saw: instead of constant compaction, every new Codex turn failed with Incomplete response returned, reason: max_output_tokens, with zero token usage recorded. It read as "Codex hit its output limit", which sent us in the wrong direction for a while.

    Evidence from the Codex log database (logs_2.sqlite, target codex_models_manager), 8 to 14 November:

    • 4 of the 113 managed app-server processes in that period logged the catalog 401; they were the long-lived ones.
    • In each, the first failed to refresh available models: 401 came 23 to 41 minutes after the process started, followed by Unknown model ... fallback model metadata.
    • From then on every new turn in that process failed as above. The failing sessions have an empty comp_hash in turn_context.
    • Stopping that one app-server while idle cleared it: the same one-word test that had failed three times passed on the fresh process.

    Pull request 33713 applied cleanly to a fork based on 09a54f01bc. CodexChatGptAuth.test.ts passes there. CodexManagedRuntime.test.ts passes 2 of 4 cases on Windows with or without the change (the other 2 fail on symlink creation, unrelated). We have not run the patched build past a token expiry.

    Workaround in use: setupMode: "existing" with a stable Codex executable path.

    Investigated and written with Claude (Fable 5.2) in T3 Code, posted at the user's request.

  3. asmither commented on Nov 14, 2026

    @asmither

    Note

    🤖 Claude Opus 5.5 responding on behalf of asmither

    This still happens on 0.1.10-nightly.20261113.4643 (macOS 27.2 arm64, managed Codex app-server 0.166.0). It affects gpt-6-astra as well as gpt-6.1-sol.

    What I saw:

    • Codex children started with delegate_task (gpt-6-astra and gpt-6.1-sol, reasoning high) began their first request at 264k–310k input tokens.
    • The context window was 258,400, so they were already over it and got stuck in a compaction loop before doing any work.
    • 258,400 is 272,000 × 95%, the fallback metadata described above, not the models' real window.
    • A standalone codex exec on the same machine, run at the same time, started at about 19k.
    • Trimming Codex plugins in ~/.codex/config.toml did not help.
    • Killing only T3's codex app-server process (T3 respawns it) cleared the problem. It returned in later runs, so I killed the process before every run.

    I did not check the catalog 401 in the logs, so the cause above is not independently confirmed here. The symptoms, the recovery after a restart and the recurrence all match it.

  4. coreylubo commented on Nov 14, 2026

    @coreylubo

    Note

    Claude Opus 5.5 responding on behalf of coreylubo

    Another macOS reproduction. The cost here was large: within about 5 hours of the weekly reset, this bug had used at least 82% of the new weekly Codex limit, because nothing stopped the loop.

    Setup: T3 Code (Beta) 0.1.9 desktop with local server, macOS 27.2 arm64. Managed Codex app-server 0.167.0. Five delegate_task review children on gpt-5.6-terra (medium).

    What the logs show (~/.codex/logs_2.sqlite)

    • failed to refresh available models: unexpected status 401 Unauthorized recurs from 2026-11-13 08:55Z onward. That is the earliest row the log keeps.
    • Unknown model gpt-5.6-terra is used. This will use fallback model metadata. appears 418 times over the same period.

    What it cost

    • The first request of each child carried about 425k input tokens. About 376k of that was the schemas of one MCP server with 860 tools, which goes inline when the fallback metadata turns tool search off.
    • Compaction cannot remove tool schemas, so every request overflowed again. One child compacted 1,944 times inside a single turn.
    • The longest-running child looped for about 23 hours. After the weekly reset, the five children together made about 6,900 requests and used about 2.0B input tokens. That was 99.8% of the week's Codex usage.

    Workarounds applied

    • Disabled that MCP server.
    • Set the top-level model_catalog_json workaround from the report above. codex debug models then lists gpt-5.6-terra with supports_search_tool: true.

    The delegate_task children had no timeout, token budget or compaction cap, so this ran unattended. That part is filed as issue #36982.

  5. Falkicon commented on Nov 15, 2026

    @Falkicon

    Windows corroboration on 0.1.9 (Codex 0.167.2, managed, gpt-6.1-sol), with two details the thread doesn't have yet:

    • Top-level threads loop too, not only delegate_task children. Five threads, including one started directly by the user, compacted 391–1,735 times each. The longest ran about 24 hours until the account hit its usage limit.
    • Healthy threads degrade mid-run, not only new ones. One thread kept its 475,000 window and a 25.9k first request until 42 minutes after the first catalog 401, then reported 258,400 and compacted at once. The other four started at 271–275k input tokens, already over the 258,400 window.

    Logs show the same 401 Unauthorized and Unknown model … fallback model metadata pair in every affected thread. A Codex Desktop session on the same machine stayed at 475,000 with no compactions.

    Investigated with Claude (Opus 5.5) in T3 Code, posted at the user's request.

  6. xuli500177 commented on Nov 17, 2026

    @xuli500177

    Windows confirmation on Codex 0.169.0 — please prioritize human review and an official fix

    I am also affected in managed ("Connect with ChatGPT") mode. This makes unattended, long-running work unreliable: a healthy top-level thread can fall into repeated compaction/read cycles without advancing, wasting usage until I notice and stop it. Restarting or sending another message is not a satisfactory remedy for unattended work. I want to keep using managed mode, not maintain a private patch or switch authentication modes permanently.

    Sanitized local evidence from November 17, 2026:

    • Affected top-level run: T3 0.1.10-nightly.20261116.4787, Codex 0.169.0, gpt-6.1-sol. The same run's reported context window changed from 475,000 to 258,400. After two compactions, history estimates were about 25.9k/24.5k, but the next full requests had 291,703/289,838 input tokens, immediately triggering compaction again. Those history estimates and request-input measurements are different metrics, not proof of an exact tool-schema size.
    • At that run's start, native logs explicitly recorded loaded cache file, then cache is stale ... cache_ttl_secs=300, models cache: no usable cache entry, and model catalog refresh after auth change failed or timed out, followed by unknown-model fallback. This incident's captured trigger was timeout/cache ineligibility; I am not retroactively attributing it to an unobserved 401.
    • Separately, after updating to T3 0.1.11-nightly.20261117.4838 with managed Codex 0.169.0, one running app-server logged repeated catalog 401 Unauthorized responses. Its actual launch arguments still specified refresh_interval_ms=0.
    • Invoking that running provider's configured T3 token helper separately and using its current credential against the same catalog endpoint returned 200, including gpt-6.1-sol, context_window=500000, and supports_search_tool=true. Helper retrieval took about 116–147 ms. This supports a stale-auth/cache-path problem; it does not independently prove the precise expiry reason or validate a proposed patch across token expiry.
    • Authenticated full-catalog diagnostic fetches can also exceed the native five-second deadline on this connection. These used a separate Windows HTTP client, so their timings are not direct measurements of Codex's internal transport. Actual Clash connection records showed api.openai.com routed through the intended overseas VPS, not DIRECT.

    Could a maintainer please take ownership of the human-review step for #33713 and #31903, or explain what remaining technical change or evidence is needed?

    I am not asking to bypass authentication/security review or claiming that either patch alone fixes every timeout or early-token-rejection case. I am asking for a prioritized, official resolution: if these approaches are correct, please review and merge the appropriate changes; if not, please identify the preferred fix and a practical verification path. In particular, what sanitized evidence can an affected user provide without publishing OAuth flows, tokens, or private conversations?

    Several independent users above already report the same default-managed-mode failure, including very large unattended usage losses. Users should not have to patch packaged authentication code themselves to make the default mode safe for long-running tasks. If a full fix needs more time, an official warning or supported interim mitigation would help.

    Posted at the affected user's explicit request with AI assistance. No credentials, account identifiers, raw session exports, or private project content are included. No local patch has been applied, so this is corroboration of the failure, not a claim that either proposed fix has passed on this installation.

  7. realsamrat commented on Nov 19, 2026

    @realsamrat

    Confirmed on 0.1.11-nightly.20261119.4941: a managed Codex delegate_task child hit fallback metadata mid-process and looped through 190 compactions over 3h16m until interrupted.

    Environment

    • T3 Code 0.1.11-nightly.20261119.4941 desktop (local server), macOS 27.0 arm64.
    • Managed Codex ("Connect with ChatGPT", openai_token_sharing, shadow Codex home), app-server 0.170.0, gpt-6.1-sol (high reasoning), ~25 MCP servers (some with hundreds of tools).
    • Both v0.1.11-nightly.20261119.4941 and main still launch managed Codex with refresh_interval_ms=0 (apps/server/src/provider/CodexManagedRuntime.ts:26). PR fix(server): managed Codex renews the token its model catalog uses #33713 is still open.

    What happened (2026-11-19)

    • A delegate_task child (code-review council member) ran 16:18–19:35 UTC (durationMs: 11,799,858, status interrupted). Its first request was 264,828 input tokens against a 258,400 window. It ran 190 compactions in one turn, stayed near ~265k input tokens after each, re-ran the same brief-file read command ~160+ times, and produced no final answer.
    • Across ~250 Codex thread starts that day, 7 hit fallback metadata—all on the managed instance (0 of 9 threads on a second Codex instance using the existing CLI login).
    • All 7 started at 264k–301k input tokens against a 258,400 window with 1–190 compactions (190, 54, 47, 38, 9, 4, 1). Healthy siblings on the same managed instance and app-server started at ~30k–34k tokens, 475,000 window, 0 compactions.
    • Fallbacks occurred 36–65+ minutes after app-server start. One app-server served gpt-6.1-sol normally at 20:46 and 21:01 UTC, then fell back on a new thread at 21:14 UTC, confirming mid-life degradation.

    Log evidence

    # Mid-life fallback on one app-server (20:46/21:01 healthy -> 21:14 fallback)
    Unknown model gpt-6.1-sol is used. This will use fallback model metadata.
    Model metadata for `gpt-6.1-sol` not found. Defaulting to fallback metadata
    
    # First /responses request after fallback (4 of 7 cases in logs_2.sqlite)
    401 auth_401_error_code="token_expired" -> "Refreshing token" -> auth_recovery_outcome="recovery_succeeded"
    
    # Catalog refresh failure on same managed home/day (2 rows retained)
    failed to refresh available models: unexpected status 401 Unauthorized
    

    The /responses path recovers its token, but the turn stays on fallback metadata for the whole turn. Because logs_2.sqlite does not retain rows for every case, the catalog 401 is not logged for all 7 incidents.

    Maintainer notes and workaround

    • Even with fix(server): managed Codex renews the token its model catalog uses #33713, nothing in T3 Code stops a turn that compacts endlessly without reducing tokens. Failing when the first request exceeds the window (or after N non-reducing compactions) and surfacing the fallback-metadata warning in the thread would prevent multi-hour stalls.
    • Workaround: route delegates to the existing-CLI-login Codex instance. Restarting the managed app-server only helps temporarily.

    Found via the t3 triage playbook. Investigated by Claude Code (claude-opus-5-5); comment drafted by Gemini 4 Neon (Antigravity).

  8. jankalasnikov47 commented on Nov 20, 2026

    @jankalasnikov47

    Another macOS data point (T3 Code Beta 0.1.10 desktop with local server, macOS 26.5 arm64, managed Codex 0.166.0, gpt-6.2-astra and gpt-6.2-sol), plus one measurement this thread does not have yet: most of the fallback overhead is the codex_apps catalog.

    Where the tokens go

    One-word prompt through codex exec with the managed 0.166.0 binary and gpt-6.2-astra. Fallback was forced with a model_catalog_json that lacks the model.

    Setup Input tokens
    Model in the catalog (healthy) 21,605
    Fallback metadata 271,940
    Fallback metadata, features.apps=false 72,424

    The codex_apps tool cache on this machine holds 889 tools. With [features] apps = false in ~/.codex/config.toml, a first request under fallback is about 72k instead of over the 258,400 window. The thread still runs on fallback metadata (generic prompt, 258,400 window, no tool search) and loses the ChatGPT connectors, so this is a lighter stopgap than the static model_catalog_json above, not a fix.

    What it looked like here

    • Since 17 Nov, 14 sessions started at 243k–296k input tokens against the 258,400 window. The three worst compacted 124, 138 and 155 times. The last did that in 156 tool calls, repeatedly re-reading the same brief.
    • In one app-server process, sessions started 0 and 41 minutes after launch began healthy (28k and 30k first request). The 41-minute one dropped from a 475,000 window to 258,400 mid-run and compacted 64 times in total. Every session started from 75 minutes on began at 290k–296k.
    • One cycle from a looping turn. The Responses token is fine; only the catalog request is rejected:
    POST https://api.openai.com/v1/responses -> 200 OK   (auth_retry_after_unauthorized="false")
    models cache: cache hit cache_ttl_secs=300
    ERROR failed to refresh available models: unexpected status 401 Unauthorized: Unknown error
    post sampling token usage total_usage_tokens=291552 auto_compact_scope_limit=Some(244800)
    
  9. Heisenberg77528 commented on Nov 21, 2026

    @Heisenberg77528

    Another macOS corroboration on T3 Code Beta 0.1.11 (still launching managed Codex with refresh_interval_ms=0), with gpt-6.2-sol and an additional compounding trigger when Codex Desktop runs alongside T3.

    Environment

    • macOS 27.2.1 (arm64), T3 Code (Beta) 0.1.11 desktop with local server
    • Managed Codex (setupMode: "managed", openai_token_sharing), Codex app-server 0.166.0, model gpt-6.2-sol
    • Official Codex Desktop / ChatGPT app (codex-cli 0.171.0-alpha.13) also running on the same machine, sharing ~/.codex/models_cache.json

    Observed behavior (2026-11-20 UTC)

    • Two top-level gpt-6.2-sol threads started healthy with model_context_window = 475,000.
    • ~34 minutes into the managed app-server's lifetime, both threads degraded mid-session:
      • Codex emitted Model metadata for 'gpt-6.2-sol' not found. Defaulting to fallback metadata and Unknown model gpt-6.2-sol is used. This will use fallback model metadata.
      • model_context_window dropped mid-thread from 475,000 to 258,400 (272,000 × 95%).
      • On the main thread, single-request input tokens jumped from 188,765 to 366,751 (+178k inline tool-schema overhead once fallback disabled tool search), immediately exceeding 258,400 and triggering contextCompaction on the next turn. A second thread similarly jumped to 336,319 against 258,400 and compacted immediately.
    • Confirmed in ~/.codex/logs_2.sqlite:
      • Repeated failed to refresh available models: unexpected status 401 Unauthorized: Unknown error.
      • Compounding cache-version mismatch: Codex Desktop (0.171.0) refreshes /backend-api/codex/models?client_version=0.171.0 every ~4.5 minutes and overwrites the shared ~/.codex/models_cache.json. T3's managed 0.166.0 then logs cache version mismatch (expected_version="0.166.0", cached_version=Some("0.171.0")), cannot reuse the cache, and immediately hits the 401 refresh failure.
    • Verified in packaged 0.1.11 app.asar that managed Codex is still spawned with refresh_interval_ms=0.

    Adding this data point to help prioritize review/merge of #33713 (and #31903).

    (Investigated and drafted with AI assistance at the user's request; no credentials, account IDs, or private prompts included.)

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

    via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions