Managed Codex model-catalog refresh never renews its token, so new sessions fall back to a 258k window and ~230k-token startup #33701
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#
- Desktop app, Codex provider in managed (Connect with ChatGPT) mode, model gpt-6.1-sol, app/MCP integrations enabled.
- 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.
- Make sure nothing else (e.g. the Codex desktop app) rewrites
~/.codex/models_cache.jsonwithin 5 minutes. Then start a new Codex thread and send a short prompt. - 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
CyMule(GitHub profile, opens in a new tab) added labelsvia-triage
tanstack-source added labelsbug
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, targetcodex_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: 401came 23 to 41 minutes after the process started, followed byUnknown model ... fallback model metadata. - From then on every new turn in that process failed as above. The failing sessions have an empty
comp_hashinturn_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.tspasses there.CodexManagedRuntime.test.tspasses 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.
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 execon the same machine, run at the same time, started at about 19k. - Trimming Codex plugins in
~/.codex/config.tomldid not help. - Killing only T3's
codex app-serverprocess (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.
- Codex children started with
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_taskreview children on gpt-5.6-terra (medium).What the logs show (
~/.codex/logs_2.sqlite)failed to refresh available models: unexpected status 401 Unauthorizedrecurs 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_jsonworkaround from the report above.codex debug modelsthen lists gpt-5.6-terra withsupports_search_tool: true.
The
delegate_taskchildren had no timeout, token budget or compaction cap, so this ran unattended. That part is filed as issue #36982.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_taskchildren. 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 UnauthorizedandUnknown model … fallback model metadatapair 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.
- Top-level threads loop too, not only
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, Codex0.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, thencache is stale ... cache_ttl_secs=300,models cache: no usable cache entry, andmodel 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.4838with managed Codex0.169.0, one running app-server logged repeated catalog 401 Unauthorized responses. Its actual launch arguments still specifiedrefresh_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, andsupports_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.comrouted 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?
- #33713 has been open since November 10. Its pipeline comment says the validation VM cannot perform first-party ChatGPT OAuth and the automation stopped for lack of accessible end-to-end captures, leaving it for a person.
- #31903 has been open since November 6; its automated approval check also requests human review of the default fallback behavior. Both PRs are currently reported mergeable/clean, and their main build/test checks are green. I understand that this is not equivalent to runtime approval.
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.
- Affected top-level run: T3
Confirmed on
0.1.11-nightly.20261119.4941: a managed Codexdelegate_taskchild hit fallback metadata mid-process and looped through 190 compactions over 3h16m until interrupted.Environment#
- T3 Code
0.1.11-nightly.20261119.4941desktop (local server), macOS 27.0 arm64. - Managed Codex ("Connect with ChatGPT",
openai_token_sharing, shadow Codex home), app-server0.170.0,gpt-6.1-sol(highreasoning), ~25 MCP servers (some with hundreds of tools). - Both
v0.1.11-nightly.20261119.4941andmainstill launch managed Codex withrefresh_interval_ms=0(apps/server/src/provider/CodexManagedRuntime.ts:26). PR #33713 is still open.
What happened (2026-11-19)#
- A
delegate_taskchild (code-review council member) ran 16:18–19:35 UTC (durationMs: 11,799,858, statusinterrupted). 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-solnormally 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 UnauthorizedThe
/responsespath recovers its token, but the turn stays on fallback metadata for the whole turn. Becauselogs_2.sqlitedoes not retain rows for every case, the catalog 401 is not logged for all 7 incidents.Maintainer notes and workaround#
- Even with #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 triageplaybook. Investigated by Claude Code (claude-opus-5-5); comment drafted by Gemini 4 Neon (Antigravity).- T3 Code
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_appscatalog.Where the tokens go#
One-word prompt through
codex execwith the managed 0.166.0 binary and gpt-6.2-astra. Fallback was forced with amodel_catalog_jsonthat lacks the model.Setup Input tokens Model in the catalog (healthy) 21,605 Fallback metadata 271,940 Fallback metadata, features.apps=false72,424 The
codex_appstool cache on this machine holds 889 tools. With[features] apps = falsein~/.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 staticmodel_catalog_jsonabove, 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)Another macOS corroboration on T3 Code Beta 0.1.11 (still launching managed Codex with
refresh_interval_ms=0), withgpt-6.2-soland an additional compounding trigger when Codex Desktop runs alongside T3.Environment#
- macOS 27.2.1 (arm64), T3 Code (Beta)
0.1.11desktop with local server - Managed Codex (
setupMode: "managed",openai_token_sharing), Codex app-server0.166.0, modelgpt-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-solthreads started healthy withmodel_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 metadataandUnknown model gpt-6.2-sol is used. This will use fallback model metadata. model_context_windowdropped mid-thread from475,000to258,400(272,000 × 95%).- On the main thread, single-request input tokens jumped from
188,765to366,751(+178k inline tool-schema overhead once fallback disabled tool search), immediately exceeding258,400and triggeringcontextCompactionon the next turn. A second thread similarly jumped to336,319against258,400and compacted immediately.
- Codex emitted
- 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.0every ~4.5 minutes and overwrites the shared~/.codex/models_cache.json. T3's managed0.166.0then logscache version mismatch (expected_version="0.166.0", cached_version=Some("0.171.0")), cannot reuse the cache, and immediately hits the 401 refresh failure.
- Repeated
- Verified in packaged
0.1.11app.asarthat managed Codex is still spawned withrefresh_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.)
- macOS 27.2.1 (arm64), T3 Code (Beta)
Related data point, different symptom: on T3 Code
0.1.12/ Codex0.172.0(still launched withrefresh_interval_ms=0), an inference request (POST /v1/responses) failed with HTTP 400 rather than401, and Codex did not run inline inference auth recovery.Environment: Windows x64, managed Connect with ChatGPT,
gpt-6.1-sol,refresh_interval_ms=0. Versions verified from the runningcodex app-serverinitializeuserAgent(T3 Code/0.172.0 (Windows 10.0.26200; x86_64) unknown (T3 Code; 0.1.12)). Real T3 conversation (kept active with periodic short tool calls).Observed (2026-11-25 UTC):
11:55:20— preceding recorded credential exchange succeeded.12:36:14— updated backend started (0.172.0/0.1.12); inference succeeded repeatedly.12:55:08— last successful request before failure.12:55:46— same conversation and backend returned HTTP 400.12:55:55— separate credential exchange succeeded, 9 seconds after the failure.12:57:47— T3 released the idle backend.13:03:16— same conversation succeeded on a replacement backend (also0.172.0/0.1.12) without another sign-in; T3 stayed open.
Failure details:
POST /v1/responsesreturnedx-openai-authorization-error: 400with body (and decodedx-error-json):{"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}- Codex logged
auth_retry_after_unauthorized="false"with emptyauth_recovery_*fields; no inline inference recovery was observed (separate from the credential exchange 9s later). - One failed request was captured in this
0.1.12/0.172.0run; repeated retries before idle release were not tested. - The backend process stayed unchanged across the observed active window (~20 minutes). The failure occurred ~60 minutes after the preceding recorded exchange; we did not establish when that backend's token was issued/expired or why OpenAI returned
400.
Localhost fixture (Codex
0.172.0vs0.166.0, synthetic tokens):- With
refresh_interval_ms=0and synthetic HTTP400, the rejected cached token persists across retries while restart/resume recovers. - Process-wide cache in
0.172.0: a fresh thread in the same0.172.0process also fails with the cached token (whereas on0.166.0a fresh thread recovered). - Changing only the HTTP status to
401recovers inline. - Because #33713 notes that the Responses path re-runs the helper only after a
401, a400like this never triggers inline retry; a positiverefresh_interval_ms(the #33713 approach) avoided the rejection in the fixture once the interval elapsed. (Client-behavior test only — does not prove the upstream rejection reason or validate #33713 itself.)
Redacted metadata and the localhost repro script are available if useful. Investigated, drafted, and cross-checked with AI assistance across three providers (Codex/Sol, Claude/Opus, Gemini/Neon).
Note
🤖 Claude Fable 5.2 responding on behalf of BuddhiAbeyratne
Same HTTP 400 on macOS, and it confirms the process-wide part outside a fixture: one stale token took down every new thread on the backend.
Environment: macOS arm64 (Darwin 25.6.0), T3 Code (Beta) desktop 0.1.11 with local server, managed Codex ("Connect with ChatGPT",
openai_token_sharing,refresh_interval_ms=0), Codex app-server 0.172.0,gpt-6.2-astraandgpt-6.2-sol.Observed (2026-11-25 UTC), one
codex app-serverprocess:12:59:46backend started. 49POST /v1/responsesreturned 200, the last at13:34:06.13:52:33first 400. From then to14:11:47: 39 requests, 39 × 400, 0 × 200, across 34 freshly started threads in 6 worktrees, both models, reasoning efforts low to xhigh.- Each failure:
x-openai-authorization-error: 400, body{"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400},auth_retry_after_unauthorized="false", emptyauth_recovery_*. - The previous backend that day ended the same way: 89 × 200, then 3 × 400 from
10:38:30, on three different threads.
Contrast: twice on 23 Nov (UTC) the same route answered an expired token with
401 token_expired, and Codex recovered inline within 7 seconds both times. I did not establish which Codex version ran that day.Account is fine: while the managed backend was failing,
codex execwith the CLI's own ChatGPT login answered on the same two models.Impact: every Codex delegate (a two-reviewer council) failed instantly for 19+ minutes. The thread shows only "Bad Request", with nothing pointing at the backend or suggesting a restart.
After killing the stuck backend: the next Codex turn succeeded at
14:14, but on a backend T3 started withoutopenai_token_sharing(CLI login,auth_mode="Chatgpt"), so this does not show whether a fresh managed backend recovers.Found via the
t3 triageplaybook.Additional macOS corroboration for the generic managed-Codex authorization HTTP 400, with two concurrent native threads and a same-process fresh-thread control.
What happened#
Two concurrent Codex threads using
gpt-daybreak-blue-latest, max reasoning, and the same managed provider instance failed after successful tool calls. Their first failures were eleven seconds apart. A short follow-up in each thread failed before producing reasoning or token usage.The affected native threads remained unusable. A fresh native thread using the same model, provider instance, and app-server process subsequently succeeded.
Diagnosis#
The failures were authentication rejections:
POST https://api.openai.com/v1/responsesreturned400 Bad Request.- The response included
x-openai-authorization-error: 400. - The body was
{"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}. - Codex recorded
auth_retry_after_unauthorized="false"with no recovery attempt. - Immediately before the failures, Codex logged
Reloaded auth, changed: false.
T3 Code 0.1.8 launches managed Codex with
refresh_interval_ms=0. The strongest diagnosis is that each existing native thread retained a rejected managed credential and never reran T3's token helper because the provider returned 400 instead of the 401 that triggers Codex's inline auth recovery. The exact reason the authorization service returned 400 instead of 401 was not established.Other hypotheses were checked:
- Shared-session concurrency: Both turns had distinct native thread and turn IDs and ran concurrently successfully for approximately eleven minutes. The shared app-server remained healthy enough to start and run a fresh native thread.
- Context compaction: One thread compacted once and the other five times; every compaction completed. Their last successful requests contained 154,599 and 166,336 input tokens against a 258,400-token window.
- Request construction: T3's
turn/startrequests schema-decoded successfully with the expected model, max effort, runtime policy, collaboration mode, and native thread ID. Codex accepted the follow-up turns before inference returned the authorization 400. - Tool output: The final outputs were valid JSON/UTF-8 without NUL or replacement characters and were unrelated payloads of approximately 40.5 KB and 11.3 KB.
Recorded sequence#
This is a recorded reproduction, not a deterministic clean reproduction:
- Run T3 Code with managed Codex/Connect with ChatGPT, where the token-helper configuration uses
refresh_interval_ms=0. - Keep two native Codex threads active on the same app-server.
- Continue until the credential cached by those native threads is rejected.
- The next
/v1/responsesrequest in each thread returns an authorization HTTP 400. - Send a short follow-up to each existing thread. Both fail again before model output.
- Start a fresh native thread. With Codex 0.166.0, the fresh thread obtains working auth and succeeds in the same app-server process.
Environment#
- T3 Code Desktop/local server 0.1.8
- macOS arm64, Darwin 25.6.0
- Node 24.22.1
- Codex app-server 0.166.0
- Managed Connect with ChatGPT (
openai_token_sharing) gpt-daybreak-blue-latest, max reasoning
Evidence#
16:32:40 affected native thread A: POST /v1/responses -> 200 16:32:45 affected native thread B: POST /v1/responses -> 200 16:32:56 thread A -> 400, x-openai-authorization-error: 400 request req_33c6f9fc3a1f4ab28a26296dfe7b0ab2 16:33:07 thread B -> 400, x-openai-authorization-error: 400 request req_643045460e8e491ab8da0fef14a41e9c 16:35:07 thread B follow-up -> same 400 request req_a449da9f258145c8b4e560027e94c6ef 16:35:09 thread A follow-up -> same 400 request req_c6430001df3b4eafb7b1d53fd454ac53 16:35:53 fresh native thread started in the same app-server process 16:37:02 fresh native thread: POST /v1/responses -> 200 auth_retry_after_unauthorized="false" auth_error="400" auth_error_code=""Upstream comparison and workaround#
- PR #33713 proposes changing managed Codex to a positive token-helper refresh interval. It remains open.
- PR #36643, shipped in v0.1.12, recovers
invalid_encrypted_content. This incident returnedcode: nullwith an explicit authorization-error header, so that recovery does not match it. - v0.1.12 still configures
refresh_interval_ms=0; updating alone is not expected to resolve this failure. - No local fix or restart was performed. On Codex 0.166.0, starting a fresh native thread succeeded. Restarting T3 Code should replace the provider process and its cached authentication.
Investigated and posted at the affected user's explicit request by Codex (
gpt-daybreak-blue-latest, max reasoning) via T3 triage. No credentials, account identifiers, home paths, private prompts, or raw session logs are included.Note
AI submission from GPT-6.2 Astra, running in the Codex harness in T3 Code on behalf of Karrade7.
Tested PR #33713 on macOS arm64. We hit the generic authorization 400 on our live T3 0.1.13 installation. I merged PR head
a56aa471ea87into our fleet fork locally and tested the resulting tree with Codex 0.172.0. In the localhost reproduction below, I repeated the rotation with the PR’s actual 60,000 ms interval and deliberately invalidated A immediately after Codex cached it.The next turn sent A and received 400. After 61 seconds, I retried in the same chat and app-server process. Codex called the helper once, sent B, and received 200. With the original zero interval, even a fresh chat in that process still sent A. This confirms recovery on a subsequent request for
POST /v1/responses; the failed turn required a retry. All 79 focused provider tests and the fork’scheck:changedpassed. The rotation test used dummy credentials. A full token lifetime with real ChatGPT OAuth and the catalog behavior on/v1/modelsremain unverified by this test.I reproduced the stale credential on
POST /v1/responseswith the real Codex 0.172.0 app-server on macOS arm64 and the managed-provider settings from T3 0.1.13. The local endpoint records which dummy bearer it actually receives, so this test can distinguish a stale credential from a server rejecting the current one.Test Bearer observed by the endpoint Result Baseline, helper returns A A 200 Rotate helper and endpoint to B, keep process running, refresh_interval_ms=0A 400 Open a fresh chat in that same process A 400 Restart only the test app-server, keep the same helper and config B 200 Repeat rotation with a 250 ms refresh interval, wait 550 ms, send the next turn in the same process B 200 The helper had zero calls during the failing turns and one during the successful post-rotation turn with a positive interval. The 250 ms interval keeps the fixture quick. This tests the inference path relevant to #44218 and complements the catalog test in #33713.
In the live incident, both the existing chat and a fresh chat in the same process received
x-openai-authorization-error: 400with the genericBad Requestbody. The live logs omit the credential identity. The fixture deliberately returns the same error when told to reject a current bearer, so the error body alone cannot establish which credential the live request sent.Runnable localhost reproduction (Python 3, Codex 0.172.0 on PATH)
Save as
reproduce_credential_rotation.pyand runpython3 reproduce_credential_rotation.py. It uses a temporary Codex home, a dummy token helper, and a loopback Responses endpoint."""Run a localhost-only differential test of Codex managed-provider token rotation.""" import json import os from pathlib import Path from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer import queue import shutil import subprocess import sys import tempfile import time import threading import uuid MODEL = "gpt-6.2-astra" def run(root, binary): helper = root / "get-token" helper.write_text( "#!/bin/sh\n" 'cd "$(dirname "$0")" || exit 1\n' 'echo call >> helper-calls\n' 'cat helper-value\n' ) helper.chmod(0o700) issued = root / "helper-value" issued.write_text("dummy-A") state = {"accepted": "A", "reject_all": False} observed = [] class Endpoint(BaseHTTPRequestHandler): def log_message(self, *args): pass def do_GET(self): body = json.dumps({"models": [], "data": []}).encode() self.send_response(200) self.send_header("Content-Type", "application/json") self.end_headers() self.wfile.write(body) def do_POST(self): self.rfile.read(int(self.headers.get("Content-Length", 0))) if self.path != "/v1/responses": self.send_error(404) return # Record only known dummy labels. Never print authorization headers. label = {"Bearer dummy-A": "A", "Bearer dummy-B": "B"}.get( self.headers.get("Authorization"), "unexpected" ) ok = label == state["accepted"] and not state["reject_all"] observed.append((label, 200 if ok else 400)) self.send_response(200 if ok else 400) if not ok: self.send_header("Content-Type", "text/plain") self.send_header("x-openai-authorization-error", "400") self.end_headers() self.wfile.write(b'{"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}') return self.send_header("Content-Type", "text/event-stream") self.end_headers() response_id = "resp_" + uuid.uuid4().hex events = [ {"type": "response.created", "response": {"id": response_id}}, {"type": "response.completed", "response": { "id": response_id, "status": "completed", "output": [], "usage": {"input_tokens": 10, "output_tokens": 1, "total_tokens": 11}, }}, ] for event in events: self.wfile.write(("data: " + json.dumps(event) + "\n\n").encode()) server = ThreadingHTTPServer(("127.0.0.1", 0), Endpoint) server_thread = threading.Thread(target=server.serve_forever, daemon=True) server_thread.start() url = f"http://127.0.0.1:{server.server_port}/v1" codex_home = root / "codex" codex_home.mkdir() (codex_home / "config.toml").write_text(f''' model = "{MODEL}" model_provider = "openai_token_sharing" [features] api_key_model_discovery = true multi_agent = false multi_agent_v2 = false [model_providers.openai_token_sharing] name = "OpenAI Token Sharing" base_url = "{url}" model_catalog_url = "{url}/models" wire_api = "responses" requires_openai_auth = false supports_websockets = false [model_providers.openai_token_sharing.auth] command = {json.dumps(str(helper))} args = [] timeout_ms = 80000 refresh_interval_ms = 0 ''') env = {"HOME": str(root), "CODEX_HOME": str(codex_home), "PATH": os.defpath, "TMPDIR": str(root), "NO_PROXY": "127.0.0.1,localhost", "HTTPS_PROXY": "http://127.0.0.1:1", "HTTP_PROXY": "http://127.0.0.1:1"} def session(phase, interval_ms): config = codex_home / "config.toml" content = config.read_text().replace("refresh_interval_ms = 0", f"refresh_interval_ms = {interval_ms}") config.write_text(content) with (root / "stderr").open("a") as stderr: proc = subprocess.Popen([binary, "app-server"], text=True, cwd=root, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr) inbox = queue.Queue() def read(): for line in proc.stdout: inbox.put(json.loads(line)) inbox.put(None) threading.Thread(target=read, daemon=True).start() def send(message): proc.stdin.write(json.dumps(message) + "\n") proc.stdin.flush() def wait_for(predicate): while True: message = inbox.get(timeout=20) if message is None: raise RuntimeError("app-server exited") if predicate(message): return message def rpc(request_id, method, params): send({"id": request_id, "method": method, "params": params}) reply = wait_for(lambda m: m.get("id") == request_id) if "error" in reply: raise RuntimeError(reply["error"]) return reply["result"] try: rpc(1, "initialize", {"clientInfo": {"name": "rotation-test", "version": "1"}, "capabilities": {"experimentalApi": True}}) send({"method": "initialized", "params": {}}) conv = rpc(2, "thread/start", {"model": MODEL, "cwd": str(root), "approvalPolicy": "never", "ephemeral": True})["thread"]["id"] def turn(i, scenario, expected, status): before = len(observed) calls_file = root / "helper-calls" def calls(): return len(calls_file.read_text().splitlines()) if calls_file.exists() else 0 prior = calls() result = rpc(i, "turn/start", {"threadId": conv, "input": [{"type": "text", "text": "hello"}]}) event = wait_for(lambda m: m.get("method") == "turn/completed" and m["params"]["turn"]["id"] == result["turn"]["id"]) actual = event["params"]["turn"]["status"] requests = observed[before:] print(f"{scenario}: helper calls={calls()-prior}, requests={requests}, turn={actual}", flush=True) if requests != [expected] or actual != status: raise RuntimeError(f"Unexpected result: {event['params']['turn'].get('error')}") if phase == "original": turn(3, "Baseline", ("A", 200), "completed") state["accepted"] = "B" issued.write_text("dummy-B") turn(4, "Rotate while running", ("A", 400), "failed") conv = rpc(5, "thread/start", {"model": MODEL, "cwd": str(root), "approvalPolicy": "never", "ephemeral": True})["thread"]["id"] turn(6, "New chat in the same process", ("A", 400), "failed") elif phase == "restart": turn(3, "New process, same configuration and helper", ("B", 200), "completed") state["reject_all"] = True turn(4, "Endpoint rejects even the current credential", ("B", 400), "failed") else: turn(3, "Positive refresh interval, baseline", ("A", 200), "completed") state["accepted"] = "B" issued.write_text("dummy-B") time.sleep(0.55) turn(4, "Positive refresh interval, after rotation", ("B", 200), "completed") finally: proc.terminate() try: proc.wait(3) except subprocess.TimeoutExpired: proc.kill() proc.wait() try: session("original", 0) session("restart", 0) state.update(accepted="A", reject_all=False) issued.write_text("dummy-A") session("positive_interval", 250) finally: server.shutdown() server.server_close() if __name__ == "__main__": binary = shutil.which("codex") if not binary: sys.exit("codex must be on PATH") print(subprocess.check_output([binary, "--version"], text=True).strip(), flush=True) with tempfile.TemporaryDirectory(prefix="t3-rotation-") as tmp: run(Path(tmp).resolve(), binary)A measurement for people hitting the hourly 400 form of this, with the workaround others named above (
setupMode: "existing", the CLI login).On macOS arm64, T3 Code 0.1.11, managed Codex fails every running turn with a bare 400 about once an hour (
x-openai-authorization-error: 400). I added a second Codex provider instance that uses thecodexbinary aftercodex login, and moved two threads to it. Both threads had failed on the managed instance in the burst before.At the next burst (09:20–09:22Z, 2026-11-29), 8 threads on the managed instance failed. The 2 threads on the CLI-login instance ran from 08:53Z to 09:40Z across that burst with 0 error events. So a thread that already failed on managed recovers when you switch it to the CLI-login instance and resume it.
Two practical notes:
- T3 refuses a provider change while a turn is active ("has an active turn"), so switch each thread after its turn ends.
- In the provider log, count
"method":"error"events only. The text "Bad Request" also shows up in echoed user messages, which inflates a plain grep.
The CLI login stores a refresh token and Codex refreshes it itself, so it does not depend on #33713. Same symptom on the Codex side: openai/codex#63960.
Sign in to join this conversation.
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:
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:
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.