Resolves #13700
Related: #13942
Reworks LM Studio preload from blind resident reload to shape-aware replacement. ensureLmsModelsLoaded now uses lms ps --json metadata when a resident model has context/parallel gates, skips exact identifiers that already match the configured shape, unloads a stale exact identifier before reloading it with stable --identifier <model>, and unloads suffixed siblings only after the exact configured id is verified sufficient.
Scope Boundary
This PR is the local LM Studio / OpenAI-compatible adapter fix for #13700. It does not claim to solve cloud/native Ollama deployment recovery. Active-provider residency recovery belongs to the diagnostics -> recovery daemon path under ADR-0025/ADR-0026 and is tracked in #13942.
Evidence: L2 (mocked lms load / lms unload dispatch plus focused provider-readiness unit coverage) -> L3 required (live LM Studio host shows only exact configured ids after orchestrator preload). Residual: live post-merge lms ps validation [#13700].
Deltas from ticket
- Extends the original chat
--parallel ticket into the unresolved load-order / already-loaded replacement path identified in the latest issue comment.
- Keeps phase-2 idle downscaling out of this PR; Discussion #13873 already owns that proactive homeostatic loop.
- Keeps cloud/native-provider recovery out of this PR; #13942 owns the active-provider daemon recovery lane.
- Does not add or change AiConfig leaves; callers still pass resolved context/parallel maps into the helper.
Test Evidence
npm run agent-preflight -- ai/services/graph/providerReadinessHelper.mjs test/playwright/unit/ai/scripts/runners/runSandman.spec.mjs
npm run test-unit -- test/playwright/unit/ai/scripts/runners/runSandman.spec.mjs -> 52 passed
git diff --check
Post-Merge Validation
Commit
7685fcd7f7 - fix(ai): replace stale lms resident models (#13700)
Authored by Euclid (GPT-5, Codex Desktop). Session 019ef378-527d-7393-bc74-ec3a1d3f2ddf.
Resolves #13700 Related: #13942
Reworks LM Studio preload from blind resident reload to shape-aware replacement.
ensureLmsModelsLoadednow useslms ps --jsonmetadata when a resident model has context/parallel gates, skips exact identifiers that already match the configured shape, unloads a stale exact identifier before reloading it with stable--identifier <model>, and unloads suffixed siblings only after the exact configured id is verified sufficient.Scope Boundary
This PR is the local LM Studio / OpenAI-compatible adapter fix for #13700. It does not claim to solve cloud/native Ollama deployment recovery. Active-provider residency recovery belongs to the diagnostics -> recovery daemon path under ADR-0025/ADR-0026 and is tracked in #13942.
Evidence: L2 (mocked
lms load/lms unloaddispatch plus focused provider-readiness unit coverage) -> L3 required (live LM Studio host shows only exact configured ids after orchestrator preload). Residual: live post-mergelms psvalidation [#13700].Deltas from ticket
--parallelticket into the unresolved load-order / already-loaded replacement path identified in the latest issue comment.Test Evidence
npm run agent-preflight -- ai/services/graph/providerReadinessHelper.mjs test/playwright/unit/ai/scripts/runners/runSandman.spec.mjsnpm run test-unit -- test/playwright/unit/ai/scripts/runners/runSandman.spec.mjs-> 52 passedgit diff --checkPost-Merge Validation
lms psorlms ps --jsonand verify the configured chat and embedding models have the exact configured identifiers with the expected context/parallel shape.<model>:2/<model>:3are not left loaded after preload succeeds.Commit
7685fcd7f7-fix(ai): replace stale lms resident models (#13700)Authored by Euclid (GPT-5, Codex Desktop). Session 019ef378-527d-7393-bc74-ec3a1d3f2ddf.