fix(server): harden managed Codex ChatGPT sharing and recover rejected input history #46389
main fromrefs/pull/46389/head·opened View on GitHubProblem#
When using Codex through Connect with ChatGPT (openai_token_sharing), OpenAI's Subscription Sharing endpoint rejects unsupported capabilities and persisted input items (such as agent_message, encrypted_content, hosted image_generation, or non-default service_tier) with subscription_sharing_unsupported_capability (param: "input").
Once an unsupported item is persisted in a Codex rollout, every subsequent prompt in that thread fails permanently because ProviderTurnStartService's rejectedHistory recovery only checks invalid_encrypted_content. In addition, classifyCodexManagedError only looked for additional_tools (missing OpenAI's real param: "input" / Remove unsupported input items response), and CodexManagedRuntime did not disable features.image_generation, features.fast_mode, features.ultrafast_mode, or override service_tier from a shared ~/.codex/config.toml.
Fixes #39101 (also covers the param: "input" message classification gap described in #36207).
Fix#
apps/server/src/provider/CodexManagedRuntime.ts: Disablefeatures.image_generation=false,features.fast_mode=false,features.ultrafast_mode=false, and pinservice_tier="default"inmanagedCodexLaunchArgsso Codex CLI defaults or a shared~/.codex/config.tomlcannot send capabilities rejected by ChatGPT sharing.apps/server/src/provider/CodexManagedErrors.ts: Unwrap nested JSON error payloads insidemessage/additionalDetailssoparam: "input"and inner OpenAI messages are detected accurately, update the input-item failure message to tell the user sending another message continues in a fresh session, and exportisCodexRejectedHistoryFailure(coveringinvalid_encrypted_content, input-itemsubscription_sharing_unsupported_capability, and already-persisted legacy generic messages, while excludingtool namespacerejections).apps/server/src/orchestration-v2/ProviderTurnStartService.ts: UseisCodexRejectedHistoryFailure(item.failure)inrejectedHistoryso poisoned threads automatically abandon the rejected native Codex session and continue in a fresh session with a cleanfull_thread_summaryvisible-history handoff on the next prompt.
Verification#
- Found in real local Codex provider logs (
events._global.logandrollout-*.jsonlon Codex CLI 0.172.0 withopenai_token_sharing), where anagent_messageitem caused every follow-up prompt (even after switching models) to fail immediately withsubscription_sharing_unsupported_capability(param: "input"). vp test run apps/server/src/provider/CodexManagedErrors.test.ts— 7/7 passed (including real OpenAI JSON payload classification andisCodexRejectedHistoryFailurecases).vp test run apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts -t "recovers rejected Codex history on the next prompt"— 10/10 passed (sharing-input,sharing-raw-input, andsharing-legacyrecover into a fresh native thread generation with visible conversation handoff;sharing-namespacedoes not needlessly reset history).vp test run apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts -t "sharing|encrypted"— 5/5 passed.vp test run apps/server/src/provider/CodexManagedRuntime.test.ts -t "primary"— 2/2 passed (asserting all new managed launch args; the 2additional accounttests require Windows symlink privileges).vp run --filter t3 typecheck,vp lint,vp fmt --check, andvp run knip:check— all 0 errors.
Built with Gemini 4 Neon in Antigravity.
- 1
- 2
Pushed468b2ff
The automated pipeline stopped on this pull request and will not merge it:
the fix is written and reviewed, but proving it needs something no worker has:
- Permanent blocker: first-party ChatGPT OAuth is unavailable on every worker, and this reproduction requires a real managed Codex ChatGPT session with native history rejected as subscription_sharing_unsupported_capability (param=input). Recovery, explanatory errors, subsequent messages, model-switch retries, and managed-sharing capability restrictions could not be demonstrated. A replay agent or invented provider response would not prove this behavior.
It stays open for a person to finish or close.
juliusmarminge added labelstakeover:blocked
juliusmarminge removed labelstakeover:in-progress
Sign in to join this conversation.
coderabbitai[bot](GitHub profile, opens in a new tab) reviewed
60280f8d-7208-4e57-9294-7e8103c8b19cReviewing files that changed from the base of the PR and between 0b9b2bb3d4686331bc557f931c7971f3b7ae41a4 and 468b2ff7ce39593af4f5ffa722f981cb2d3f3d41.
apps/server/src/provider/CodexManagedErrors.test.tsapps/server/src/provider/CodexManagedErrors.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.