Skip to content

fix(doctor): consolidate legacy Codex migration cleanup#90451

Open
ooiuuii wants to merge 5 commits into
openclaw:mainfrom
ooiuuii:agent/xiaozhua/codex-context-override-migration
Open

fix(doctor): consolidate legacy Codex migration cleanup#90451
ooiuuii wants to merge 5 commits into
openclaw:mainfrom
ooiuuii:agent/xiaozhua/codex-context-override-migration

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR consolidates legacy Codex/OpenAI doctor migration cleanup after the OpenAI/Codex provider unification.

  • When both canonical models.providers.openai and legacy models.providers.openai-codex exist, doctor now copies missing positive context metadata from the legacy provider before removing it.
  • Migrated metadata includes contextTokens, contextWindow, and maxTokens at provider/model scope.
  • Canonical openai values remain authoritative: existing canonical metadata is not overwritten, explicit canonical provider-level context budgets are not overridden by stale legacy model rows, and contextTokens/contextWindow are treated as one context-budget group so legacy data cannot reverse runtime precedence.
  • Model ids are matched across scoped/unscoped legacy forms such as gpt-5.5, openai/gpt-5.5, and openai-codex/gpt-5.5; scoped canonical OpenAI rows are normalized back to runtime-readable unscoped ids before metadata is copied.
  • Session-store doctor repair also normalizes stale openai-codex/* model refs when the persisted session provider is already canonical openai, so stored model/modelOverride fields become runtime-readable unscoped ids such as gpt-5.5.
  • This replaces earlier runtime-fallback/shim approaches with update/doctor repair paths; runtime routing remains unified under openai.

Why now: 2026.5.28-era installs could store Codex context overrides under models.providers.openai-codex.models[]. After 2026.6.1 unification, configs that already had canonical models.providers.openai would remove the legacy provider without carrying over that context metadata, causing unified OpenAI/Codex routes to fall back to lower default context budgets.

Out of scope: runtime fallback/shims, changing Codex defaults, changing OAuth/auth routing, or restoring closed runtime write-boundary behavior. This PR only repairs persisted config/session state during doctor/update.

Linked context

Closes #90448

Related #77858
Related #77861

Consolidates the useful doctor-side session-store edge case from closed PR #90662.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: doctor/config migration removes legacy models.providers.openai-codex during OpenAI/Codex route unification. It must preserve legacy Codex contextTokens / contextWindow / maxTokens without turning those Codex-only provider defaults into broad canonical models.providers.openai provider defaults for unrelated OpenAI models. It must also repair stale persisted sessions with modelProvider: "openai" but model / modelOverride still scoped as openai-codex/gpt-*.
  • Real environment tested: macOS local OpenClaw source checkout on this PR branch (agent/xiaozhua/codex-context-override-migration, current PR head 2226e281030) using the real LEGACY_CONFIG_MIGRATIONS doctor migration pipeline. The original regression shape comes from official OpenClaw upgrades across the 2026.5.28 → 2026.6.1 OpenAI/Codex unification.
  • Exact steps or command run after this patch:
node --import tsx - <<'EOF'
import { LEGACY_CONFIG_MIGRATIONS } from './src/commands/doctor/shared/legacy-config-migrations.ts';
function migrate(raw) {
  const changes = [];
  for (const migration of LEGACY_CONFIG_MIGRATIONS) migration.apply(raw, changes);
  return { providers: raw.models.providers, changes };
}
// Scenario 1: canonical OpenAI has an unrelated embeddings model; legacy Codex provider
// has provider-level budgets plus a disjoint Codex chat model. The embeddings row must
// not inherit the Codex context budget.
const unrelatedCanonicalModel = migrate({
  models: { providers: {
    openai: { api: 'openai-chatgpt-responses', models: [{ id: 'text-embedding-3-small', name: 'OpenAI embeddings' }] },
    'openai-codex': { api: 'openai-codex-responses', baseUrl: 'https://chatgpt.com/backend-api/codex', contextTokens: 1050000, contextWindow: 1050000, maxTokens: 16384, models: [{ id: 'gpt-5.5', name: 'Legacy Codex GPT-5.5' }] },
  } },
});
// Scenario 2: provider-level legacy budgets must still land on a matching canonical row
// while a second disjoint Codex model is merged.
const matchingPlusDisjoint = migrate({
  models: { providers: {
    openai: { api: 'openai-chatgpt-responses', baseUrl: 'https://api.openai.com/v1', models: [{ id: 'openai/gpt-5.5' }] },
    'openai-codex': { api: 'openai-codex-responses', baseUrl: 'https://chatgpt.com/backend-api/codex', contextTokens: 1050000, contextWindow: 1050000, maxTokens: 16384, models: [{ id: 'openai-codex/gpt-5.5' }, { id: 'gpt-5.6', name: 'Legacy Codex GPT-5.6' }] },
  } },
});
// Scenario 3: if provider-level Codex budgets cannot be mapped to a model row, doctor
// keeps the legacy provider for manual migration instead of copying budgets to all OpenAI.
const unmappedProviderBudget = migrate({
  models: { providers: {
    openai: { api: 'openai-chatgpt-responses', models: [{ id: 'text-embedding-3-small', name: 'OpenAI embeddings' }] },
    'openai-codex': { contextTokens: 1050000, contextWindow: 1050000, maxTokens: 16384 },
  } },
});
console.log(JSON.stringify({ unrelatedCanonicalModel, matchingPlusDisjoint, unmappedProviderBudget }, null, 2));
EOF
  • Evidence after fix:
{
  "unrelatedCanonicalModel": {
    "providers": {
      "openai": {
        "api": "openai-chatgpt-responses",
        "models": [
          {
            "id": "text-embedding-3-small",
            "name": "OpenAI embeddings"
          },
          {
            "id": "gpt-5.5",
            "name": "Legacy Codex GPT-5.5",
            "baseUrl": "https://chatgpt.com/backend-api/codex",
            "api": "openai-chatgpt-responses",
            "contextWindow": 1050000,
            "contextTokens": 1050000,
            "maxTokens": 16384
          }
        ]
      }
    },
    "changes": [
      "Moved models.providers.openai-codex.api \"openai-codex-responses\"\"openai-chatgpt-responses\".",
      "Merged 1 model(s) from models.providers.openai-codex into models.providers.openai: gpt-5.5."
    ]
  },
  "matchingPlusDisjoint": {
    "providers": {
      "openai": {
        "api": "openai-chatgpt-responses",
        "baseUrl": "https://api.openai.com/v1",
        "models": [
          {
            "id": "gpt-5.5",
            "contextTokens": 1050000,
            "contextWindow": 1050000,
            "maxTokens": 16384
          },
          {
            "id": "gpt-5.6",
            "name": "Legacy Codex GPT-5.6",
            "baseUrl": "https://chatgpt.com/backend-api/codex",
            "api": "openai-chatgpt-responses",
            "contextWindow": 1050000,
            "contextTokens": 1050000,
            "maxTokens": 16384
          }
        ]
      }
    },
    "changes": [
      "Moved models.providers.openai-codex.api \"openai-codex-responses\"\"openai-chatgpt-responses\".",
      "Normalized models.providers.openai.models[0].id to gpt-5.5 and copied contextTokens, contextWindow, maxTokens metadata.",
      "Merged 1 model(s) from models.providers.openai-codex into models.providers.openai: gpt-5.6."
    ]
  },
  "unmappedProviderBudget": {
    "providers": {
      "openai": {
        "api": "openai-chatgpt-responses",
        "models": [
          {
            "id": "text-embedding-3-small",
            "name": "OpenAI embeddings"
          }
        ]
      },
      "openai-codex": {
        "contextTokens": 1050000,
        "contextWindow": 1050000,
        "maxTokens": 16384
      }
    },
    "changes": [
      "Skipped removing models.providers.openai-codex because provider-level context metadata cannot be mapped safely to a canonical OpenAI model row."
    ]
  }
}
  • Observed result after fix: legacy Codex provider-level budgets are no longer copied onto canonical models.providers.openai. In the unrelated canonical model scenario, the existing text-embedding-3-small row remains budget-free while the merged Codex gpt-5.5 row receives the Codex base URL and context budget. In the matching-plus-disjoint scenario, the matching gpt-5.5 row and merged gpt-5.6 row both preserve Codex budgets. In the unmapped scenario, doctor keeps models.providers.openai-codex and emits a manual-migration change instead of silently broadening the budget to every OpenAI model. Existing canonical provider/model context budgets remain authoritative and are not overwritten. The session-store repair also preserves modelProvider: "openai" while rewriting stale openai-codex/gpt-* model/modelOverride values to unscoped gpt-* and clearing stale Codex runtime pins.
  • What was not tested: I did not install this PR branch onto a production Gateway or mutate an existing user config; this was validated with the real source-level doctor migration pipeline, focused tests, full migration tests, and local CI artifact build.
  • Before evidence: before this patch, provider-level legacy Codex context metadata could be copied onto canonical models.providers.openai, making Codex-only budgets fallback defaults for unrelated OpenAI models; in the earlier mixed path, provider-level budgets could also be skipped before deleting the legacy provider.

Tests and validation

Commands run after the current-head P1 fixes:

node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="legacy OpenAI Codex|context metadata|provider-level|mixed|unrelated canonical OpenAI"
node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts
node scripts/run-vitest.mjs src/commands/doctor/shared/codex-route-warnings.test.ts --testNamePattern="legacy Codex|canonical OpenAI"
git diff --check

Results:

focused provider/model migration: 10 passed, 113 skipped
full config migration: 123 passed
focused Codex route warnings: 6 passed, 105 skipped
oxfmt --check, oxlint, and git diff --check passed
pnpm build:ci-artifacts passed

Earlier validation retained by this PR:

node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="canonical OpenAI contextWindow metadata"
node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="legacy OpenAI Codex|context metadata|canonical OpenAI|scoped canonical"
node scripts/run-vitest.mjs src/commands/doctor/shared/codex-route-warnings.test.ts --testNamePattern="legacy Codex model refs under canonical OpenAI session providers"
node scripts/run-vitest.mjs src/agents/context.test.ts src/agents/context.lookup.test.ts --testNamePattern="contextTokens|contextWindow"
pnpm exec oxlint src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts src/commands/doctor/shared/legacy-config-migrate.test.ts src/commands/doctor/shared/codex-route-warnings.ts src/commands/doctor/shared/codex-route-warnings.test.ts
git diff --check

Regression coverage added:

  • Preserves legacy openai-codex.models[].contextTokens/contextWindow/maxTokens by creating canonical openai.models[] metadata when canonical OpenAI exists but has no matching model row.
  • Preserves legacy provider-level openai-codex.contextTokens/contextWindow/maxTokens on matching canonical OpenAI model rows when another disjoint legacy model must also be merged.
  • Normalizes existing scoped canonical OpenAI model rows such as openai/gpt-5.5 to runtime-readable gpt-5.5 before copying missing legacy metadata.
  • Merges only missing legacy metadata into canonical openai provider/model config.
  • Verifies canonical openai values are not overwritten by stale legacy Codex values.
  • Verifies the legacy provider is still removed after migration.
  • Verifies canonical OpenAI provider/model contextTokens and contextWindow remain authoritative over stale legacy Codex context-budget metadata, including the reverse contextWindow versus legacy contextTokens case, matching canonical model rows with provider-level budgets, and canonical model-level budgets over legacy provider defaults.
  • Repairs stale session-store shape modelProvider: "openai" + model/modelOverride: "openai-codex/gpt-*" to provider-separated gpt-* ids while clearing stale Codex runtime pins.

Risk checklist

Did user-visible behavior change? (Yes/No)

Yes. After running doctor/update migration, legacy Codex context metadata can continue to affect unified OpenAI/Codex context budgets via canonical models.providers.openai, and stale session model refs under canonical OpenAI providers are normalized to runtime-readable unscoped ids.

Did config, environment, or migration behavior change? (Yes/No)

Yes. Doctor migration now preserves missing context metadata before removing models.providers.openai-codex when canonical openai already exists, and session-store doctor repair handles one additional stale OpenAI/Codex model shape.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

No. This does not change auth, runtime provider routing, network behavior, or tool execution.

What is the highest-risk area?

Copying stale legacy context metadata into canonical openai where explicit canonical values should remain authoritative; additionally, normalizing only stale Codex-scoped session model refs without disturbing valid canonical provider/model pairs.

How is that risk mitigated?

The migration copies only positive numeric metadata, only for missing target fields, and tests cover canonical-wins behavior at provider and model scope. Session repair tests cover preserving canonical modelProvider: "openai", rewriting only stale openai-codex/* model refs to unscoped ids, and clearing stale Codex runtime pins.

Current review state

What is the next action?

Wait for CI and ClawSweeper re-review on current head 2226e281030.

What is still waiting on author, maintainer, CI, or external proof?

CI/ClawSweeper are pending after the latest provider-level budget scoping repair.

Which bot or reviewer comments were addressed?

Addressed ClawSweeper's P1 provider-level budget scoping finding, the mixed matching-plus-disjoint provider-budget finding, the earlier scoped canonical-row finding, and consolidated the useful doctor-side edge case from closed #90662 after maintainer feedback to consolidate remaining small migration PRs into a single PR.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 4, 2026
@clawsweeper

clawsweeper Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 7, 2026, 11:25 AM ET / 15:25 UTC.

Summary
The branch updates doctor legacy config and session repair to migrate legacy openai-codex context metadata into canonical openai model rows and unscope stale openai-codex/* session model refs under canonical OpenAI providers.

PR surface: Source +251, Tests +463. Total +714 across 4 files.

Reproducibility: yes. at source level. Current main resolves OpenAI/Codex context config through canonical openai, while Codex defaults in sibling source show the 272k fallback that legacy overrides need to avoid.

Review metrics: 1 noteworthy metric.

  • Doctor migration surfaces: 1 config-provider migration changed, 1 session-store repair changed. Both surfaces rewrite persisted upgrade state, so maintainers need compatibility and upgrade-scope confidence before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] The PR changes doctor/update behavior for persisted provider config, so a missed mapping rule would be upgrade-visible for existing OpenAI/Codex users.
  • [P2] The manual fallback intentionally leaves models.providers.openai-codex in place when provider-level budgets cannot be mapped to a model row, which is safer but may require operator cleanup for some legacy configs.
  • [P1] The session-store repair rewrites persisted model/modelOverride state, so merge review should keep the provider/model pairing invariant in focus even with green tests.

Maintainer options:

  1. Land the model-scoped doctor repair (recommended)
    Accept the upgrade risk with the current head because legacy context metadata is now scoped to matching or merged model rows and the observed head checks are green.
  2. Pause for migration policy review
    If maintainers want provider-level Codex budgets to remain fully automatic even without a model target, pause this PR and decide the permanent migration policy before merge.

Next step before merge

  • No ClawSweeper repair is needed; current head has no blocking review findings and is down to maintainer merge judgment for an upgrade-sensitive PR.

Security
Cleared: The diff changes doctor migration code and tests only; no dependency, workflow, credential, network, or new code-execution surface was introduced.

Review details

Best possible solution:

Land the doctor/update repair after maintainer review confirms the model-scoped migration policy, keeping the current regression coverage and avoiding runtime openai-codex fallback shims.

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

Yes, at source level. Current main resolves OpenAI/Codex context config through canonical openai, while Codex defaults in sibling source show the 272k fallback that legacy overrides need to avoid.

Is this the best way to solve the issue?

Yes. Doctor/update is the right layer under the repository policy, and current head scopes legacy provider metadata to model rows or a manual-warning path instead of adding runtime fallback readers.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 66b91d78feb3.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a real source checkout running the actual LEGACY_CONFIG_MIGRATIONS pipeline after the patch and showing the expected migrated state.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal output from a real source checkout running the actual LEGACY_CONFIG_MIGRATIONS pipeline after the patch and showing the expected migrated state.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a normal-priority upgrade migration fix for a real but bounded OpenAI/Codex context-budget regression.
  • merge-risk: 🚨 compatibility: The PR changes how existing openai-codex provider config is removed, preserved, or migrated during doctor/update.
  • merge-risk: 🚨 auth-provider: The migration rewrites legacy OpenAI/Codex provider and model routing metadata into canonical openai state.
  • merge-risk: 🚨 session-state: The PR changes doctor repair for persisted session model and modelOverride values.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal output from a real source checkout running the actual LEGACY_CONFIG_MIGRATIONS pipeline after the patch and showing the expected migrated state.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a real source checkout running the actual LEGACY_CONFIG_MIGRATIONS pipeline after the patch and showing the expected migrated state.
Evidence reviewed

PR surface:

Source +251, Tests +463. Total +714 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 259 8 +251
Tests 2 463 0 +463
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 722 8 +714

What I checked:

  • Repository policy applied: Root AGENTS.md was read fully; its provider routing, auth/session state, config migration, and Codex-source review requirements affected the compatibility and dependency checks for this PR. (AGENTS.md:13, 66b91d78feb3)
  • PR scopes legacy provider metadata to model rows: At PR head, legacy openai-codex context metadata is copied into existing canonical model rows via copyLegacyOpenAICodexContextMetadataToExistingCanonicalRows, and the manual-mapping branch keeps the legacy provider when provider-level context metadata has no model target. (src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts:1155, 2226e281030a)
  • Session repair stays provider-aware: The session repair change only unscopes stale Codex model refs when the persisted provider is already canonical openai; other stale Codex refs keep the existing canonical openai/... rewrite path. (src/commands/doctor/shared/codex-route-warnings.ts:2901, 2226e281030a)
  • Runtime lookup makes provider-scope metadata broad: Current main checks model-row context metadata first and then provider-level contextTokens/contextWindow, which is why the PR's model-scoped migration shape is the safer fix than copying legacy budgets onto canonical provider scope. (src/agents/context.ts:271, 66b91d78feb3)
  • Codex contract checked: Sibling Codex source shows the bundled gpt-5.5 default context window is 272000 and Codex model metadata applies model_context_window as a clamped override, matching the OpenClaw regression's 272k fallback and override-preservation goal. (sibling codex: codex-rs/models-manager/models.json:19, b89ce9a2bced)
  • Regression coverage added: The PR adds focused tests for missing canonical model merge, canonical-wins precedence, scoped canonical ID normalization, unrelated OpenAI model protection, mixed matching-plus-disjoint provider budgets, unmapped manual fallback, and canonical OpenAI stale session refs. (src/commands/doctor/shared/legacy-config-migrate.test.ts:542, 2226e281030a)

Likely related people:

  • Chunyue Wang: Authored the current safe merge path for legacy openai-codex models into canonical openai, which this PR extends. (role: recent area contributor; confidence: high; commits: e06f6ffc3e87; files: src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts, src/commands/doctor/shared/legacy-config-migrate.test.ts)
  • Vincent Koc: Current checkout blame attributes the surrounding doctor migration and session repair scaffolding to this recent commit across the central files. (role: recent adjacent contributor; confidence: medium; commits: 9fb8d87f91f8; files: src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts, src/commands/doctor/shared/codex-route-warnings.ts)
  • lilesjtu: Authored the merged native Codex context override work that defined the context-budget behavior this doctor migration preserves. (role: related behavior contributor; confidence: medium; commits: 58f81b0e04ef; files: src/agents/model-catalog.ts, src/agents/model-selection-shared.ts, src/status/status-message.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 4, 2026
@ooiuuii ooiuuii force-pushed the agent/xiaozhua/codex-context-override-migration branch from 7add989 to 3021712 Compare June 4, 2026 19:47
@ooiuuii ooiuuii force-pushed the agent/xiaozhua/codex-context-override-migration branch from 3021712 to ffb1873 Compare June 4, 2026 19:50
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 4, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 4, 2026
@ooiuuii ooiuuii force-pushed the agent/xiaozhua/codex-context-override-migration branch from ffb1873 to 02363e8 Compare June 4, 2026 19:58
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 4, 2026
@ooiuuii

ooiuuii commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the ClawSweeper recommendation in latest head 02363e8be1.

What changed:

  • Preserved the model-level legacy openai-codex fallback for official OpenAI + Codex runtime routes.
  • Added canonical OpenAI provider-level precedence: models.providers.openai.contextTokens/contextWindow now blocks stale legacy openai-codex.models[] fallback.
  • Added the focused regression: canonical provider-level defaults win over stale legacy model metadata.

Validation:

  • node scripts/run-vitest.mjs src/agents/openai-routing.test.ts src/agents/embedded-agent-runner/run/setup.test.ts --testNamePattern="context|provider-level|stale legacy"
  • node scripts/run-vitest.mjs src/agents/openai-routing.test.ts src/agents/embedded-agent-runner/run/setup.test.ts
  • git diff --check
  • Latest GitHub Actions run is green on the current head; older cancelled auto-response/label jobs are from superseded pushes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 4, 2026
@ooiuuii ooiuuii force-pushed the agent/xiaozhua/codex-context-override-migration branch from 02363e8 to 5ce5bf2 Compare June 5, 2026 12:16
@ooiuuii ooiuuii changed the title fix(codex): honor legacy context overrides after OpenAI unification fix(doctor): migrate legacy Codex context metadata Jun 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations and removed agents Agent runtime and tooling labels Jun 5, 2026
@clawsweeper

clawsweeper Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@ooiuuii

ooiuuii commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest ClawSweeper provider-level budget precedence finding in head 979c0b57b63.

What changed:

  • When canonical OpenAI has provider-level contextTokens/contextWindow, matching canonical model rows without budget fields no longer receive legacy Codex contextTokens/contextWindow.
  • The migration still normalizes scoped canonical model ids and can still copy missing maxTokens.
  • Added the requested regression for openai.contextTokens + openai.models[{ id: "openai/gpt-5.5" }] + legacy openai-codex.models[] context metadata.

Validation:

  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="provider-level context budgets authoritative|canonical OpenAI contextWindow metadata|canonical OpenAI provider-level context metadata|legacy OpenAI Codex|context metadata|canonical OpenAI|scoped canonical"
  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts
  • node scripts/run-vitest.mjs src/commands/doctor/shared/codex-route-warnings.test.ts --testNamePattern="legacy Codex|Telegram direct session routes|canonical OpenAI"
  • node scripts/run-vitest.mjs src/agents/context.test.ts src/agents/context.lookup.test.ts --testNamePattern="contextTokens|contextWindow"
  • pnpm exec oxlint src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts src/commands/doctor/shared/legacy-config-migrate.test.ts src/commands/doctor/shared/codex-route-warnings.ts src/commands/doctor/shared/codex-route-warnings.test.ts
  • git diff --check

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@clawsweeper

clawsweeper Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@ooiuuii

ooiuuii commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest ClawSweeper provider-default precedence finding in head 871e9df5f83.

What changed:

  • Legacy provider-level contextTokens/contextWindow are no longer copied into canonical models.providers.openai when canonical OpenAI already has any model-level context budget.
  • This keeps explicit canonical model budgets authoritative and avoids changing the runtime inheritance chain.
  • Non-budget metadata such as maxTokens can still copy when missing.
  • Added the requested regression for canonical model-level contextWindow plus legacy provider-level contextTokens.

Validation:

  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="model-level context budgets authoritative|provider-level context budgets authoritative|contextWindow metadata authoritative|provider-level context metadata|legacy OpenAI Codex|context metadata|canonical OpenAI|scoped canonical"
  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts
  • node scripts/run-vitest.mjs src/commands/doctor/shared/codex-route-warnings.test.ts --testNamePattern="legacy Codex|Telegram direct session routes|canonical OpenAI"
  • node scripts/run-vitest.mjs src/agents/context.test.ts src/agents/context.lookup.test.ts --testNamePattern="contextTokens|contextWindow"
  • pnpm exec oxlint src/commands/doctor/shared/legacy-config-migrations.runtime.models.ts src/commands/doctor/shared/legacy-config-migrate.test.ts src/commands/doctor/shared/codex-route-warnings.ts src/commands/doctor/shared/codex-route-warnings.test.ts
  • git diff --check

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 5, 2026
@ooiuuii ooiuuii force-pushed the agent/xiaozhua/codex-context-override-migration branch from 871e9df to 9652497 Compare June 7, 2026 13:45
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 7, 2026
@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@ooiuuii

ooiuuii commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current-head fix for the P1 mixed provider-budget finding is pushed at 32b9bbbca8c.

What changed:

  • preserve legacy openai-codex provider-level contextTokens / contextWindow / maxTokens on the matching canonical openai.models[] row when disjoint legacy models are also merged
  • keep canonical provider/model context budgets authoritative
  • add focused regression covering matching canonical row + disjoint legacy model + provider-level budget
  • refresh the PR body Real behavior proof with current-head migration output

Focused current-head checks passed:

  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="legacy OpenAI Codex|context metadata|provider-level|mixed"
  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts
  • node scripts/run-vitest.mjs src/commands/doctor/shared/codex-route-warnings.test.ts --testNamePattern="legacy Codex|canonical OpenAI"
  • git diff --check

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@ooiuuii

ooiuuii commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head 2226e281030 scopes legacy openai-codex provider-level contextTokens / contextWindow / maxTokens only to matching or merged canonical OpenAI model rows. It no longer copies those budgets onto broad models.providers.openai provider scope, and it keeps openai-codex for manual migration when no model target can be identified.

Validation on this head:

  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts --testNamePattern="legacy OpenAI Codex|context metadata|provider-level|mixed|unrelated canonical OpenAI" → 10 passed / 113 skipped
  • node scripts/run-vitest.mjs src/commands/doctor/shared/legacy-config-migrate.test.ts → 123 passed
  • node scripts/run-vitest.mjs src/commands/doctor/shared/codex-route-warnings.test.ts --testNamePattern="legacy Codex|canonical OpenAI" → 6 passed / 105 skipped
  • pnpm exec oxfmt --check ..., pnpm exec oxlint ..., and git diff --check passed
  • pnpm build:ci-artifacts passed locally

The PR body proof was refreshed with current-head migration output for unrelated canonical OpenAI models, matching-plus-disjoint Codex models, and unmapped provider-budget manual fallback.

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: blank-template Candidate: PR template appears mostly untouched. triage: refactor-only Candidate: refactor/cleanup-only PR without maintainer context.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant