Skip to content

refactor(models): preserve selected identities and centralize thinking policy - #150509

Merged
steipete merged 2 commits into
mainfrom
codex/model-policy-consolidation-20260916
Sep 17, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/model-policy-consolidation-20260916

Conversation

@steipete

@steipete steipete commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes selected models being renamed, reset, or assigned another model's thinking settings when aliases and saved choices pass through multiple selection paths.

User Impact

Pinned and configured models retain their literal identity across commands, replies, heartbeats, session lists, and pickers. Thinking defaults, supported controls, and execution levels follow the selected model's provider and runtime. No new configuration, schema, dependency, or migration is required.

Why This Change Was Made

Model resolution now happens once at its owner, and callers carry the prepared provider/model tuple forward. Bare defaults still use prepared runtime hooks without triggering manifest discovery. Thinking selection produces requested intent, support, and the execution level from one profile; Anthropic and Vertex use their existing provider-owned policy.

Catalog projections share their row cache while login readiness is checked on publication. OpenCode metadata refresh and account discovery share one lifecycle owner, preserving Zen's current-snapshot resolution, Go's seed-only resolution, and per-call credentials. Private transport wrappers and duplicate Responses policy preparation are removed; shipped transport adapters remain supported.

Production code is 256 lines smaller overall. Tests cover the removed paths and the failures discovered during the cutover, including namespace collisions, chained aliases, captured metadata, exact allowlists, locked selections, stale heartbeat origins, native runtime ownership, and empty/null thinking controls.

Upgrade Compatibility

Persisted session/config formats are unchanged. The three Doctor edits pass an already resolved default provider/model tuple into existing policy checks; retirement decisions and writes retain their existing owners. Session fields, serializers, schema, override writers, and shared legacy readers are unchanged. Existing rows still recover missing provenance or parse raw model references once. Reply coverage includes missing source/origin fields, fallback notices, user/auth pin preservation, and heartbeat fallback recovery; new cases distinguish literal IDs that previously collided during repeated normalization.

The focused compatibility run passed all 230 tests across stored model overrides, model-override provenance, retired-model repairs and ordering, and both Doctor health-check suites. No migration is needed because this change neither adds nor rewrites persisted data.

Evidence

  • The final head incorporates current-main CI repair fix(ci): restore current main checks #150491. The patch-identical rebase passed all 125 targeted Gateway identity/thinking and agent-command tests. The command fixture now uses the real parser/normalizer; its 85 cases preserve OpenRouter's native openrouter/auto identity.
  • Failing reproductions were recorded before the corresponding repairs. The corrected reference suite passed 495 tests, selection siblings passed 355, and the final default/workspace-scope suite passed 253. Provider, catalog, transport, and thinking suites also passed; these runs overlap.
  • Isolated Codex review through P2 is clean. Full local builds passed, including SDK declarations/exports and UI build budgets. Core and plugin production/test typechecks, lint, SDK/boundary checks, dead-export checks, import-cycle checks, and the selected storage/auth guards passed. The complete hosted CI run and required openclaw/ci-gate passed on head 2a86feeba88a3760e2b6b603adc5c48d71fe6167.
  • All nine direct live tests passed: Kimi K3/K3-256K Off/Max, K3 Low/Adaptive and code-reading tool replay; OpenCode Zen authenticated discovery and K3 tool replay; OpenCode Go authenticated discovery and inference.
  • The real Gateway flow independently passed kimi/k3, opencode/kimi-k3, opencode-go/gpt-5.6-luna, and anthropic/claude-opus-4-6, including file-read tool calls.
  • Initial direct probes exposed test-fixture gaps: a noncoding Kimi noop task, a 128-token Zen reasoning budget, and bypassed Go session headers. The probes now use a meaningful code-reading task, a bounded 4096-token budget, and the actual Go transport-state hook. No production retries or timeout increases were added.

@clawsweeper

clawsweeper Bot commented Sep 17, 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.

@steipete
steipete marked this pull request as ready for review September 17, 2026 02:20
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 16, 2026, 11:09 PM ET / September 17, 2026, 03:09 UTC (Revision 2).

ClawSweeper review

What this changes

Preserves selected model identities across commands, replies, and session listings while consolidating thinking settings and provider catalog preparation.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open with no blocking findings. Current main still contains the repeated normalization this PR addresses. The updated compatibility explanation and inspected readers resolve the previous migration concern.

Priority: P2
Reviewed head: 2a86feeba88a3760e2b6b603adc5c48d71fe6167

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with meaningful regression coverage, explicit compatibility evidence, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured body reports direct provider discovery, thinking, tool-replay, and real Gateway runs relevant to the changed owners; these runs were not independently repeated here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured body reports direct provider discovery, thinking, tool-replay, and real Gateway runs relevant to the changed owners; these runs were not independently repeated here.
Evidence reviewed 9 items Pinned change and current-main necessity: The introduced diff preserves resolved tuples instead of normalizing them again. Comparing the same owners with fetched main shows these changes remain absent there; the supplied merged related PR concerns CI repairs, not model selection.
Legacy compatibility remains owned by existing readers: The shared reader retains raw-reference parsing and the resolved-identity fast path. The introduced diff leaves session configuration, override writers, shared stored readers, and persisted-reference parsing unchanged.
Prior upgrade concern addressed: The three Doctor hunks only pass resolved default tuples into existing policy checks. The captured PR body adds explicit upgrade compatibility reasoning and reports 230 passing compatibility tests; no new stored format or migration is introduced.
Findings None None.
Security None None.

How this fits together

Model selection combines configured defaults, saved session choices, and provider catalogs before dispatching agent turns. Its results also supply model pickers and session displays.

flowchart TD
  A[Configured defaults] --> D[Model selection]
  B[Saved session choices] --> D
  C[Provider catalogs] --> D
  D --> E[Selected model identity]
  E --> F[Provider thinking policy]
  F --> G[Agent execution]
  E --> H[Pickers and session displays]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -272, Tests +491, Docs +18. Total +237 across 79 files.

View PR surface stats
Area Files Added Removed Net
Source 57 728 1000 -272
Tests 21 722 231 +491
Docs 1 18 0 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 79 1468 1231 +237

Review metrics

Metric Value Why it matters
Production versus regression coverage Production −256 lines; tests and test support +475 lines The consolidation reduces production code while adding coverage for identity collisions and selection compatibility.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/shared/retired-model-ref-repair.ts, migration/backfill/repair: src/flows/doctor-core-checks.ts, migration/backfill/repair: src/flows/doctor-health-contribution-runners.workspace.ts, serialized state: src/auto-reply/reply/stored-model-override.ts, unknown-data-model-change: src/auto-reply/reply/stored-model-override.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep parsing at selection boundaries, preserve prepared identities downstream, and derive thinking behavior from the selected provider and runtime.

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

Yes, from source: current-main command selection normalizes already selected references again, and the regression fixtures expose chained-alias and literal-ID collisions. No runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. Reusing existing readers and provider policy removes competing normalization paths while retaining legacy parsing and persisted formats.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs model-selection and thinking inconsistencies without evidence of an urgent widespread outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its captured body reports direct provider discovery, thinking, tool-replay, and real Gateway runs relevant to the changed owners; these runs were not independently repeated here.

Evidence

What I checked:

  • Pinned change and current-main necessity: The introduced diff preserves resolved tuples instead of normalizing them again. Comparing the same owners with fetched main shows these changes remain absent there; the supplied merged related PR concerns CI repairs, not model selection. (src/agents/command/model-selection.ts:106, 2a86feeba88a)
  • Legacy compatibility remains owned by existing readers: The shared reader retains raw-reference parsing and the resolved-identity fast path. The introduced diff leaves session configuration, override writers, shared stored readers, and persisted-reference parsing unchanged. (src/agents/model-selection-persisted.ts:13, 2a86feeba88a)
  • Prior upgrade concern addressed: The three Doctor hunks only pass resolved default tuples into existing policy checks. The captured PR body adds explicit upgrade compatibility reasoning and reports 230 passing compatibility tests; no new stored format or migration is introduced. (src/commands/doctor/shared/retired-model-ref-repair.ts:153, 2a86feeba88a)
  • Selection regression coverage: Inspected command and reply cases cover chained aliases, literal provider-prefixed IDs, exact and wildcard restrictions, inherited selections, locked selections, and heartbeat fallback origins. Tests were inspected, not executed during this read-only review. (src/agents/agent-command.resolved-pin.test.ts:44, 2a86feeba88a)
  • Private catalog helper and credential scope: The new helper is on an explicitly private-local SDK subpath. Both OpenCode consumers use it, credentials remain per build call, metadata failure retains the snapshot, and account model-list discovery remains strict. (src/plugin-sdk/provider-catalog-live-runtime.ts:227, 2a86feeba88a)
  • Native runtime dependency signal: The changed thinking resolver consumes native-runtime catalog facts. The Codex catalog adapter explicitly derives reasoning support and effort choices from app-server model discovery, establishing the relevant dependency contract. (extensions/codex/src/app-server/model-catalog.ts:40, 2a86feeba88a)

Likely related people:

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

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 (1 earlier review cycle)
  • reviewed 2026-09-17T02:28:41.697Z sha e195e6f9beea6d87afa7da45020916c0d116964e :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/model-policy-consolidation-20260916 branch from e195e6f to 2a86fee Compare September 17, 2026 02:55
@steipete steipete self-assigned this Sep 17, 2026
@steipete
steipete merged commit 90567a8 into main Sep 17, 2026
221 checks passed
@steipete
steipete deleted the codex/model-policy-consolidation-20260916 branch September 17, 2026 03:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…g policy (openclaw#150509)

* refactor(models): centralize selection and thinking policy

* test(models): reuse command normalization helpers
obviyus added a commit that referenced this pull request Sep 17, 2026
…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 #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](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]>
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: anthropic extensions: anthropic-vertex extensions: featherless extensions: fireworks extensions: kimi-coding extensions: opencode extensions: opencode-go gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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