Skip to content

fix(doctor): preserve model choices without retirement evidence - #178722

Merged
steipete merged 3 commits into
mainfrom
upd/upd-l1740
Oct 20, 2026
Merged

steipete merged 3 commits into
mainfrom
upd/upd-l1740

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor's legacy migration rewrites explicitly selected models before the provider/route-aware retirement owner can inspect them. It even rewrites a configured catalog row that still lists the selected model: openai/gpt-4.1-mini becomes openai/gpt-5.4-mini.

Fixes #169473. Supersedes #170742, thanks @MonkeyLeeT.

User Impact

Served models and selections with unknown retirement status retain their primary/fallback choices, profile suffixes, aliases, settings, and catalog IDs through Doctor and update-time config migration. This covers the old OpenAI, Claude, Copilot, Groq, and xAI name substitutions, including xAI web-search migration. Canonical spelling and provider-identity migrations remain supported.

Why This Change Was Made

Delete the competing name tables and Claude generation patterns. The existing provider catalog retirement declarations and route-aware repair owner remain responsible for genuine retirements and successor validation. The OpenAI manifest now also retains the served gpt-4.1 row so preserving that selection yields a usable prepared catalog. A model missing from the bundled catalog is insufficient evidence to replace it; undeclared retirements remain operator choices.

The nearby xAI migration still moves configuration/authentication into the owning plugin, without changing its model. The obsolete generation-rewrite test is replaced by preservation regressions; collision and prototype-safety tests now use genuine spelling aliases.

Production (including provider metadata): +38 / -272 (net -234). Tests: +89 / -206 (net -117). Documentation: +2. This follow-up adds 11 production metadata lines and changes the corpus test by +2/-1.

Evidence

  • Held-head regression repaired: legacy-roster.json selects openai/gpt-4.1. The deleted name table used to rewrite it to gpt-5.5, concealing that gpt-4.1 was missing from the bundled OpenAI catalog. Static preparation consults the manifest and the OpenAI static hook returns that same inventory; no row meant no prepared OpenAI entry. The operator fixture and its provider assertion are unchanged. The test additionally requires the original configured and catalog model IDs.
  • Provider evidence, retrieved October 20, 2026: OpenAI's GPT-4.1 model catalog lists the alias, text/image input, 1,047,576-token context, 32,768-token output, and $2/$8 input/output pricing ($0.50 cached input). The official deprecation schedule announces shutdown on January 14, 2027. It is deprecated but still served, so the new row records deprecation and its date without adding a retirement or rewriting the selection. The current models.dev OpenAI catalog independently contains the same ID and limits.
  • Full startup corpus: reproduced the held-head Bun failure (19 passed, 1 failed); fixed 20/20 on Bun and 20/20 on Node. Bun test-file duration: 90.26s, including transform time; runtime build preparation separately took 1m20.9s. Node test-file duration: 29.25s. Both exercise Doctor compatibility migration, persisted config, Gateway startup preparation, model inventory, and provider-login choices under isolated state.
  • Follow-up checks: config/CLI test typecheck, targeted oxlint/oxfmt, JSON parsing, git diff --check, and Madge (0 cycles) passed. Fresh independent Codex P0–P2 review of the repair found no actionable defects. Full check:changed SQLite inventory remains omitted under the campaign time budget.

Follow-up focused proof: 458 tests across 27 files passed (118 Doctor tests across eight files plus 340 OpenAI tests across 19 direct/one-hop consumer files), using the repository runner with isolated state and one worker. The known slow billing-route file used 171.435 seconds of test time; its deferred-retirement cases took 36.636s / 35.893s. No timeout, retry, or assertion was relaxed. The complete focused run finished in 313.60s. The installed-package upgrade gap noted by ClawSweeper remains unrun; this repair does not claim that proof or request a merge.

  • 118 distinct tests across eight focused files passed, covering preservation with/without a configured catalog, persisted utility choices, real declared retirements, missing accounts, custom routes, successor guards, and legacy migration. The initial unit run caught an obsolete assertion about the retired-model diagnostic path; that assertion was removed, retaining the observable config assertions, and the affected file passed on rerun.
  • Real CLI proof: pnpm openclaw doctor --fix --non-interactive ran with isolated HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH, synthetic config/credentials, and an unused local port. Base 1c4b27072712 replaced the OpenAI primary, Claude/Groq fallbacks, alias key, and catalog row. The candidate exited 0 and preserved every one of those fields. Its backup retained the original model selections. No authenticated provider inference or installed-package upgrade was run.
  • Production tsconfig.core.json and Doctor test test/tsconfig/tsconfig.core.test.commands-doctor.json type checks passed. Targeted oxlint, oxfmt, docs MDX validation, git diff --check, and Madge (0 cycles) passed. Independent Codex P0–P2 review found no actionable defects.
  • The lint wrapper repeatedly prepared SDK declarations and invalidated runtime build artifacts. Final lint used the same oxlint binary/config directly. Canary: debugger; failed with eslint(no-debugger) and exit 1; all changed TypeScript files then passed. The interrupted wrapper's task-owned lock was released only after its owner and descendants were verified stopped. The initial combined E2E setup consequently failed before tests; the successful E2E run reused the rebuilt runtime.
  • Known slow proof: the existing billing-route file used 179.842 seconds of test time. Its two deferred-retirement cases took 39.180s / 35.185s, each preparing Doctor three times to prove durable recovery. No timeouts, retries, or assertions were weakened. Runtime build preparation took 6m 30.9s, separately from test execution. The full check:changed SQLite inventory was omitted because of its known long-running inventory step; broad CI is pending.

Commands (all under isolated state; the first run exposed the obsolete diagnostic assertion, and the second reran the affected file plus the remaining suites):

node scripts/run-vitest.mjs \
  src/commands/doctor/shared/legacy-config-migrate.media-models.test.ts \
  src/commands/doctor/shared/legacy-config-migrate.test.ts \
  src/commands/doctor/shared/legacy-model-reference-migration.test.ts \
  src/commands/doctor/shared/xai-auto-retirement.test.ts \
  src/commands/doctor-retired-models.successor-guard.test.ts \
  src/commands/doctor-config-flow.billing-route.test.ts \
  src/commands/doctor/shared/legacy-web-tools-migrate.test.ts --maxWorkers=1
node scripts/run-vitest.mjs \
  src/commands/doctor/shared/legacy-config-migrate.media-models.test.ts \
  src/commands/doctor/shared/legacy-model-reference-migration.test.ts \
  src/commands/doctor/shared/xai-auto-retirement.test.ts \
  src/commands/doctor-retired-models.successor-guard.test.ts \
  src/commands/doctor-config-flow.billing-route.test.ts --maxWorkers=1
OPENCLAW_E2E_USE_PREBUILT_DIST=1 node scripts/run-vitest.mjs \
  src/commands/doctor/shared/legacy-config-migrate.e2e.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental \
  --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.commands-doctor.json \
  --incremental --tsBuildInfoFile .artifacts/tsgo-cache/commands-doctor.tsbuildinfo
node scripts/check-madge-import-cycles.ts

Follow-up corpus commands, each with HOME and OPENCLAW_STATE_DIR under this worktree's .artifacts/, and a runtime-specific module cache:

OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs \
  src/config/config-startup-corpus.test.ts --maxWorkers=1
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs \
  src/config/config-startup-corpus.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.config-cli.json \
  --incremental --tsBuildInfoFile .artifacts/corpus-repair/config-cli.tsbuildinfo

Remove name-only generation substitutions from legacy model normalization and
xAI search migrations. Leave retirement decisions with the existing provider
catalog and route-aware repair owner, preserving selections and their settings
when retirement is not established.

Fixes #169473

Co-authored-by: Ted Li <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: L labels Oct 20, 2026
@steipete
steipete marked this pull request as ready for review October 20, 2026 19:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T23:07:23.122530Z bf533a5 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR removes name-based model substitutions from Doctor while preserving spelling normalization and declared-retirement repair.

Example: Doctor repairs a configuration selecting openai/gpt-4.1-mini@openai:work.

  • Before: The legacy normalizer changes the selection to openai/gpt-5.4-mini@openai:work without checking retirement evidence.
  • After: The selection, profile suffix, alias, settings, and configured catalog ID remain unchanged unless the retirement owner establishes an applicable retirement.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful correction with no actionable finding; upgrade compatibility remains unproven.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Running Doctor or update-time migration silently replaces explicitly selected models and associated configuration without establishing retirement.
Reason: The maintainer-authored direction restores preservation of operator choices using existing owners, with no new option or parallel policy.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a current model-preservation defect, has maintainer-approved direction, and introduces no actionable code finding in this review.

Priority: P2
Reviewed head: 4ad356a22c4259d47e83093bd07e8845f4f9174d

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Show an installed upgrade from v2026.10.5 preserving model choices, aliases, settings, credentials, and existing data, followed by successful candidate startup; redact private endpoints and credentials.
Agent review details

How this fits together

Doctor normalizes saved configuration before validation and persistence; the separate retirement owner consumes provider declarations and authentication-route evidence to validate replacements.

flowchart TD
  A[Saved configuration] --> B[Doctor legacy migrations]
  B --> C[Spelling and identity normalization]
  C --> D[Route-aware retirement owner]
  E[Provider retirement declarations] --> D
  D --> F[Validated saved configuration]
  F --> G[Prepared model catalog]
Loading

Technical review

Best possible solution:

Keep spelling normalization separate from retirement decisions and finish compatibility validation through the installed updater.

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

Current-main source deterministically substitutes GPT-4.1 Mini without retirement evidence, and the supplied real Doctor comparison reports the corresponding persisted change; this review ran no target code.

Is this the best way to solve the issue?

Removing the competing policy is the smallest complete fix: preserve model identity during legacy normalization and leave genuine retirement decisions with the existing route-aware owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e2a44c21e27f.

Provenance checked

  • Legacy model-reference normalization changes intended behavior with a stated reason (4b9ff9d: The canonical-reference refactor consolidated repair across media, model maps, policies, and sessions while preserving explicit runtime and account choices.)
  • xAI web-search substitutions changes intended behavior with a stated reason (fix(xai): align current model catalog and tools #103260: The earlier change repaired generated stale rows and retired server-tool defaults; this PR explicitly leaves undeclared retirement decisions unchanged while retaining plugin/auth migration.)
  • Shared web-tool migration owner keeps the original intent (562129d: Centralize web-tool migration and preserve caller activation rules rather than maintain duplicated migration paths.)
  • GPT-4.1 bundled catalog restoration changes intended behavior with a stated reason (f4b5e58: The readable catalog diff removed older rows during aggressive catalog pruning; this PR explains that preserved GPT-4.1 selections require their prepared catalog entry.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 4b9ff9d adds src/commands/doctor/shared/legacy-config-migrations.runtime.models.refs.ts:93 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b9ff9dd206b; files: src/commands/doctor/shared/legacy-config-migrations.runtime.models.refs.ts)

PR surface

Source -234, Tests -117, Docs +2. Total -349 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 38 272 -234
Tests 6 89 206 -117
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 129 478 -349

Review metrics

Metric Value Why it matters
Production versus test changes Production and metadata +38/-272; tests +89/-206. The reduction removes competing retirement policy while retaining distinct preservation, collision, persistence, and startup contracts.

Labels

Label changes:

  • add P2: Doctor overwrites explicit model selections on a bounded set of provider/model inputs.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: Doctor overwrites explicit model selections on a bounded set of provider/model inputs.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the installed latest-stable upgrade result demonstrating preserved settings and data.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-20T19:56:30.040Z sha 416e1d9 :: blocked before merge. :: none

Reviewed October 20, 2026, 4:24 PM ET / 20:24 UTC (Revision 2).

Keep the still-served model in the OpenAI catalog instead of relying on
Doctor to replace the operator's choice. Preserve its deprecated status
and strengthen the unchanged operator corpus's identity assertions.

Co-authored-by: Ted Li <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf533a529b

ℹ️ 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".

Comment on lines +339 to +342
"input": ["text", "image"],
"contextWindow": 1047576,
"maxTokens": 32768,
"cost": { "input": 2, "output": 8, "cacheRead": 0.5, "cacheWrite": 0 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reuse the GPT-4.1 catalog row for live accounts

When an OpenAI API-key account's /models discovery succeeds and lists gpt-4.1, projectOpenAIAccountModels drops it because every pre-GPT-5 ID is filtered, and resolveOpenAIGptForwardCompatModel then returns buildOpenAIUncataloguedModel before consulting this manifest row. A preserved openai/gpt-4.1 selection therefore runs with generic 128k-context, 16,384-output, text-only, zero-cost metadata instead of the newly declared 1,047,576 context, 32,768 output, image support, and pricing. Reuse this manifest row in the pre-GPT-5 dynamic path, or retain exact catalog rows returned by discovery.

AGENTS.md reference: AGENTS.md:L18-L20

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 76734c4 into main Oct 20, 2026
114 of 117 checks passed
@steipete
steipete deleted the upd/upd-l1740 branch October 20, 2026 23:34
steipete added a commit that referenced this pull request Oct 21, 2026
Replace the stale name-only retirement expectation left by #178722
(76734c4). Preserve the configured model and assert that noncanonical
spelling still reports the plugins path without an agents section.
Check that diagnostics leave the authored model untouched.

Reproduced the hourly 39524896041 failure locally. Native wrapper proof:
54 tests pass across config-misc and legacy-config-migrate.media-models,
with one worker. Targeted typecheck, lint, formatting and P2 review pass.
steipete added a commit that referenced this pull request Oct 21, 2026
Match the model-preservation contract from #178722. The July fixture
explicitly selects Sonnet 4.5 and Opus 4.5; expect those same IDs in the
migrated allowlist instead of the removed name-only upgrade targets.

The complete composition file and related model-preservation tests pass
with one worker, as do targeted types, lint, format, and P2 review.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
)

Fixes openclaw#169473. Doctor rewrote configured models the provider still serves via hard-coded name-only substitution tables. Those tables are removed (-234 net production lines); model retirement is decided only by the existing provider-catalog and route-aware owner. The OpenAI catalog gains the still-served, deprecated openai/gpt-4.1 row (shutdown 2027-01-14) that the old rewrite had concealed. Spelling normalization, web-tool credential migration and legacy openai-codex provider migrations are unchanged. Supersedes openclaw#170742, thanks @MonkeyLeeT.

Co-authored-by: Ted Li <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
Replace the stale name-only retirement expectation left by openclaw#178722
(8dfbfc7). Preserve the configured model and assert that noncanonical
spelling still reports the plugins path without an agents section.
Check that diagnostics leave the authored model untouched.

Reproduced the hourly 39524896041 failure locally. Native wrapper proof:
54 tests pass across config-misc and legacy-config-migrate.media-models,
with one worker. Targeted typecheck, lint, formatting and P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
Match the model-preservation contract from openclaw#178722. The July fixture
explicitly selects Sonnet 4.5 and Opus 4.5; expect those same IDs in the
migrated allowlist instead of the removed name-only upgrade targets.

The complete composition file and related model-preservation tests pass
with one worker, as do targeted types, lint, format, and P2 review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. commands Command implementations docs Improvements or additions to documentation extensions: openai gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doctor rewrites model choices the provider still serves

1 participant