Skip to content

fix(models): share model support checks across selection and spawn - #150128

Merged
obviyus merged 18 commits into
mainfrom
fix/model-resolution-admission
Sep 17, 2026
Merged

obviyus merged 18 commits into
mainfrom
fix/model-resolution-admission

Conversation

@obviyus

@obviyus obviyus commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Model resolution, both spawn paths, catalog publication, aliases, and Doctor change together so unsupported selections cannot bypass the shared decision. Most added lines are regression tests.

What Problem This Solves

A saved Grok → xai/auto alias could create a child that the native API rejected. A custom provider name could also make retired native auto appear usable in the picker. Provider recognition and an endpoint URL were being treated as model support. Refs #115617, #142136.

Why This Change Was Made

Spawn and prepared aliases use the existing model resolver. Catalog publication and Doctor consume the same compiled retirement rules for the selected route. The catalog uses main's shared projection owner from #150509. Prepared aliases have one writer; Doctor keeps its existing config and session writers.

User Impact

Unsupported explicit choices fail before child creation with recovery guidance. Automatic choices retain their primary and fallback order. Picker views omit known retired routes; the admin inventory retains saved definitions. Custom endpoints and logical provider/account choices remain intact.

Compatibility

Native IDs need a definition, catalog support, or provider-owned resolution. This deliberately replaces #125931's endpoint-only inference: previously accepted unlisted native IDs need explicit definitions when their provider cannot resolve them. Custom/local endpoints, authored private models, and models supplied by native runtimes remain supported. Doctor repairs known retirements, preserves account pins and allowlists, and retains unresolved choices with guidance. It does not invent definitions for unverified IDs. No new configuration keys, schema, or protocol changes.

Evidence

  • The real Gateway regression fails with the browse filter removed and passes with it restored: retired native personal/auto disappears, while custom endpoint and admin inventory controls remain intact. Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts src/gateway/server.models-native-retirement.test.ts.
  • Final package 08e2f6002888 passed upgrades driven by published 2026.9.3 and 2026.9.4, followed by candidate startup and existing/new/custom conversations. Both preserved the seven original transcript events. All 26 Doctor commands passed, including repeated repair, logical native aliases, custom models, account pins, and allowlists.
  • Both upgraded fixtures passed all 10 Telegram Test Server controls: retired/unknown rejection, native/custom/friendly-alias completion, and correct picker buttons. The previously missing 2026.9.3 custom-model reply is now observed.
  • Four final-build Gateway cases passed: native account/history continuity, saved-token selection, a new reply across a 60-second process freeze, and recovery after a settled failure. Each matched exactly one intended test and left no child processes.
  • Source coverage includes 172 model/Doctor/Gateway tests, 220 affected fixture tests, and focused delivery, hook, lifecycle, and compaction checks; these counts overlap. Production/test types, lint, formatting, size limits, assertion limits, exports, architecture, and test registration checks passed.

Limits: updater tests use --no-restart followed by separate candidate startup. The first 2026.9.3 update hit its shipped 30-second package-scan limit; the retained installation was verified intact, and one normal retry after a measured 11-second scan succeeded. Telegram uses the real Test Server with local model fixtures. An extra final-package fallback run completed through the Gateway and Telegram accepted its sends, but the recorder timed out before capturing user-side receipt; that run is not counted as passed. Earlier b12d66a91bc1 fallback runs retain their original identity and successful observations.

Consumers

Visible/background spawn, prompt aliases, model materialization, picker publication, and Doctor use the shared support facts. No public SDK contract changes.

Invalidation

Existing config, catalog, account, and plugin owners control freshness. Alias hints belong to the prepared turn snapshot. Admission rechecks freshness after asynchronous resolution.

Tests

Coverage includes native/custom/private models, selected routes, namespace identity, pins, fallback order, stale generations, and repeated Doctor repair. A separate follow-up answer defect from #149223 remains behind #126263's task-ownership prerequisite; its assertion remains active and this PR does not claim to fix it.

Screenshots

Packaged comparison at b12d66a91bc1: native Personal Auto is removed, while custom Private Auto remains.

Before After
Before: native Auto is selectable After: native Auto is removed and custom Auto remains

Final-package model-list responses match both pictured comparisons. The native metadata remains readable: model name, 1M context, and Medium thinking.

Before After
Before model picker After model picker
Production changes: +707 lines

The added code implements shared admission, native alias support, and Doctor repair. It adds no state manager or configuration surface.

File Net Responsibility
cli-runner/helpers.ts +4 Pass prepared aliases
cli-runner/prepare.ts 0 Use async prompt preparation
cli-runner/prompt-context.ts +33 Capture the existing prepared owner
model.configured-fallback.ts +10 Apply shared support rules
model.configured-overrides.ts +60 Validate selected transport support
model.provider-hooks.ts -53 Defer hook binding through the existing resolver
model.provider-hooks.types.ts +31 Keep existing hook types separate
model.provider-transport.ts +35 Relocate existing transport resolution
model.registry-resolution.ts -40 Remove competing resolution paths
model.static-catalog-row.ts +36 Relocate existing row conversion
model.static-catalog.ts +64 Reuse canonical native metadata
model.static-catalog.types.ts +2 Keep donor facts in the existing cache
model.ts +13 Share resolution and recovery errors
prepared-compaction-runtime.ts +1 Pass prepared aliases
attempt-system-prompt-prepare.ts +1 Pass prepared aliases
model-catalog-visibility.ts +20 Filter retirement after route projection
model-runtime-choice.ts +224 Share admission across spawn paths
openclaw-tools.ts 0 Use current session configuration
prepared-model-runtime.configured-completion.ts +88 Prepare aliases without inventing catalog rows
prepared-model-runtime.full-catalog.ts +9 Publish captured alias facts
prepared-model-runtime.types.ts +2 Represent derived alias facts
materialize-model.ts +4 Share final route validation
subagent-spawn-child-plan.ts -96 Remove separate admission checks
subagent-spawn-deps.ts -3 Remove obsolete dependency surface
subagent-spawn-plan.ts +42 Consume shared admission
subagent-spawn.runtime.ts -1 Remove obsolete argument
system-prompt-config.ts -2 Render supplied facts only
sessions-spawn-visible.ts 0 Use common async admission
commands-models.ts -4 Use captured retirement metadata
commands-system-prompt.ts +8 Capture prompt facts before rendering
model-runtime-normalization.ts +9 Relocate existing normalization
codex-route-session-repair.ts 0 Use the session repair module
retired-model-ref-repair.ts +8 Use selected-route retirement policy
retired-session-model-repair.ts +59 Relocate existing session repair
models-list-result.ts +1 Pass captured metadata
manifest-model-suppression.ts +136 Compile native retirement policy once
manifest-model-suppression.types.ts +6 Carry effective route facts

@clawsweeper

clawsweeper Bot commented Sep 16, 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 agents Agent runtime and tooling extensions: xai size: XL maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 17, 2026, 2:50 AM ET / 06:50 UTC (Revision 7).

ClawSweeper review

What this changes

Shares model-support checks across child-agent creation, model resolution, prompt aliases, and pickers, and extends Doctor repair to retired native xAI selections.

Merge readiness

⛔ Blocked before merge - 5 items remain

This PR remains useful: current main still accepts endpoint-only native model fallbacks and does not retire native API xAI auto selections. No discrete blocking code defect was found. The updated evidence resolves the earlier package-verification gap, while the intentional compatibility change still warrants owner acceptance.

Priority: P2
Reviewed head: 08e2f6002888b085eabe7eaa8b9de0f2cf31d300
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful consolidated implementation with strong behavior and upgrade evidence; the compatibility tradeoff remains an owner decision rather than a newly identified code defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured final-package observations exercise shared admission, picker retirement, and Doctor through upgraded Gateways and Telegram Test Server controls, including custom-model completion and account/history preservation. Inspected screenshots corroborate visible behavior at their original build identities; the explicitly incomplete extra fallback recording is excluded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured final-package observations exercise shared admission, picker retirement, and Doctor through upgraded Gateways and Telegram Test Server controls, including custom-model completion and account/history preservation. Inspected screenshots corroborate visible behavior at their original build identities; the explicitly incomplete extra fallback recording is excluded.
Evidence reviewed 10 items Verified introduced scope: The local merge-base-to-head comparison supplies the complete file list beyond the truncated prompt. The checkout is the pinned original head; the supplied stale test merge was not used to infer removal of current-main behavior.
Current main still has the reported acceptance gap: Current main's fallback predicate accepts a configured endpoint without a model definition; the PR replaces that inference with route-aware support checks. Current main also lacks the new shared spawn admission function.
Native API retirement remains absent on main: The current-main xAI manifest restricts auto retirement to the subscription host. The PR adds the native API host and applies retirement after effective-route projection.
Findings None None.
Security None None.

How this fits together

OpenClaw combines saved model choices, provider catalogs, account information, and plugin metadata before starting an agent. These changes make selection, child-agent creation, picker visibility, and Doctor repair consume consistent support and retirement decisions.

flowchart TD
  A[Saved choices and aliases] --> C[Prepared model and account facts]
  B[Provider catalogs and plugin metadata] --> C
  C --> D[Support and retirement checks]
  D --> E[Agent and child creation]
  D --> F[Picker and prompt aliases]
  D --> G[Doctor repair or recovery guidance]
Loading

Decision needed

Question Recommendation
Should native model IDs previously accepted from endpoint configuration alone now require an explicit definition, catalog entry, or provider-owned resolution? Preserve default compatibility: Narrow unconditional rejection to verified unsupported or retired routes, leaving broader strict admission for an explicitly approved policy.

Why: The implementation and PR body deliberately change an established acceptance path; successful upgrade examples establish coverage but cannot decide whether that broader compatibility tradeoff is acceptable.

Before merge

  • Resolve merge risk (P1) - Existing selections using unlisted native model IDs can stop resolving after upgrade until explicitly defined or supported by a provider resolver; the successful upgrade fixtures do not eliminate this intentional compatibility change.
  • Complete next step (P2) - Obtain owner acceptance of rejecting previously accepted unlisted native model IDs, or narrow the restriction to preserve default compatibility.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +707; tests and test support net +2242 The growth is concentrated in regression coverage, with production additions justified by shared admission, native alias support, and route-aware Doctor repair.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/shared/codex-route-session-repair.ts, migration/backfill/repair: src/commands/doctor/shared/retired-session-model-repair.ts, unknown-data-model-change: src/commands/doctor/shared/retired-model-ref-repair.ts, unknown-data-model-change: src/commands/doctor/shared/retired-session-model-repair.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Narrow native rejection (recommended)
    Preserve endpoint-only compatibility for unverified native IDs while rejecting known retired selections through the shared owner.
  2. Approve the documented cutover
    Explicitly accept that some saved native IDs will require definitions after upgrade, using the supplied upgrade evidence to bound the decision.

Technical review

Best possible solution:

Keep one support owner and route-specific retirement repair, preserving default compatibility for unlisted native IDs unless the responsible owner explicitly accepts their rejection.

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

Yes, source establishes the path: a saved xAI auto alias on the native API can pass endpoint-only fallback acceptance, while main's retirement rule covers only the subscription host. This review did not execute the reproduction.

Is this the best way to solve the issue?

The shared resolver and retirement owner are a sound repair direction; whether rejecting every unlisted native ID is the best scope remains a compatibility decision.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs a bounded model-selection and child-creation problem without evidence of an emergency runtime outage.
  • merge-risk: 🚨 compatibility: The introduced support predicate intentionally rejects some native model selections accepted by the existing endpoint-only path.
  • 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 (live_output): The captured final-package observations exercise shared admission, picker retirement, and Doctor through upgraded Gateways and Telegram Test Server controls, including custom-model completion and account/history preservation. Inspected screenshots corroborate visible behavior at their original build identities; the explicitly incomplete extra fallback recording is excluded.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured final-package observations exercise shared admission, picker retirement, and Doctor through upgraded Gateways and Telegram Test Server controls, including custom-model completion and account/history preservation. Inspected screenshots corroborate visible behavior at their original build identities; the explicitly incomplete extra fallback recording is excluded.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The PR changes Telegram-visible model rejection and picker choices; the supplied Test Server observations cover those behaviors.

Evidence

What I checked:

  • Verified introduced scope: The local merge-base-to-head comparison supplies the complete file list beyond the truncated prompt. The checkout is the pinned original head; the supplied stale test merge was not used to infer removal of current-main behavior. (08e2f6002888)
  • Current main still has the reported acceptance gap: Current main's fallback predicate accepts a configured endpoint without a model definition; the PR replaces that inference with route-aware support checks. Current main also lacks the new shared spawn admission function. (src/agents/embedded-agent-runner/model.configured-overrides.ts:230, 8b9739cc48c0)
  • Native API retirement remains absent on main: The current-main xAI manifest restricts auto retirement to the subscription host. The PR adds the native API host and applies retirement after effective-route projection. (extensions/xai/openclaw.plugin.json:113, 8b9739cc48c0)
  • Intentional compatibility restriction: The introduced predicate preserves explicit definitions and custom/local endpoints, but rejects native routes lacking catalog support. The captured PR body explicitly acknowledges that previously accepted unlisted native IDs may require definitions; Doctor repairs known retirements rather than every affected ID. (src/agents/embedded-agent-runner/model.configured-overrides.ts:69, 08e2f6002888)
  • Shared admission and account preservation: Admission uses the target agent's policy, prepared account decisions, selected route, and existing model resolver; it checks freshness after asynchronous resolution and retains the original automatic candidate when a fallback is supported. Focused tests cover missing pins, incompatible subscription routes, native-owned models, and stale generations. (src/agents/model-runtime-choice.ts:15, 08e2f6002888)
  • Gateway boundary regression: The inspected regression starts a Gateway and requests models.list for prepared/full and default/configured views. It expects retired native rows to disappear, custom rows to remain available, and authored rows to remain in provider-config inventory. Tests were inspected, not executed during this read-only review. (src/gateway/server.models-native-retirement.test.ts:23, 08e2f6002888)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record owner acceptance of the native-ID restriction or narrow rejection to preserve default compatibility.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-16T15:34:32.059Z sha 36b9335 :: blocked before merge. :: none
  • reviewed 2026-09-16T17:01:08.640Z sha 2ad9153 :: blocked before merge. :: none
  • reviewed 2026-09-17T02:36:42.312Z sha 8afb413 :: blocked before merge. :: none
  • reviewed 2026-09-17T05:25:03.335Z sha b12d66a :: blocked before merge. :: none
  • reviewed 2026-09-17T06:15:16.328Z sha b12d66a :: blocked before merge. :: none
  • reviewed 2026-09-17T06:27:59.387Z sha 08e2f60 :: blocked before merge. :: none

@obviyus
obviyus marked this pull request as ready for review September 17, 2026 02:27
@obviyus
obviyus requested a review from a team as a code owner September 17, 2026 02:27
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 17, 2026
@obviyus obviyus changed the title fix(agents): validate model support before spawning fix(models): share model support checks across selection and spawn Sep 17, 2026
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 17, 2026
@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Sep 17, 2026
@obviyus
obviyus merged commit 5f17f89 into main Sep 17, 2026
377 of 379 checks passed
@obviyus
obviyus deleted the fix/model-resolution-admission branch September 17, 2026 07:09
@obviyus

obviyus commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Proof: Published 2026.9.3 and 2026.9.4 upgrades, 26 Doctor commands, and 20 Telegram controls passed on the final package.

  • Bug: Unsupported native model choices appeared usable and could create subagents that failed immediately.
  • Fix: Model selection and spawn share support checks. Doctor repairs known retirements while preserving custom routes and account choices.
Before After
Retired native Auto appeared selectable and could create a failing child. Retired native Auto is omitted from the picker and rejected before child creation; custom Auto remains usable.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…penclaw#150128)

Model resolution, both spawn paths, catalog publication, aliases, and Doctor change together so unsupported selections cannot bypass the shared decision. Most added lines are regression tests.

## What Problem This Solves

A saved `Grok → xai/auto` alias could create a child that the native API rejected. A custom provider name could also make retired native `auto` appear usable in the picker. Provider recognition and an endpoint URL were being treated as model support. Refs openclaw#115617, openclaw#142136.

## Why This Change Was Made

Spawn and prepared aliases use the existing model resolver. Catalog publication and Doctor consume the same compiled retirement rules for the selected route. The catalog uses main's shared projection owner from openclaw#150509. Prepared aliases have one writer; Doctor keeps its existing config and session writers.

## User Impact

Unsupported explicit choices fail before child creation with recovery guidance. Automatic choices retain their primary and fallback order. Picker views omit known retired routes; the admin inventory retains saved definitions. Custom endpoints and logical provider/account choices remain intact.

## Compatibility

Native IDs need a definition, catalog support, or provider-owned resolution. This deliberately replaces openclaw#125931's endpoint-only inference: previously accepted unlisted native IDs need explicit definitions when their provider cannot resolve them. Custom/local endpoints, authored private models, and models supplied by native runtimes remain supported. Doctor repairs known retirements, preserves account pins and allowlists, and retains unresolved choices with guidance. It does not invent definitions for unverified IDs. No new configuration keys, schema, or protocol changes.

## Evidence

- The real Gateway regression fails with the browse filter removed and passes with it restored: retired native `personal/auto` disappears, while custom endpoint and admin inventory controls remain intact. Command: `node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts src/gateway/server.models-native-retirement.test.ts`.
- Final package `08e2f6002888` passed upgrades driven by published 2026.9.3 and 2026.9.4, followed by candidate startup and existing/new/custom conversations. Both preserved the seven original transcript events. All 26 Doctor commands passed, including repeated repair, logical native aliases, custom models, account pins, and allowlists.
- Both upgraded fixtures passed all 10 Telegram Test Server controls: retired/unknown rejection, native/custom/friendly-alias completion, and correct picker buttons. The previously missing 2026.9.3 custom-model reply is now observed.
- Four final-build Gateway cases passed: native account/history continuity, saved-token selection, a new reply across a 60-second process freeze, and recovery after a settled failure. Each matched exactly one intended test and left no child processes.
- Source coverage includes 172 model/Doctor/Gateway tests, 220 affected fixture tests, and focused delivery, hook, lifecycle, and compaction checks; these counts overlap. Production/test types, lint, formatting, size limits, assertion limits, exports, architecture, and test registration checks passed.

Limits: updater tests use `--no-restart` followed by separate candidate startup. The first 2026.9.3 update hit its shipped 30-second package-scan limit; the retained installation was verified intact, and one normal retry after a measured 11-second scan succeeded. Telegram uses the real Test Server with local model fixtures. An extra final-package fallback run completed through the Gateway and Telegram accepted its sends, but the recorder timed out before capturing user-side receipt; that run is not counted as passed. Earlier `b12d66a91bc1` fallback runs retain their original identity and successful observations.

## Consumers

Visible/background spawn, prompt aliases, model materialization, picker publication, and Doctor use the shared support facts. No public SDK contract changes.

## Invalidation

Existing config, catalog, account, and plugin owners control freshness. Alias hints belong to the prepared turn snapshot. Admission rechecks freshness after asynchronous resolution.

## Tests

Coverage includes native/custom/private models, selected routes, namespace identity, pins, fallback order, stale generations, and repeated Doctor repair. A separate follow-up answer defect from openclaw#149223 remains behind openclaw#126263's task-ownership prerequisite; its assertion remains active and this PR does not claim to fix it.

## Screenshots

Packaged comparison at `b12d66a91bc1`: native Personal Auto is removed, while custom Private Auto remains.

| Before | After |
| --- | --- |
| ![Before: native Auto is selectable](https://gist.githubusercontent.com/obviyus/edbedb48d37b680d54f2047d457376e2/raw/86ad7e678f0160bdc9fc4809b7e2e930750f12bf/retirement-before-8afb413.png) | ![After: native Auto is removed and custom Auto remains](https://gist.githubusercontent.com/obviyus/edbedb48d37b680d54f2047d457376e2/raw/86ad7e678f0160bdc9fc4809b7e2e930750f12bf/retirement-after-b12d66a.png) |

Final-package model-list responses match both pictured comparisons. The native metadata remains readable: model name, 1M context, and Medium thinking.

| Before | After |
| --- | --- |
| ![Before model picker](https://gist.githubusercontent.com/obviyus/edbedb48d37b680d54f2047d457376e2/raw/ce7158ba21ac5a4e9bf4d592febf86647bcbd899/before-picker.png) | ![After model picker](https://gist.githubusercontent.com/obviyus/edbedb48d37b680d54f2047d457376e2/raw/a4053b9fb3e81d74ecd505cbf7041a10c827fa98/after-picker.png) |

<details>
<summary>Production changes: +705 lines</summary>

The added code implements shared admission, native alias support, and Doctor repair. It adds no state manager or configuration surface.

| File | Net | Responsibility |
| --- | ---: | --- |
| `cli-runner/helpers.ts` | +4 | Pass prepared aliases |
| `cli-runner/prepare.ts` | 0 | Use async prompt preparation |
| `cli-runner/prompt-context.ts` | +33 | Capture the existing prepared owner |
| `model.configured-fallback.ts` | +10 | Apply shared support rules |
| `model.configured-overrides.ts` | +60 | Validate selected transport support |
| `model.provider-hooks.ts` | -55 | Defer hook binding through the existing resolver |
| `model.provider-hooks.types.ts` | +31 | Keep existing hook types separate |
| `model.provider-transport.ts` | +35 | Relocate existing transport resolution |
| `model.registry-resolution.ts` | -40 | Remove competing resolution paths |
| `model.static-catalog-row.ts` | +36 | Relocate existing row conversion |
| `model.static-catalog.ts` | +64 | Reuse canonical native metadata |
| `model.static-catalog.types.ts` | +2 | Keep donor facts in the existing cache |
| `model.ts` | +13 | Share resolution and recovery errors |
| `prepared-compaction-runtime.ts` | +1 | Pass prepared aliases |
| `attempt-system-prompt-prepare.ts` | +1 | Pass prepared aliases |
| `model-catalog-visibility.ts` | +20 | Filter retirement after route projection |
| `model-runtime-choice.ts` | +224 | Share admission across spawn paths |
| `openclaw-tools.ts` | 0 | Use current session configuration |
| `prepared-model-runtime.configured-completion.ts` | +88 | Prepare aliases without inventing catalog rows |
| `prepared-model-runtime.full-catalog.ts` | +9 | Publish captured alias facts |
| `prepared-model-runtime.types.ts` | +2 | Represent derived alias facts |
| `materialize-model.ts` | +4 | Share final route validation |
| `subagent-spawn-child-plan.ts` | -96 | Remove separate admission checks |
| `subagent-spawn-deps.ts` | -3 | Remove obsolete dependency surface |
| `subagent-spawn-plan.ts` | +42 | Consume shared admission |
| `subagent-spawn.runtime.ts` | -1 | Remove obsolete argument |
| `system-prompt-config.ts` | -2 | Render supplied facts only |
| `sessions-spawn-visible.ts` | 0 | Use common async admission |
| `commands-models.ts` | -4 | Use captured retirement metadata |
| `commands-system-prompt.ts` | +8 | Capture prompt facts before rendering |
| `model-runtime-normalization.ts` | +9 | Relocate existing normalization |
| `codex-route-session-repair.ts` | 0 | Use the session repair module |
| `retired-model-ref-repair.ts` | +8 | Use selected-route retirement policy |
| `retired-session-model-repair.ts` | +59 | Relocate existing session repair |
| `models-list-result.ts` | +1 | Pass captured metadata |
| `manifest-model-suppression.ts` | +136 | Compile native retirement policy once |
| `manifest-model-suppression.types.ts` | +6 | Carry effective route facts |

</details>

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant