Repository navigation
fix(models): signed-in native runtime loses to a runtime preference pinned before sign-in - #180830
ivankuznetsov wants to merge 8 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesValidate stored runtime pins during model re-selection while preserving compatible choices and worker-owned authentication. Example: A session pinned to openclaw selects meta/muse-spark-1.3 while Muse is signed in and the Meta API route has no credential.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR contains useful runtime-selection repairs still absent from current main; no blocking code defect was found, and the new live traces resolve the previous proof request. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherChat commands, model pickers, and Gateway session mutations pass model requests and stored session preferences into shared runtime preparation, which returns a validated runtime or an actionable rejection before persistence. flowchart TD
A[Chat command or model picker] --> C[Shared runtime preparation]
B[Gateway session mutation] --> C
D[Stored pin and configured routing] --> C
C --> E[Prepared catalog and account availability]
E --> F[Validated runtime or rejection]
F --> G[Session selection commit]
Technical reviewBest possible solution: Retain the focused repair in the existing runtime-selection owners and complete the required CI gate before landing. Do we have a high-confidence way to reproduce the issue? Current-main source shows how an openclaw session override bypasses runtime preparation for API-first or config-declared native models; the contributor supplies matching before/after Gateway traces, which were inspected without executing target code. Is this the best way to solve the issue? The patch uses the existing availability owner to distinguish a strict stored pin from a soft preference, preserves required-worker authentication, and introduces no competing state or selection service. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2408b27ff5d2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +63, Tests +349. Total +412 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed November 23, 2026, 5:43 AM ET / 10:43 UTC (Revision 6). |
d635a15 to
f344c1a
Compare
Model re-selection prepared no runtime choice when a session carried a stored runtime override and the selected catalog row was the API route, so a runtime pinned before sign-in (for example openclaw while unauthenticated) kept winning even after a native/CLI sign-in completed. Always discover a claiming CLI/native runtime, and treat a native variant of the selected model as requiring runtime-choice preparation. On re-selection the existing availability-filtered runtime choices apply: a stored preference that is still available always wins; one that no longer evaluates available (missing credential, expired sign-in, or cooldown) falls through to the first available choice. This is a deliberate re-selection repair, not a per-turn switch: plain turns without re-selection are untouched. Required worker inference keeps ownership of runtime selection when no explicit non-openclaw runtime was requested, so worker-local credentials are never validated against the gateway.
f344c1a to
e9064ea
Compare
|
@clawsweeper re-review Updates since the last review:
|
|
🦞👀 Re-review progress:
|
…e-runtime # Conflicts: # src/agents/model-runtime-choice.native.test.ts
Re-selection passed any stored agentRuntimeOverride as a hard pin. Session rows that hold the "no preference" values "auto" or "default" (any casing) became a pin on a runtime id that is never a choice, so re-selecting the model was rejected instead of resolving a runtime. Only pin real runtime ids; default ids keep their stored meaning. Adds a stored-row compatibility test covering absent, "auto", "default", unnormalized " Auto ", legacy "pi", and "OpenClaw" overrides.
|
@clawsweeper re-review Changes on head
Focused suites: 5 files, 170 tests, all passing. |
|
🦞👀 Re-review progress:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…del-only switch A chat pinned to a native runtime (Muse for meta/*) rejected a plain `/model deepseek/deepseek-flash` with `Runtime "muse" is not available`. Session runtime compatibility accepts any registered harness for any provider, so the stored muse pin reached runtime choice as a strict pin. Pin a stored runtime only when it can serve the selected model: openclaw, the discovered CLI runtime, or a native catalog row for this exact model. Any other stored runtime stays a preference, so the documented "an incompatible pin is cleared" behavior holds. Unavailable pins that can serve the model are still rejected instead of silently switching. Found during live Telegram proof on the combined build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@clawsweeper re-review Changes on head
|
|
🦞👀 Re-review progress:
|
…ured runtime
Live proof on an upgraded copy of real state (Muse signed in, Meta's API route
signed out) showed a session storing an `openclaw` pin switch to
meta/muse-spark-1.3 through both typed /model and sessions.patch with
"Model set to meta/muse-spark-1.3": the pin stayed, so the chat was left on a
runtime that cannot serve the model.
Muse models get their runtime from config
(`agents.defaults.models["meta/muse-spark-1.3"].agentRuntime = { id: "muse" }`),
not from a catalog row with nativeRuntime. Runtime-choice preparation only ran
for native catalog rows, CLI runtimes, or a non-openclaw effective runtime,
and the stored `openclaw` override made the effective runtime `openclaw`. So
the configured `muse` policy was shadowed and the pin was never validated.
A model or provider runtime configured to something other than openclaw now
also sends selection through runtime-choice preparation, which validates the
stored pin and rejects it with sign-in guidance instead of keeping it.
Unpinned sessions are unchanged: their effective runtime already is the
configured one.
Regression "validates a stored openclaw preference against the runtime the
model's config declares" (config-declared runtime, no nativeRuntime anywhere):
before, status "ready"; after, "rejected". The native-harness registry setup
the tests repeated becomes one local helper, keeping the file under the line
limit.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What Problem This Solves
Fixes: after completing a native/CLI subscription sign-in (for example Muse), chats keep resolving the model to the default API runtime and fail with missing-auth errors, because a runtime preference stored while unauthenticated suppresses the signed-in runtime forever — and runtime-choice preparation never validated the stored preference at all.
User Impact
On re-selection, the stored runtime preference is now validated against current availability:
autoordefault(any casing) are read the same way and are never treated as a pin.inference="worker"profile keeps ownership of runtime selection (pinned or unpinned), so re-selection never validates worker-local credentials on the gateway.Plain turns without re-selection are untouched; implicit runtime choices saved as pins at write time are a separate follow-up.
Why This Change Was Made
Two stacked causes: session runtime overrides skipped CLI/native runtime discovery entirely, and dual-route models that list the API catalog row first skipped runtime-choice preparation even when a native variant exists. The change always discovers claiming runtimes, treats a native variant as requiring runtime choice, and passes a stored real runtime id (not
auto/default) to runtime-choice preparation as a dedicatedpinnedRuntimeId. Availability-filtered choices (runtimeChoicesonly contains runtimes that evaluated available) decide the outcome: pin available → pin wins; pin unavailable → selection returns the existing unavailable message with sign-in guidance instead of falling through tochoices[0].Evidence
Head
04093a8390f. Currentmain(8ab24647379, version 2026.11.6) merged cleanly in25502ef202c.04093a8390ffixes a gap found during live proof.Live gap fixed in
04093a8390f: a model whose runtime is set in config.openclawpin switched tometa/muse-spark-1.3through both typed/modelandsessions.patch. It repliedModel set to meta/muse-spark-1.3and kept the pin, leaving the chat on a runtime that cannot serve the model.agents.defaults.models["meta/muse-spark-1.3"].agentRuntime = { id: "muse" }), not from a catalog row withnativeRuntime. The storedopenclawoverride made the effective runtimeopenclaw, so runtime-choice preparation never ran.openclaw(runtimeSourcemodelorprovider) now also runs runtime-choice preparation, which validates the stored pin. The change is 7 lines inmodel-runtime-normalization.ts. Unpinned sessions are unchanged, because their effective runtime already is the configured one.nativeRuntimeanywhere. On the previous head it returnsstatus: "ready"; on this head,"rejected". The native-harness registry setup the tests repeated is now one local helper, keeping the file under the line limit.Data-model compatibility (earlier head
a2403ff6771). No schema, config, or migration changes. Existing session rows are read as stored, not rewritten. A new stored-row test, "reads a stored runtime override … from an existing session row", feeds session rows shaped like those earlier releases persisted (sessionId,updatedAt,providerOverride,modelOverride, optionalagentRuntimeOverride) through re-selection. Values covered: absent,"auto","default", unnormalized" Auto ", legacy alias"pi", and"OpenClaw". This test found a real regression in the previous head: rows storingauto/defaultbecame a hard pin on a runtime id that is never a choice, so re-selection was rejected. Fixed in8a46c50e100; those rows now stay unpinned.1e2a8b9438a:auto,default, and" Auto "fail (rejected); the others pass.Red on base. These are this PR's regressions run against
main'smodel-runtime-choice.tsandmodel-runtime-normalization.tswith this branch's tests. All fail with assertion errors; onmain, every case returnsreadywith the runtimeunchanged, because API-first dual-route re-selection never reaches runtime-choice validation:rejected, gotready.{ kind: "set", runtime: "openclaw" }, got{ kind: "unchanged" }.The two required-worker re-selection tests pass on both base and head. They guard the earlier P1 against regression and are not red-on-base proofs.
Tests on this head (
node scripts/test-projects.mts <files> --maxWorkers=2): 13 files, 298 tests, all passing.model-runtime-choice.native,sessions-patch-model-selectiondirective-handling.model,directive-handling.mixed-inline,directive-handling.session-list,directive-handling.levelssession-override.user-link,openclaw-tools.session-status.gateway-model,get-reply-native-slash-fast-pathagents-model-selection,sessions-mutations.sticky-model,server.sessions.agent-model-catalog,apply-session-model-selectionWith #202564 and #180831 combined: 131 tests across the three PRs' suites, all passing.
tsgo:coreis clean, andoxlint/oxfmtare clean on touched files.Live proof
Pin cases on the owner's real state (2026-11-23). The copy of the operator's state was written by a 2026.10.10 main build and upgraded to this head (combined build
e8ec8a4). It ran in an isolated Gateway with the live state mounted read-only. Muse was signed in through a Meta device code and Meta's API route had no credential. The proof session stores anopenclawpin and sits onxai/grok-4.3.On the previous build (
65f0484), both rejects were accepted with the pin kept. That's the gap fixed above. Full trace: TRACES-20261123.md.Completed Muse reply on upgraded real data. In that copy, a fresh session on
meta/muse-spark-1.3(runtimemuse) repliedOK — Muse Code powered by Meta Muse Spark. Native-runtime consent was granted for the test copy.Upgrade traces (TRACES-20261123.md):
codexruntime pin. v2026.11.6 refuses this data (state schema 39 is newer than its 36).openclawruntime pin. This head migrated it (state schema 36 → 41). All 5 sessions are field-identical, and the pin is still read as stored (source: session-key).Regression found live, fixed in
a2403ff6771. After a Muse model was selected (Runtime set to muse), a plain/model deepseek/deepseek-flashwas rejected withRuntime "muse" is not available for deepseek/deepseek-flash.resolveCompatibleAgentRuntimeForProvidertreats any registered harness as compatible with any provider, so the storedmusepin reached runtime choice, and this PR made it strict. A stored runtime is now pinned only when it can serve the selected model:openclaw, the discovered CLI runtime, or a native catalog row for this exact model. Any other stored runtime stays a preference, which matches the documented rule that an incompatible pin is cleared. New test "does not let a stored native runtime that cannot serve the selected model block a model-only switch": red before the fix (rejected), green after.🤖 Generated with Claude Code