Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Codex (ChatGPT / openai_token_sharing) thread permanently wedges with opaque 400 Bad Request Provider error (0.1.11) #42969

Closedrasptum(GitHub profile, opens in a new tab) opened this issue 13 comments

Before submitting

  • I searched existing issues and did not find an exact duplicate with logs (possibly related to #42729).
  • I included enough detail to reproduce or investigate the problem.

Summary

On a Codex thread using Connect with ChatGPT (openai_token_sharing), a turn fails mid-flight with an opaque HTTP 400 Provider error:

{
  "error": {
    "message": "Bad Request",
    "type": null,
    "code": null,
    "param": null
  },
  "status": 400
}

Once this happens, the thread is permanently wedged:

  • Sending a follow-up message (e.g., continue) fails immediately (~2s) with the exact same 400 Bad Request.
  • Running compaction (thread/compact/start / contextCompaction) retries 5/5 (responseStreamDisconnected) and then fails with the exact same 400 Bad Request.
  • The only workaround is starting a fresh thread.

Environment

  • T3 Code: 0.1.11 (Beta, Desktop)
  • OS: Windows
  • Provider: codex (codex.app-server, modelProvider: "openai_token_sharing", Connect with ChatGPT / subscriptionSharing: true)
  • Codex CLI: 0.156.1
  • Model: gpt-6.2-sol (reasoningEffort: "low")
  • Context usage at failure: 111,689 / 258,400 tokens (well below context window; note Model metadata for gpt-6.2-sol not found. Defaulting to fallback metadata warning was also logged)

Observed behavior & protocol timeline

From ~/.t3/userdata/logs/provider/events.<thread>.log (sanitized):

  1. During an active turn (01a2139f-f6c0-7a23-b98a-d793fb251c19), two commandExecution items were in-flight (one interactive/background process receiving terminalInteraction events, plus a newly started command at 17:00:47.539Z).
  2. At 17:00:57.561Z, thread/tokenUsage/updated reported last.totalTokens = 111689 (modelContextWindow = 258400).
  3. At 17:00:58.187Z, the turn failed with systemError and codexErrorInfo: "other":
    {"method":"thread/status/changed","params":{"threadId":"<thread>","status":{"type":"systemError"}}}
    {"method":"error","params":{"error":{"message":"{\"error\":{\"message\":\"Bad Request\",\"type\":null,\"code\":null,\"param\":null},\"status\":400}","codexErrorInfo":"other","additionalDetails":null,"misalignment":null},"willRetry":false}}
    {"method":"turn/completed","params":{"turn":{"status":"failed","error":{"message":"{\"error\":{\"message\":\"Bad Request\",\"type\":null,\"code\":null,\"param\":null},\"status\":400}","codexErrorInfo":"other"}}}}
  4. 3–5 seconds after turn/completed (status: failed), both in-flight commandExecution items emitted item/completed (17:01:01.746Z and 17:01:03.124Z).
  5. User sent continue (turn/start at 17:01:16.722Z):
    • 17:01:16.731Z: warning: Model metadata for \gpt-6.2-sol` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.`
    • 17:01:19.034Z (~2.3s later): failed immediately with the exact same 400 Bad Request (systemError).
  6. User triggered compaction (thread/compact/start at 17:03:57.505Z):
    • 17:03:57.526Z: item/started (type: "contextCompaction")
    • 17:03:59Z–17:04:04Z: Reconnecting... 1/5 through 5/5 (codexErrorInfo: {"responseStreamDisconnected":{"httpStatusCode":null}}, additionalDetails: "{\"error\":{\"message\":\"Bad Request\",\"type\":null,\"code\":null,\"param\":null},\"status\":400}")
    • 17:04:07.704Z: failed with systemError and the same 400 Bad Request.

Expected behavior

  1. The turn should not fail with an opaque 400 Bad Request mid-session, or if a provider 400 occurs (e.g., due to orphaned/out-of-order tool call state or malformed history after a failed turn), T3 Code should surface the real cause and/or offer a recovery path (such as continuing in a fresh Codex session) rather than leaving the thread permanently broken on every subsequent message and compaction attempt.
  • Possibly the same issue as #42729 (also reported on 0.1.11 with ChatGPT Provider error crashing the conversation until a new thread is created).
  • Similar permanent-wedging UX to #39101 (thread becomes permanently unusable on every retry).

Impact

Blocks work completely on the affected thread.

Workaround

Start a new thread (retrying, sending continue, or compacting the existing thread all fail with the same 400).

  1. tanstack-source added labelsbug

  2. I tried to reproduce this on the current build and could not.

    Commit b1360538c1 (origin/main). The upstream 400 itself needs first-party ChatGPT OAuth (openai_token_sharing), which no VM has, so I did not run the app against real Codex. I reproduced T3's half, the thread never recovering after the rejection, in the orchestration integration harness. I added an opaque-bad-request case to recovers invalid encrypted Codex history on the next prompt in apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts. In that case run 2 fails with code other and the reporter's exact message {"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}, and the test expects run 3 to finish in a fresh native session with history carried over. vp test run src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts -t "recovers invalid encrypted Codex history": the new case fails (expected 'failed' to equal 'completed': the follow-up resumes the same rejected native thread and fails again); the 6 existing cases pass. Pushed as factory/repro-42969 (088b67ddb6).

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  3. juliusmarminge closed this

  4. I'm having the same problem with Debian 13 and v0.1.11.

  5. This just happened a second time on a brand-new thread in the same T3 Code 0.1.11 (Windows) session, with an almost identical pattern — requesting a reopen, especially since:

    1. T3's recovery failure is already reproduced in factory/repro-42969 (088b67ddb6), and
    2. @Max-202547 also confirmed hitting the same issue on Debian 13 + v0.1.11.

    Side-by-side comparison of both occurrences (same session, openai_token_sharing, gpt-6.2-sol, Codex CLI 0.156.1)

    Occurrence 1Occurrence 2 (brand-new thread)
    Thread started16:05:34Z17:04:23Z
    First 400 Bad Request17:00:58Z18:01:17Z
    Elapsed thread age55m 24s56m 54s
    Context at failure111,689 / 258,400 tokens162,619 / 258,400 tokens (2 prior compactions succeeded earlier in the thread)
    State at failureMid-turn while a commandExecution was still in-flight past its 10s yield (item/started 17:00:47.539Z → tokenUsage 17:00:57.561Z → 400 17:00:58.187Z)Mid-turn while a commandExecution was still in-flight past its 10s yield (item/started 18:00:50.608Z → tokenUsage 18:01:00.627Z → 400 18:01:17.836Z)
    In-flight command completionEmitted item/completed ~5s after turn/completed (status: failed)Emitted item/completed 3m26s after turn/completed (status: failed)
    Next follow-up turnFailed in 2.3s with identical 400 Bad RequestFailed in 2.6s with identical 400 Bad Request

    Sanitized protocol excerpt from Occurrence 2

    // In-flight command started, yielded at 10s, then turn failed with opaque 400
    [18:00:50.608Z] item/started (type: commandExecution, id: call_Bmwokc4WTBMiLbsfYggtfhDg)
    [18:01:00.627Z] thread/tokenUsage/updated (last.totalTokens: 162619, modelContextWindow: 258400)
    [18:01:17.836Z] thread/status/changed (status: { type: "systemError" })
    [18:01:17.836Z] error (codexErrorInfo: "other", willRetry: false, message: "{\"error\":{\"message\":\"Bad Request\",\"type\":null,\"code\":null,\"param\":null},\"status\":400}")
    [18:01:17.839Z] turn/completed (status: "failed")
    [18:04:44.092Z] item/completed (type: commandExecution, id: call_Bmwokc4WTBMiLbsfYggtfhDg)
    
    // Follow-up turn resumes the same rejected native thread and fails immediately
    [18:04:51.306Z] turn/start
    [18:04:51.319Z] warning: "Model metadata for `gpt-6.2-sol` not found. Defaulting to fallback metadata..."
    [18:04:53.973Z] thread/status/changed (status: { type: "systemError" })
    [18:04:53.973Z] error (codexErrorInfo: "other", willRetry: false, message: "{\"error\":{\"message\":\"Bad Request\",\"type\":null,\"code\":null,\"param\":null},\"status\":400}")
    [18:04:53.977Z] turn/completed (status: "failed")

    Notable patterns for investigation

    1. Consistent ~55–57 minute mark: Both threads ran fine for ~55–57 minutes (Occurrence 2 even completed 2 compactions without issue) before hitting the first 400 Bad Request.
    2. Consistent in-flight commandExecution at failure: In both cases, the 400 landed while a command was still running past the 10s yield, and its item/completed arrived after turn/completed (status: failed).
    3. T3 recovery gap (already reproduced in factory/repro-42969): Even if the initial 400 originates upstream or in Codex's native thread state, T3 currently resumes the poisoned native thread on every subsequent prompt instead of recovering into a fresh native session with history carried over (as recovers invalid encrypted Codex history on the next prompt already does for other unrecoverable Codex history rejections).
  6. I hit the same repeated provider error on T3 Code Beta 0.1.12, macOS 27.2.1 (Apple Silicon), with the Codex provider and gpt-6.2-sol. I have had to restart T3 twice. In my case, fully restarting T3 let me continue the same thread with the same model.

    What I observed on November 25, 2026 (UTC):

    1. A long-running Codex turn was running browser and desktop-tool checks. It failed at 18:38:27 with the provider error below.
    2. I sent ordinary follow-up messages in the existing thread. They failed again at 18:38:51 and 18:39:10, about 1.4 and 1.3 seconds after their respective turns started, before a tool ran.
    3. I restarted T3 and sent another follow-up. At 18:39:47 the same thread and model started a run successfully and resumed tool work.
    {"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}

    The thread history has no provider request ID or more specific error. I don't have a deterministic trigger for the initial 400. The quick retry failures and recovery after a full T3 restart are what I can confirm. Could you reopen this for the 0.1.12 recurrence and investigate whether T3 can recover the session automatically?

  7. Another macOS reproduction on 0.1.11, with a likely root cause that I think explains this issue, and a request to reopen it.

    Setup: T3 Code (Beta) 0.1.11, macOS (arm64), managed Codex 0.171.0 (openai_token_sharing), gpt-6.2-sol, 4-5 Codex threads running at the same time.

    What I see: every codex app-server process that T3 spawns works for roughly an hour, then every /v1/responses request from that process gets 400 Bad Request, across all threads at once. Today it happened 7 times in a row. Time from process start to the first 400 (local time, UTC-3):

    process startfirst 400elapsed
    09:34:5810:26:0251 min
    10:28:0111:26:0158 min
    ~11:3612:31:18~55 min
    12:44:4813:31:5547 min
    13:38:2414:32:1854 min
    14:54:1715:34:3040 min
    15:35:2316:34:4159 min

    Once a process starts failing, no request from it succeeds again (checked in ~/.codex/logs_2.sqlite). New turns on the same threads fail about 1 s after starting. A fresh process works immediately.

    The response is not a 401. Codex logs it as:

    status=400 Bad Request, content-type: text/plain, content-length: 121
    x-openai-authorization-error: 400
    x-error-json: {"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}
    server: cloudflare

    (request ids: req_6cb4eab853e3445d9f4a16f4c305ba91, req_47194c69071844d19eed3729e62542fa)

    Likely cause: the managed provider is launched with refresh_interval_ms=0 (I confirmed it in the live process arguments). #33713 explains that with this value Codex keeps the token it fetched at launch for the whole life of the process and only re-runs the token helper after a 401 on the Responses path. Here the expired token is rejected with a 400 (x-openai-authorization-error), so that 401 recovery never runs and the process stays wedged. That matches the ~1 hour, the "all threads at once" pattern, and the fact that a new process fixes it. Other reports in this thread (55-57 min) fit too. I have not proven that the token is what expires, only that the evidence is consistent with it.

    Recovery without restarting T3: killing only the codex app-server child (SIGTERM) while T3 stays open works every time. T3 spawns a new one on the next message and the same threads continue. That also suggests the thread is not poisoned, the process is.

    This looks like the same root cause as #33701, and the fix in #33713 (a positive refresh_interval_ms plus the larger broker renewal margin) should cover this 400 as well. Could this be reopened, or linked to #33701/#33713?

    I'm happy to help verify a fix: I'm on a real ChatGPT account on macOS, so I can run a build with #33713 across a full token expiry and report back. I'm also running a local workaround (a launcher that rewrites refresh_interval_ms=0 to 30000, plus a watchdog that restarts a wedged process) and will report whether processes started with it survive past one hour.

    Posted on behalf of @wallynm, investigated with AI assistance in T3 Code. No tokens, account identifiers or private conversation content are included.

  8. Tstrife(GitHub profile, opens in a new tab)commented

    i'm having the exact same problem, macOS 27.2.1, T3 0.1.12.

  9. This message is generated by Isak, Jöran Omark's AI buddy.

    On Windows with T3 0.1.11 and Codex CLI 0.166.0 using openai_token_sharing, I found this sequence on November 25, 2026. All times are UTC.

    • 21:33:10.372 — T3 completed CodexChatGptAuth.exchange during its periodic provider refresh.
    • 22:32:55.861 — A second credential exchange completed during workspace skill discovery.
    • 22:32:55.990 — The affected conversation received HTTP 200 from POST /v1/responses.
    • 22:33:10.822 — The same conversation received HTTP 400 with x-openai-authorization-error: 400. OpenAI request ID req_6504386278264778ac601d41b291a643.

    The 400 arrived 3,600.450 seconds after the first exchange and 14.961 seconds after the second. These are client-side completion timestamps. One possible explanation is that the conversation still used the earlier credential. The logs don’t identify which credential it sent or when that credential expired.

  10. I can confirm this on macOS with T3 Code Beta 0.1.12, managed Codex 0.166.0 (“Connect with ChatGPT”), and gpt-6.2-astra. On Nov 25 I saw 11 failed Astra turns in three clusters roughly an hour apart. Retrying in the same thread kept returning “Bad Request.”

    In the clearest case, at 20:31:23 UTC, POST /v1/responses returned x-openai-authorization-error: 400. Codex logged auth_retry_after_unauthorized="false". I restarted T3, continued the same thread with the same model, and at 20:31:55 UTC the replacement Codex process received HTTP 200. No new thread or sign-in was needed.

    Could you reopen this to investigate automatic recovery from this authorization 400?

  11. This message is generated by Isak, Jöran Omark's AI buddy.

    Two more failures from Windows add a timing detail to wallynm's root-cause comment. On this machine the 400 arrives a few seconds after T3's own credential exchange, not at an arbitrary point in the hour.

    Setup: T3 Code 0.1.11 on Windows 11, managed Codex 0.166.0, openai_token_sharing, gpt-6.2-astra. The live codex app-server here was also launched with refresh_interval_ms=0.

    Overnight on 2026-11-26, two long turns failed with the generic {"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}. Each failure came 3 to 5 seconds after a CodexChatGptAuth.exchange span ended in T3's server trace:

    CodexChatGptAuth.exchange ends (UTC)Turn fails with the 400 (UTC, as T3 recorded it)
    01:48:53.93001:48:57
    02:49:13.34202:49:18

    The retained trace covered 01:27 to 03:27 UTC. It contained only these two exchanges, 60 min 19 s apart. A new thread started within a minute of each failure and ran normally. Including the case in my earlier comment, where the 400 came 15 s after the newer of two exchanges, all three 400s I've timed came within seconds of an exchange.

    One possible explanation: T3's exchange rotates or invalidates the credential that the long-lived process fetched at launch. That would explain why the rejection follows the exchange by seconds and why a fresh process works. With refresh_interval_ms=0 the old process never picks up the new credential. Because the rejection is a 400, not a 401, Codex's 401 recovery never runs. I have not seen which credential the failing requests carried, so this is inferred from timing only.

  12. Another reproduction on T3 Code Beta 0.1.12, macOS (Apple Silicon), Codex CLI 0.172.0, openai_token_sharing, gpt-6.2-sol. This one adds a timing detail: the failing process was only about 4 minutes old, so the trigger looks like the age of the credential, not the age of the process.

    Timeline (2026-11-26, UTC), from ~/.codex/logs_2.sqlite and ~/.t3/userdata/logs/server.trace.ndjson:

    timeevent
    13:26:46CodexChatGptAuth.exchange succeeds
    14:22:48new T3-spawned codex app-server (launched with refresh_interval_ms=0) makes its first /v1/responses request → 200
    14:25:48another CodexChatGptAuth.exchange succeeds
    14:26:39last 200 from this process (24 successful requests in total)
    14:26:47first 400, which is ~3,601 s after the 13:26:46 exchange
    14:26:47 / 14:26:48 / 14:27:07400 on two different threads at once, then on a follow-up turn

    Request IDs: req_7f3667a3b6fc4ed2814a5a097b590287, req_19ad555a038841d19987744a4425e817, req_8e108b8a967a4ea2a17ac154abd49998.

    The response is the same as in the earlier reports: content-type: text/plain, x-openai-authorization-error: 400, opaque Bad Request body. Codex logged auth_mode="ApiKey" and auth_retry_after_unauthorized="false", so the 401 recovery path never ran.

    Earlier the same day: a process failed at 08:26:40 UTC in the same way, and a fresh process at 08:28:16 UTC got 200 immediately on the same threads.

    Interpretation (inferred from timing, not proven): the process apparently started with a credential minted by the 13:26:46 exchange and kept it under refresh_interval_ms=0. That credential stopped working exactly one hour after it was minted, even though the process itself was only ~4 minutes old. The newer exchange at 14:25:48 did not reach the running process. If that's right, a process started shortly before a credential's 1h expiry fails within minutes. This fits the fix direction in #33701 / #33713: a positive refresh interval, or treating x-openai-authorization-error: 400 like a 401 and re-running the token helper.

    Could this be reopened?

    Investigated with AI assistance in T3 Code; no tokens or account identifiers included.

  13. Still happening here on Linux (Azure VM), Codex CLI 0.172.0, Connect with ChatGPT, models gpt-6.2-sol and gpt-6.2-astra (default and high reasoning effort), run as delegated child tasks.

    Same opaque error every time:

    {"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}

    Pattern on 2026-11-26 (5 failures):

    • Long-running child tasks (review/agent loops with many shell commands) fail mid-turn after a while. Each failure followed active command execution.
    • A brand-new child task started a few minutes after one of these failures failed on its first request, after 458 ms (task_complete with codex_error_info: "other", duration_ms: 458). So it is not only the old native thread being wedged: a fresh session failed immediately too.
    • Model metadata for gpt-6.2-sol not found. Defaulting to fallback metadata is logged, as in the original report.
    • features.enable_request_compression = false is already set, so compression is not the cause here.

    Workaround we use: keep Codex tasks short and start a new task rather than resuming. Happy to provide sanitized provider event logs.

  14. Same issue here. T3 Code Beta 0.1.11, Windows 10 Pro 19045, Codex provider.

    • A long Codex turn (many shell commands + file edits) finished its last command successfully (exit 0), then the turn failed with the exact opaque envelope: {"error":{"message":"Bad Request","type":null,"code":null,"param":null},"status":400}
    • A short plain-text follow-up in the same thread failed immediately with the same 400.
    • Handing the thread off to the Claude provider worked; the Codex side stayed wedged.
  15. Same issue on Linux (Ubuntu 26.04.1), T3 Code t3 CLI 0.1.11, managed Codex 0.172.0, openai_token_sharing, gpt-6.2-sol. Adding a data point for the reopen request, since the failing process here was young and the 400 followed a network error.

    Timeline (2026-11-27, UTC+5:30), from ~/.codex/logs_2.sqlite:

    timeevent
    17:10:35T3 spawns codex app-server (refresh_interval_ms=0); two long Codex turns in two threads run fine
    17:26:44one POST /v1/responses fails at the network level: is_timeout=false is_connect=true
    17:27:02next requests from both threads get 400 in the same second (process age ~16.5 min)
    17:35 / 17:41 / 17:53new threads fail on their first request, including one whose only message was .
    18:03kill -TERM <codex app-server pid> only; T3 respawns it, next turn gets 200 and no errors since

    Response headers on the first failures:

    status=400, content-type: text/plain, content-length: 121
    x-openai-authorization-error: 400
    x-openai-internal-caller: unknown_through_ide
    x-request-id: req_c43d5f8ebaab46429bfbff7bcd28e765
    x-request-id: req_21f2807f1c7e4c6b9671d0effb657d15

    While the process was failing, I ran the same Codex binary with the exact -c provider config and environment copied from the running app-server (codex exec ... -m gpt-6.2-sol "Reply with just: ok", run from /tmp and from the project directory). It returned 200, because it runs the token-sharing auth command again. Tool payloads in the failing requests were byte-identical to those in the requests that succeeded earlier. That points to the credential the long-lived app-server was still sending, not the account, the model, the thread history, or the tools.

    Workaround that avoids restarting T3: kill only the codex app-server process (pgrep -af 'codex app-server'). T3 respawns it on the next Codex turn.

Sign in to join this conversation.