Repository navigation
Description
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.5withagentRuntime.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.contextTokensaround1.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:
- migrate the relevant
models.providers.openai-codex.models[].contextTokens/contextWindowmetadata to the canonicalmodels.providers.openai.models[]entry; or - compatibility-read legacy
openai-codexcontext metadata when the canonicalopenaimodel 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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 4, 2026
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:
canonicalCanonical: #90448
Summary: Current main implements the canonical safe migration; prior replacement PRs are closed and no longer own remaining work.
Members:
superseded: fix(doctor): gate legacy Codex canonicalization on a migration plan #93180 - The linked replacement is closed, while current main contains the requested per-model migration plan.superseded: fix(doctor): consolidate legacy Codex migration cleanup #90451 - The maintainer discussion closed this unsafe migration attempt; current main uses safe per-model mapping instead.superseded: fix(doctor): preserve legacy codex OAuth provider when no models are mergeable #92839 - The maintainer discussion identifies this closed attempt as lacking the required safe migration contract.adjacent_distinct: fix(doctor): repair legacy Codex route persistence #94478 - This merged follow-through concerns persistence of Doctor route repairs, not the primary metadata-transfer fix.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:
src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts:485, 5cd2c5b07bf2)src/commands/doctor/shared/legacy-config-migrate.test.ts:718, 5cd2c5b07bf2)src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts:560, 5cd2c5b07bf2)Likely related people:
src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts)src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts)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.
vincentkoc commentedon Jun 15, 2026
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 (
migratedvsretained) and apply it consistently across every persisted/runtime surface. Partial preservation and unconditionalopenai-codexcanonicalization both produced concrete credential/data-loss cases under fresh autoreview. Keeping this issue open for that canonical fix.ooiuuii commentedon Jun 15, 2026
I opened a fresh replacement PR for this after the #90451/#92839 closeout: #93180.
It uses one shared legacy
openai-codexmigration plan across provider migration, config route repair, and session route repair. The important behavioral split ismigratedvsretained: doctor only rewrites migrated routes to canonicalopenai/*; 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.tspnpm tsgo:test:srcgit diff --check upstream/main...HEAD