Skip to content

Codex context override can fall back to 272k after 2026.6.1 OpenAI route unification #90448

Closed

Description

@ooiuuii

Summary

After the OpenAI/Codex route unification in 2026.6.1, a 5.28-era Codex context override can be lost: openai/gpt-5.5 running through the Codex runtime no longer reads models.providers.openai-codex.models[].contextTokens, so sessions can fall back to the Codex runtime default 272000 instead of the configured ~1M cap.

This looks like a regression of the behavior fixed in #77858 / #77861, not a general session-context preservation issue.

Real environment observed

  • Windows OpenClaw node upgraded from 2026.5.28 to official 2026.6.1
  • Route after migration: openai/gpt-5.5 with agentRuntime.id = "codex"
  • Before the upgrade, the local config used a 5.28-style override under models.providers.openai-codex.models[]:
    • id: "gpt-5.5"
    • contextTokens: 1050000
  • After the 6.1 migration/repair, the active context display fell back to ~272k.

A read-only config probe after the upgrade showed no gpt-5.5 context override under the canonical models.providers.openai.models[] entry, so the 5.28-era override was not available to the 6.1 resolver.

Why this matters

#77861 intentionally made native Codex runs honor Codex OAuth context overrides. Its real behavior proof used exactly this kind of setup:

  • openai/gpt-5.5
  • Codex runtime
  • models.providers.openai-codex.models[].contextTokens: 1000000
  • expected /status / agentMeta.contextTokens around 1.0m

In 2026.6.1, OpenAI/Codex provider ids were unified. That is fine as a route/auth model, but legacy context-window metadata needs either migration or a compatibility fallback. Otherwise existing installs can silently lose their larger configured Codex context budget.

Source-level repro on current main

Current main resolves the context config provider for OpenAI routes to openai:

resolveContextConfigProviderForRuntime({ provider: "openai", runtimeId: "codex" })
// => "openai"

With a legacy 5.28-style config where the override still lives under openai-codex, the current resolver misses it and returns the fallback/default:

{
  "models": {
    "providers": {
      "openai-codex": {
        "models": [
          { "id": "gpt-5.5", "contextTokens": 1050000, "contextWindow": 400000 }
        ]
      },
      "openai": { "models": [] }
    }
  }
}

Observed with a local probe on current main:

{"name":"cfgLegacy","contextConfigProvider":"openai","tokens":272000}

If the same override is placed under canonical models.providers.openai.models[], the resolver returns the expected cap:

{"name":"cfgCanonical","contextConfigProvider":"openai","tokens":1050000}

Expected behavior

Upgrading/repairing a 5.28-era config should preserve the effective Codex context cap for openai/gpt-5.5 + codex runtime.

Either of these would be reasonable:

  1. migrate the relevant models.providers.openai-codex.models[].contextTokens/contextWindow metadata to the canonical models.providers.openai.models[] entry; or
  2. compatibility-read legacy openai-codex context metadata when the canonical openai model entry has no explicit context override.

Actual behavior

A legacy Codex override can be ignored after 6.1 provider unification, so the active budget can fall back to 272000.

Scope / non-goals

  • This is not about changing the default Codex runtime cap.
  • This is not about expanding the native Codex context engine or projection logic.
  • This is not about Preserve session context and durable Telegram progress #84828-style durable Telegram progress/session-context persistence.
  • The narrow scope is preserving existing configured context-window metadata across the OpenAI/Codex provider unification.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Current main has the canonical Doctor migration that preserves legacy per-model Codex context metadata under canonical OpenAI configuration, including the safe retained-versus-migrated handling requested by the maintainer discussion.

    Possible regression — suspected (reviewed change). No predecessor PR is attributed.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90448
    Summary: Current main implements the canonical safe migration; prior replacement PRs are closed and no longer own remaining work.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the Doctor-owned canonical migration and retain ambiguous legacy provider state with a warning rather than restoring a runtime fallback.

    Do we have a high-confidence way to reproduce the issue?

    No current-main reproduction was established: source and regression coverage show the reported legacy model metadata is migrated into the canonical OpenAI row before runtime lookup.

    Is this the best way to solve the issue?

    Yes. A Doctor-side per-model migration is the policy-aligned repair because runtime consumes only canonical OpenAI configuration and ambiguous provider defaults are retained rather than guessed.

    Security review:

    Security review: This issue has no proposed patch requiring a security review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • openperf: Authored the historical Doctor repair that preserved safely mappable legacy Codex model metadata. (role: introduced safe migration behavior; confidence: high; commits: e06f6ffc3e87; files: src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts)
    • steipete: Authored later OpenAI/Codex Doctor migration refactors and the current module split. (role: recent architecture contributor; confidence: medium; commits: 1bfd207a5405; files: src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts)
    • TurboTheTurtle: Authored the merged follow-through for persisting canonical Doctor route repairs across session state. (role: adjacent persistence contributor; confidence: medium; commits: 1e105d53406e; files: src/commands/doctor/shared/codex-route-session-repair.ts)

    Codex review notes: model internal, reasoning high; reviewed against 7b8bba26c953; fix evidence: commit 5cd2c5b07bf2, main fix timestamp 2026-08-05T16:38:59+01:00.

  2. added
    P2Normal backlog priority with limited blast radius.
    impact:data-lossCan lose, corrupt, or silently drop user/session/config data.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jun 4, 2026
  3. vincentkoc commented on Jun 15, 2026

    @vincentkoc
    Member

    Maintainer closeout: the reported Codex context-migration regression remains valid, but PRs #90451 and #92839 are closed because neither provides a safe migration contract across provider models, config/session routes, auth stores, and credential eligibility.

    The replacement should build one explicit per-model migration plan (migrated vs retained) and apply it consistently across every persisted/runtime surface. Partial preservation and unconditional openai-codex canonicalization both produced concrete credential/data-loss cases under fresh autoreview. Keeping this issue open for that canonical fix.

  4. ooiuuii commented on Jun 15, 2026

    @ooiuuii
    ContributorAuthor

    I opened a fresh replacement PR for this after the #90451/#92839 closeout: #93180.

    It uses one shared legacy openai-codex migration plan across provider migration, config route repair, and session route repair. The important behavioral split is migrated vs retained: doctor only rewrites migrated routes to canonical openai/*; retained routes keep their legacy provider/auth/runtime/session state and emit a manual-migration warning.

    Local validation:

    • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts src/commands/doctor/shared/codex-route-warnings.test.ts src/commands/doctor/shared/preview-warnings.test.ts
    • pnpm tsgo:test:src
    • git diff --check upstream/main...HEAD
  5. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    on Jun 15, 2026
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

    P2Normal backlog priority with limited blast radius.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions