Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(codex): accept ChatGPT Edu Plus accounts #7869

ClosedExotic209093(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/7869/headopened View on GitHub

Codex 0.148.0 added new ChatGPT plan types (edu_plus, edu_pro). T3 Code decodes account/read responses against a pinned protocol schema whose planType union predates those plans, so every OpenAI request on an Edu account fails with "Invalid payload for method 'account/read' during 'decode-payload'". Codex 0.149.1 adds three more (self_serve_business_prolite, ent26, enterprise_cbp_automation), so this keeps recurring.

The five generated __PlanType unions now decode an unrecognized member to "unknown". They're #[serde(other)] catch-alls upstream and already list "unknown", so this matches what serde does with a plan the binary knows and the pinned schema doesn't. scripts/generate.ts applies it during codegen, so a protocol bump keeps the behavior, and it throws if such a union stops being a literal union or loses its catch-all rather than quietly dropping the fallback.

The helper follows ForwardCompatibleArray in packages/contracts/src/baseSchemas.ts, which already handles the same problem for arrays whose element unions grow over time.

An earlier revision normalized planType inside decodeOptionalPayload. Review caught that this walked every method's payload by key name, so a planType in opaque data (MCP tool arguments, structuredContent, and the other 173 Schema.Unknown fields) was rewritten before handlers saw it, and every thread and notification payload was cloned for a field almost none carry. decodeOptionalPayload is untouched in this revision; a regression test pins that opaque tool arguments keep their own planType.

Fixes #7828

Co-authored with @bitconym, who generated the schema from codex 0.149.1 and identified the full set of missing plan values.

ox-alpha via opencode


Note

Medium Risk Touches request payload decoding for account (and any nested planType) responses. The change is a conservative fallback, but a bug here could mis-classify plans or hide real decode failures.

Overview Stops account/read from failing when Codex reports newer ChatGPT plans (e.g. edu_plus) that the pinned protocol schema does not include.

Before schema decode, decodeOptionalPayload now walks object payloads and rewrites unrecognized planType strings to "unknown", matching Codex’s #[serde(other)] fallback. Known plans are left unchanged.

Adds unit and mock-peer coverage so Edu-style plans decode instead of raising invalid-payload errors.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 04f3a2850534aab6b2c6357a6194ececc12c7baa. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Accept unknown account plan types in codex client by decoding to "unknown"

ChatGPT Edu Plus accounts return a planType the client schema does not recognize, causing decode failures. This PR introduces a ForwardCompatibleLiterals schema helper that maps any unrecognized string to a designated fallback while preserving normal encoding.

  • Adds ForwardCompatibleLiterals in forwardCompatible.ts, composing Schema.String with a transform that decodes unknown values to "unknown"
  • Updates the code generator in generate.ts to wrap any enum matching /__PlanType$/ with ForwardCompatibleLiterals, and emits the corresponding import in the generated schema
  • Regenerates schema.gen.ts so V2GetAccountResponse__PlanType and related constants now use the forward-compatible wrapper
  • Adds unit and integration tests covering unknown-plan decoding through the client; the mock peer in codex-app-server-mock-peer.ts now reads planType from an env var for test control
  • Risk: applyForwardCompatibleEnum in generate.ts throws on malformed Schema.Literals shapes — any future generator change that alters the literal-union pattern will fail the build until the regex is updated
Macroscope summarized 6916ee5.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 4676644d-ef97-4b24-ac5b-4c1b08303bc2

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 04f3a28505

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -19,0 +31,21 @@
      31+ "business",
      32+ "enterprise_cbp_usage_based",
      33+ "enterprise",
      34+ "edu",
      35+ "unknown",
      36+]);
      37+
      38+export const normalizeUnknownPlanTypes = (value: unknown): unknown => {
      39+ if (Array.isArray(value)) {
      40+ return value.map(normalizeUnknownPlanTypes);
      41+ }
      42+ if (typeof value !== "object" || value === null) {
      43+ return value;
      44+ }
      45+
      46+ return Object.fromEntries(
      47+ Object.entries(value).map(([key, child]) => [
      48+ key,
      49+ key === "planType" && typeof child === "string" && !KNOWN_PLAN_TYPES.has(child)
      50+ ? "unknown"
      51+ : normalizeUnknownPlanTypes(child),

      P2 Badge Preserve opaque planType fields outside account payloads

      When a decoded response or notification contains opaque tool data—such as MCP results or dynamic-tool arguments with an application field like planType: "premium"—this key-only recursive walk silently rewrites it to "unknown". Those values are represented by Schema.Unknown in the generated protocol and should pass through unchanged, but decodeOptionalPayload is shared by every method, so unrelated thread and tool payloads are corrupted; restrict normalization to the actual account and rate-limit plan paths.

      Useful? React with 👍 / 👎.

      @@ -31,4 +67,6 @@
      3167 );
      3268 }
      3369
      34- return Schema.decodeUnknownEffect(schema)(raw).pipe(
      70+ return Schema.decodeUnknownEffect(schema)(
      71+ typeof raw === "object" && raw !== null ? normalizeUnknownPlanTypes(raw) : raw,
      72+ ).pipe(

      P2 Badge Avoid cloning every decoded protocol payload

      Because every object-shaped call to decodeOptionalPayload takes this branch, the normalizer recursively walks and reconstructs complete thread/list, thread/read, and notification payloads even though almost none contain an account plan. Large thread snapshots therefore incur an additional full traversal and allocation pass before schema decoding, while frequent notifications create unnecessary object churn; gate normalization to plan-bearing methods or handle the fallback in the relevant plan schemas instead.

      AGENTS.md reference: AGENTS.md:L15-L17

      Useful? React with 👍 / 👎.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Would Approve

      Macroscope's review found this PR approvable — This is a focused Codex protocol-compatibility fix that changes only plan-schema decoding, preserving known values and opaque payloads while accepting newer account plans as "unknown." The final revision includes targeted coverage and removes the earlier recursive-normalization approach that caused the reported review concerns.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Confirmed this same failure on macOS with Codex CLI 0.149.1, but for a different newly added plan:

      Codex app-server provider probe failed: Invalid payload for method 'account/read' during 'decode-payload'.

      A redacted direct account/read probe showed:

      {
        "account": {
          "type": "chatgpt",
          "planType": "self_serve_business_prolite"
        }
      }

      I also generated the current protocol schema directly from Codex 0.149.1 with:

      codex app-server generate-json-schema --experimental --out /tmp/codex-schema

      Compared with T3's pinned PlanType enum, the current Codex schema has five additional values:

      • self_serve_business_prolite
      • ent26
      • enterprise_cbp_automation
      • edu_plus
      • edu_pro

      So the generic unknown-plan normalization in this PR is the right forward-compatible behavior and fixes the Business ProLite case too. I locally extended the decoder regression test to exercise all five values; both focused test files passed (11 tests), as did package typecheck and formatting.

      The internal KNOWN_PLAN_TYPES name may be clearer as PINNED_PLAN_TYPES: it represents values understood by T3's pinned schema, not a complete OpenAI plan registry. There does not appear to be a documented public HTTP API for enumerating these values; the Codex-generated app-server schema is the machine-readable source tied to the installed CLI version.

    6. I pushed the verified follow-up on a branch and opened Exotic209093/t3code#2 against this PR's head branch. Merging that small PR will add coverage for all five current Codex plan values missing from T3's pinned schema.

    7. Rescoped in 6916ee5 to address the correctness and allocation findings. Both were right.

      The recursive walk in decodeOptionalPayload matched on key name across every method's payload, so a planType string in opaque application data — MCP tool arguments, structuredContent, and the other 173 Schema.Unknown fields in the generated protocol — was rewritten before handlers saw it. I added a test that reproduced it against the real ServerRequest__DynamicToolCallParams schema and watched it fail: { planType: "premium" } in tool arguments came back as "unknown".

      The fallback now lives on the five generated __PlanType unions instead, following the ForwardCompatibleArray idiom already in packages/contracts/src/baseSchemas.ts. Those unions are #[serde(other)] catch-alls upstream and already carry "unknown", so folding an unrecognized member into it is what serde does anyway. decodeOptionalPayload is byte-identical to main again, which also settles the payload-cloning comment: nothing outside a plan field is traversed or reallocated.

      scripts/generate.ts applies this during codegen, so a protocol bump keeps the behavior. It throws if a __PlanType union stops being a literal union or loses its catch-all member rather than quietly dropping the fallback.

      Coverage now spans the five values codex 0.149.1 emits that the pinned schema lacks (self_serve_business_prolite, ent26, enterprise_cbp_automation, edu_plus, edu_pro), the account/updated notification path, and the opaque-arguments regression above. Thanks to @bitconym for generating the current schema and finding the full set; that work is in this branch with credit.

      Verified: 25/25 in packages/effect-codex-app-server, typecheck clean on the package and apps/server, lint and fmt clean. I also ran generate end to end to confirm it emits the fallback for exactly those five unions.

      One thing I deliberately left out. HookSource, ThreadSourceKind, RateLimitResetType, RateLimitResetCreditStatus, and WorkspaceMessageType are the same kind of catch-all and will fail the same way when codex adds a member. Widening FORWARD_COMPATIBLE_ENUM_PATTERN to cover them is a one-line change, but it seemed wrong to answer a scope complaint by broadening scope. Happy to do it here or in a follow-up, whichever you prefer.

    8. Note

      🤖 GPT-6 Astra (preview) responding on behalf of Theo

      This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened.

      Closing the reported account-plan compatibility fix as superseded by merged #8447. Current main accepts all five plan values listed here, including edu_plus and self_serve_business_prolite. The schema-local fallback for unknown future values is a separate compatibility improvement, not a remaining failure for these accounts.

Sign in to join this conversation.