Repository navigation
feat: change the Local AI model in settings and choose the Gateway default model - #1744
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 real behavior proof before merge. What this changesThis PR adds in-place Local AI model switching, Gateway default-model selection, and provider management in Settings. Example: Replace Qwen3.8 27B with unsloth/Qwen3-0.6B-GGUF:Q4_K_M.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 14 items remain Keep open: this collaborator-authored feature remains useful and absent from main, but nine existing correctness findings still block merging despite green CI. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherSettings supplies model choices and credentials to authenticated Gateway services; the Local AI runtime coordinates verified downloads, processes, durable installation receipts, and route ownership. flowchart LR
A[Settings pages] --> B[Presentation owners]
B --> C[Model switcher]
C --> D[Verified model cache]
C --> E[Local AI runtime]
E --> F[Receipts and route lifecycle]
B --> G[Authenticated Gateway client]
F --> G
Technical reviewBest possible solution: Complete model transitions through the existing runtime and lifecycle owners, preserving durable ownership, current user intent, recoverable receipts, and visible localized outcomes. Do we have a high-confidence way to reproduce the issue? Main retains the setup-based model-change route, and the remaining patch failures follow concrete source paths; this read-only review ran no reproduction. Is this the best way to solve the issue? The approved in-place direction is worthwhile, but its smallest complete implementation must keep authenticated identity, durable receipts, current running intent, Gateway routing, and visible results consistent. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d50e57913465. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Connection-bound sends address the reported replacement-Gateway disclosure paths, while authorization at final credential persistence remains unproven. EvidenceSecurity concerns:
What I checked:
Likely related people:
LabelsLabel changes: No label changes. Label justifications:
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 (9 earlier review cycles; latest 8 shown)
Reviewed November 3, 2026, 11:42 PM ET / November 4, 2026, 04:42 UTC (Revision 10). |
|
Addressed the review findings in the latest commit.
Validation on this head:
Still not verified: a complete real switch against a connected native or WSL Gateway. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
389d724 to
852bd82
Compare
Hanselman review: HOLD_FOR_AUTHOR#1744 (feat: change the Local AI model in settings and choose the Gateway default model) Code review complete; not merge-ready. Reviewed head Independent reviewers: HIGH consensus
LOW consensusThese were independently flagged by one model and verified against the pinned source by the coordinator.
Rejected/disputed concerns: Opus withdrew two original findings after bounded evidence checks. Recovery suppression after a failed offline switch follows explicit teardown's fail-closed policy and is recoverable through explicit Start. The proposed mid-download Default model navigation race is not demonstrated: leaving Local AI cancels acquisition, and its own Start/Stop buttons are disabled while busy. These remain LOW (disputed), not accepted defects or independent agreement. Existing HTTPS/digest checks, bounded GGUF parsing and partial guarded config patches did not establish additional defects. Missing authority proof alone is not a security vulnerability. Prior repairs: Ordinary cross-Gateway fallback scoping, lifecycle-first fallback persistence, provider sign-in gating, thrown-start rollback and sequential journal recovery are present. The previously reported concurrent journal race remains. The new pending-primary-write finding is distinct from the repaired manifest-write ordering. Validation and remaining proofInspected exact-head CI run 38983839552 and its logs: CI Gate succeeded, with 17 successful and 7 conditionally skipped check runs. Logs report Shared 4403 passed/1 skipped, Connection 1662/1, Tray 4105/0 and SetupEngine 2358/1; the focused switching/default-model tests executed. Hosted setup/connect reports 40 passed/7 skipped. These are inspected CI results, not locally executed tests or independent TRX validation. No builds, tests or runtime operations were run by this read-only review. Both author screenshot links resolve and were visually inspected: native starting state and replacement verification while the old router runs. They support connected intermediate native UI behavior. They do not show final replacement inference, Default model application, rollback or authority rejection, and precede the current-head force push without source/binary attribution. The author's reported complete native switch is acknowledged, not treated as fully evidenced or absent. Remaining gates:
Decision: HOLD_FOR_AUTHOR. Take confidence: 35%. Recommendation confidence: 98%. Author should repair the five accepted defects, add focused regressions and supply current-head proof. GitHub also currently reports merge conflicts. No source, GitHub metadata, reviews, comments or runtime state were changed. |
872c165 to
5e59325
Compare
Fix: serialize the model-rebind journal with the manifest commit (5e59325)Addresses the review finding "Stale ownership observation can split durable receipts" (ClawSweeper P1 "Serialize journal settlement with the active model-switch commit"). Problem
Fix
Tests (
Not verified: a real native model switch against a live Gateway. |
5e49646 to
434a8f7
Compare
|
Rebased onto main (12789b4) and removed the duplicate @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Replace the Local AI "Change model" wizard route with in-page selection: a dropdown of catalog models that fit this PC plus an optional custom Hugging Face GGUF reference (owner/repo, owner/repo:QUANT, file path, or huggingface.co/hf.co link). - Custom models are pinned to a commit revision and LFS SHA-256, sized from the GGUF header, and stored as a schema-6 receipt carrying the recipe. Oversized models require explicit "Switch anyway". - LocalAiModelSwitcher downloads and verifies while the current model serves; ILocalAiRuntime.ReplaceInstallAsync withdraws the old route before committing the new receipt, and a failed start restores the previous one. Prior weights stay in the Hugging Face cache. - Hub sidebar gains a "Model" header with a new Default model page and the existing Local AI page. Default model writes agents.defaults.model.primary via config.patch and keeps the Local AI fallback in sync. - Remove IAppCommands.ShowLocalAiModelSetup and its window-manager route.
…ndow freezing Verifying an already-downloaded model reports progress after every 1 MiB read (about 15,700 reports per pass for a 16 GiB GGUF). The Local AI page queued a full-page refresh on the UI thread for each one, so the window stopped responding during "Verifying the download". CoalescingSwitchProgress delivers byte updates at most once per 100 ms, delivers phase changes immediately, and keeps at most one UI update queued (carrying the latest value). Byte-only updates now raise SwitchProgress and refresh just the progress text and bar instead of the whole page.
…odel writes Address the review findings on the in-place model switch and the Default model page: - Native binding and manifest now recover together. RebindModelAsync journals the previous model in gateway-binding.json (RebindFrom) before the manifest commit; every manifest load settles the journal to whichever model the manifest names, and a failed manifest save settles it back at once. - Fallback updates write the lifecycle receipt first and are idempotent, so a retry after a rejected or partial update repairs both receipts. - The Default model page changes Local AI's fallback (and stops Local AI) only when the active Gateway is the one Local AI is bound to. - Models whose provider still needs sign-in are listed but cannot be made the default. - A start that throws after the switch commits now gets the same rollback as a start that returns a failure.
Ownership observation no longer settles a journaled rebind from a stale installation snapshot; it reports Unavailable and stays read-only. CommitModelRebindAsync holds the binding lease across journal, manifest save and journal clear, and crash recovery settles against the manifest read under that lease.
The model switcher reused any installed runtime in the same family, including the retired b10655/b11026 pins, which predate the minimum llama.cpp builds of the current recipes. Reuse only the exact runtime the new plan qualified; otherwise install the current pin side by side.
…lder The hub cache already stored nested relative paths, but the mandatory legacy copy treated the whole path as one filename and failed after the download.
…nconfirmed The Default model page wrote the cloud primary before the fallback update checked the native receipt, so a pending publication left a primary that recovery could not settle. The primary write now runs inside the receipt lease after a Pending check with no same-value shortcut.
A switch that outlives navigation (past its cancelable phases) could be followed by a second switch from a new Local AI page, which loaded a stale rollback baseline and could overwrite or undo the newer choice. LocalAiModelSwitcher now claims a single-flight slot before reading the receipt and rejects concurrent calls; IsSwitching/IsSwitchingChanged keep every page busy until the switch ends, then reload the installed plan.
The selection was made before the ComboBox template applied, so WinUI left the closed selection box blank. Re-select once the page loads, and keep the options instance across refreshes with unchanged content so the selector is not cleared and rebuilt.
Settings > Default model gains an Add a model provider card: save an API key (models.authSetApiKey) or sign in (models.authLogin + wizard.next/cancel, rendered with the shared ProviderSetupDialog) for Gateway providers listed by models.authStatus, or add a custom OpenAI/Anthropic-compatible endpoint under models.providers.<id> with a guarded config.patch. The chat model picker links to that page. Features are gated on admin scope and advertised methods.
Gateway setup stores the configured agent's own primary (agents.entries.<id>.model), which the Gateway prefers over agents.defaults.model.primary. The page wrote and showed only the defaults primary, so new chats kept the setup model. Show the default agent's effective model and remove its own primary in the same config.patch; after a successful Local AI start or hand-back, remove it too.
…cess A running model switch returned success as soon as the router reported Healthy, but the router starts with load-on-startup = false, so health never proved the new weights could load. A CUDA OOM or unsupported GGUF passed the switch and failed on the first chat, after rollback protection had ended. A running switch now succeeds only after the new model answers one bounded inference request and the router reports that exact model as Loaded, mirroring setup's VerifyLocalAiInferenceStep. A failed or timed-out load takes the existing rollback path and restores the previous receipt. Stopped-runtime commits remain start-free and check-free, and the restored previous model starts without a load check. The load budget is bounded by OPENCLAW_LOCAL_AI_SWITCH_LOAD_TIMEOUT (whole seconds, 30 to 3600, default 600 matching setup's first-load budget). A new non-cancelable LoadingModel phase covers the post-commit wait and is localized in all six languages. The public switcher ctor now takes the gateway API key provider so the verification request carries the same auth as the router. Validation: dotnet test SetupEngine (17/17 switcher tests, 2549/2553 total), Shared 4828/4852, Tray 4830/4830, ./build.ps1 all green. The three rollback regression cases fail on the old Healthy-only branch. Live switch proof blocked: no completed Local AI install on this host.
…d Gateway A cloud default chosen while Local AI owns the route waits behind the runtime gate, and the queued config.patch used to resolve whatever Gateway was current at that point. Bind every default-model write, including default-agent cleanup, to the admitted Gateway id, operator client and connection epoch before the first await. Recheck that binding before config.get, after its reply and after a failed patch, and send only on the captured epoch through new connection-bound client APIs. A changed Gateway or session now fails closed, so the Local AI receipt and manifest fallback stay unchanged.
…t started on Each models.authLogin flow is now bound by BeginLogin to its client, connection epoch and Gateway id. wizard.next and wizard.cancel recheck that binding and are sent only on the captured epoch, so a retained answer is never transmitted to a replacement Gateway or session. A lost binding retires the flow permanently and the page reports that the connection changed.
…d admit them from the saved receipt SetPrimaryAndFallbackModelAsync now records the target as LocalAiNativeBinding.UnconfirmedPrimary before the Gateway write. Every lifecycle Gateway config read (start, stop, release, model switch) settles it to the primary the Gateway shows, so a lost reply, crash or failed receipt save no longer leaves the route needing manual reconciliation. The Default model page now treats a saved native ownership receipt for the active Gateway as ownership even when the Local AI install cannot be loaded, so cloud choices always go through the runtime's Pending guard instead of a direct primary write.
…e model settings change Applies the AGENTS.md module documentation rule: each production C# file changed on this branch starts with a header describing what it owns, with a usage example of its main entry points, and its primary type and cross-module methods carry XML summaries. Comments only.
b40041b to
c6e8b13
Compare
DefaultModelPage only observed DefaultModelPageViewModel, so ModelProviderSetupViewModel changes (provider selection, catalog load, sign-in dialog steps) rendered only on the next unrelated refresh. Re-raise them as Providers.
Data-model compatibility proofThis PR changes two persisted Local AI files. Both additions are optional members, so data written by earlier builds still loads.
Existing tests that already cover this: Results: both new tests pass. Full Not covered: downgrade (an older build reading a file this PR wrote). The binding file should be fine because The new tests are in |







What Problem This Solves
Fixes: changing the Local AI model sends users through the full setup wizard, and settings has no place to choose the Gateway's default model.
User Impact
User impact: users can change the Local AI model directly on the Local AI page, either by picking a catalog model that fits their PC or by pasting a public Hugging Face GGUF. A new Model section in settings groups Default model (choose the Gateway's default, including Local AI) with Local AI.
provider/modelid with a single slash, because Local AI's existing fallback rule rejects others. The page explains this instead of saving.Why This Change Was Made
owner/repo,owner/repo:Q4_K_M, a file path, or a huggingface.co / hf.co link) is pinned to a commit revision plus its Git LFS SHA-256 and size. Layers, KV heads, head size and trained context are read from the GGUF header without downloading the weights. The catalog's capacity rules then choose a context tier. Custom installs use a new schema-6 receipt that carries this recipe.agents.defaults.model.primarywith a partialconfig.patch. When Local AI is installed it also records the choice as Local AI's fallback, so a later Local AI start or stop leaves the Gateway consistent.ShowLocalAiModelSetup) is removed. Retry setup still opens the existing setup flow.Evidence
unsloth/Qwen3-0.6B-GGUF:Q4_K_MpinnedQwen3-0.6B-Q4_K_M.ggufat50968a44…, 28 layers, 40,960 context.unsloth/Qwen3-8B-GGUF:Q4_K_Mgave 5,027,784,512 bytes and SHA-256120307ba…49bd4, matching the Hub's file listing./blob/link to a Q8_0 file resolved that file.app.navigatewithmodeland withlocal-aiboth reached the new pages, and the sidebar shows the Model header with both items.Change Type
Scope
winnodeRequired proof pools
windows-winui-interactive: new Default model page, new Local AI model controls, and a new Settings sidebar section.windows-11-arm64: developed and launched only on a Windows ARM64 host.windows-wsl-gateway-e2e: Local AI route withdrawal, rebind, and default-model writes go through the Gateway.Validation
./build.ps1: all projects built and documentation validation passed on the feature commit (d4ed57a7). After the progress fix, the WinUI step could not copy its DLLs because a running Companion instance (started by setup) held them;dotnet buildofOpenClaw.Tray.WinUI.csprojinto a separate output folder succeeded with 0 errors.dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 4331 passed, 36 skipped.dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 4095 passed.dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csprojwithOPENCLAW_REPO_ROOTset: 2344 passed, 1 skipped.dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj: 1585 passed, 5 skipped, 1 failed. The failure,LocalAiApiCredentialStoreTests.ConcurrentCreationConvergesOnOneCredential, is in code this PR does not touch and passed when rerun alone.OpenClaw.Tray.UITestsbuilds with-r win-arm64.Real Behavior Proof
d4ed57a7; the switch-freeze report came from the developer's own Local AI install.winnode --command app.navigate --params '{"page":"model"}'and--params '{"page":"local-ai"}', then window captures. Model-card states were rendered with synthetic hardware in a throwaway UI test.{"navigated": true, "page": "model"}and{"navigated": true, "page": "local-ai"}; captures show the Model header with Default model and Local AI, and the fit-warning card reading "It needs about 41.7 GB of GPU memory and NVIDIA RTX 4080 has 16.0 GB."Yes/No/N/A): N/A. Screenshots were taken locally and are not attached.config.patch.Security Impact
Yes/No): NoYes/No): NoYes/No): YesYes/No): NoYes/No): NoYes, explain the risk and mitigation: custom model resolution calls the Hugging Face API (/api/models/<repo>/revision/<rev>and/tree/<sha>) and reads the GGUF header from/resolve/<sha>/<file>. It uses the existing Hugging Face HTTPS policy, now shared asHuggingFaceHttp: the first request must go to huggingface.co, redirects may only reach huggingface.co or hf.co hosts, and URLs must be credential-free. No token is sent, so gated or private repos are rejected. Downloaded weights are verified against the pinned size and SHA-256 before use, as for catalog models. The Default model page writes Gateway config only when the operator connection has write scope.Compatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations