Repository navigation
fix(local-ai): recommend Qwen3.8 with measured context profiles - #1281
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 8:06 PM ET / September 3, 2026, 00:06 UTC. ClawSweeper reviewWhat this changesThis PR adds Qwen3.8 Local AI profiles selected from GPU capacity, persists the selected context and KV-cache settings, retires Qwen3.5 9B from new installs, and updates setup and tray presentation. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 7 items remain Keep open. The branch has a concrete setup-recovery regression for existing Qwen3.5 9B installs, and it still needs current-head supported-GPU launch and inference proof plus maintainer confirmation of the model-versus-context recommendation policy. Priority: P1 Review scores
Verification
How this fits togetherLocal AI combines detected NVIDIA GPU capacity with a pinned model catalog to choose a runnable profile. Setup persists that choice as an installation receipt, then llama-server consumes the receipt to start the local provider and the tray displays its state. flowchart LR
A[Detected NVIDIA GPU] --> B[Local AI eligibility]
B --> C[Model and context profile]
C --> D[Setup installation receipt]
D --> E[llama-server launch preset]
E --> F[Local provider]
E --> G[Tray status]
Decision needed
Why: The linked open issue identifies this as a user-facing model-quality versus agent-context tradeoff, and the branch selects one policy without recorded maintainer approval. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Preserve recovery for a valid legacy 9B receipt or provide an explicit, tested migration path, then land the approved recommendation policy with redacted supported-GPU launch and inference evidence. Do we have a high-confidence way to reproduce the issue? Yes, from source: use a valid pre-profile Qwen3.5 9B manifest, rerun setup with no offered-model override, and recovery receives a Qwen3.8 plan that fails the exact manifest-model check. This review did not execute that write-producing setup path. Is this the best way to solve the issue? No. The direct launcher correctly resolves a legacy receipt, but setup recovery still rejects it; the branch also needs an approved policy for the capability-versus-context default. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 09bc834fd4ae. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
| public const string Qwen35BModelId = "qwen3.6-35b-a3b-mtp-q4-k-m"; | ||
| public const string Qwen27BModelId = "qwen3.6-27b-mtp-q4-k-m"; | ||
| public const string Qwen9BModelId = "qwen3.5-9b-mtp-q4-k-m"; | ||
| public const int NativeContextTokens = 262_144; |
There was a problem hiding this comment.
can we refactor this and name it with t-shirt size: Context Large, Medium, Small, XS. Better with an enum or an array instead of defining all those variables explicitly. This suits better if we need to use a selector or at least makes the code easier to read by explicitly declaring the options and having a map to the context size length.
There was a problem hiding this comment.
This is tricky to do. Weaker model might have larger context or higher parameters count. I prefer something like Model name - version number - parameter count. Let's look into this after initial merge as product team might have a say on the specific strings for this and other similar strings, and I don't want to gate merging this last minute. Thanks
9b38ea9 to
bdd3e20
Compare
bdd3e20 to
2809214
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Joel: will add proof |
Windows model-selection proofCaptured on Windows 11 ARM64 with an NVIDIA RTX Spark N1X during the validated Local AI integration run. The screen shows:
During the same run, fixed-prompt inference completed with 32 generated tokens and GPU verification passed with 66/66 layers and 15,738,286,899 bytes in CUDA model buffers. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…hable Enabling Local AI no longer implies consent for the user-wide .wslconfig mirrored-networking rewrite and one-time wsl.exe --shutdown. The affirmative checkbox is restored and Continue stays blocked until it is accepted whenever the change is actually required. Qwen3.5 9B is retired from new installs but kept as a hidden legacy catalog entry so an existing managed installation keeps resolving its own pinned receipt and launching after upgrade. The entry is never offered, recommended, or selectable, exposes only the native F16 profile it could have been installed with, and no model artifact is remapped. Co-authored-by: Copilot App <[email protected]>
# Conflicts: # src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml.cs # src/OpenClaw.SetupEngine/LocalAiInstallReconciler.cs # tests/OpenClaw.Shared.Tests/LocalInferenceQualificationTests.cs
Cover the step-level invariant behind the restored consent gate: without explicit consent ConfigureLocalAiWslNetworkingStep stops before applying mirrored networking, so the user-wide .wslconfig keeps its exact bytes, no backup is staged, and no global WSL shutdown is issued. Enabling Local AI on its own does not satisfy the gate. Co-authored-by: Copilot App <[email protected]>
The deny test claimed no global WSL shutdown is issued but used a real CommandRunner and never asserted it. Inject a refusing ICommandRunner and assert zero invocations, so a regression that shuts WSL down before applying mirrored networking fails the test instead of running wsl.exe. Co-authored-by: Copilot App <[email protected]>
…claw#1281) * fix(local-ai): recommend Qwen3.8 with measured context profiles * fix(local-ai): drop 16 GiB model support * fix(local-ai): restore WSL consent and keep retired 9B installs launchable Enabling Local AI no longer implies consent for the user-wide .wslconfig mirrored-networking rewrite and one-time wsl.exe --shutdown. The affirmative checkbox is restored and Continue stays blocked until it is accepted whenever the change is actually required. Qwen3.5 9B is retired from new installs but kept as a hidden legacy catalog entry so an existing managed installation keeps resolving its own pinned receipt and launching after upgrade. The entry is never offered, recommended, or selectable, exposes only the native F16 profile it could have been installed with, and no model artifact is remapped. Co-authored-by: Copilot App <[email protected]> * test(local-ai): prove denied WSL consent changes nothing Cover the step-level invariant behind the restored consent gate: without explicit consent ConfigureLocalAiWslNetworkingStep stops before applying mirrored networking, so the user-wide .wslconfig keeps its exact bytes, no backup is staged, and no global WSL shutdown is issued. Enabling Local AI on its own does not satisfy the gate. Co-authored-by: Copilot App <[email protected]> * test(local-ai): assert the denied consent path launches no process The deny test claimed no global WSL shutdown is issued but used a real CommandRunner and never asserted it. Inject a refusing ICommandRunner and assert zero invocations, so a regression that shuts WSL down before applying mirrored networking fails the test instead of running wsl.exe. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
LocalModelRunRecipe no longer carries ContextTokens after openclaw#1281 moved capacity settings to LocalInferenceRunProfile. The merged LocalAiInferenceFailureDiagnosticsTests still referenced model.Recipe.ContextTokens, which broke the CI test job with CS1061. Thread the selected profile's ContextTokens through CreateInstall like LocalAiSetupSteps does.
…1284) * fix(local-ai): surface llama-server root cause on inference failure A failed `verify-local-ai-inference` reported only "llama-server inference returned HTTP 500 (InternalServerError)". The real cause — a CUDA flash-attention kernel fault during model warm-up (#1242) — was reachable only by hand-reading llama-server's own logs, which live in a different tree from the setup log the UI links to. Three gaps hid it: - The HTTP error body, which carries llama.cpp's `{"error":{"message":"model ... failed to load"}}`, was discarded. - Nothing read llama-server's stdout/stderr on failure, even though the GPU verification path already had a bounded log-tail helper. - The GUI never surfaced the llama-server log directory. Read a bounded, best-effort error body and raise LlamaServerInferenceException carrying the status and the server's own message. Extract the log-tail helper into LocalAiLogTail, add failure-line extraction, and share it with LocalAiGpuVerification. Attach a structured LocalAiFailureDetail (diagnostic lines plus log directory) to StepResult and thread it to the completion page, which now renders the llama-server lines and an "Open Local AI logs" link. The lines are also echoed into the setup log so the root cause survives rollback. Only server-generated error text is surfaced, never assistant output; a test pins that contract. Two incidental fixes: - Capture diagnostics before resetting the router. The reset restarts llama-server, which appends a startup banner and can rotate the failing lines out of the bounded log. Covered by a regression test verified to fail against the old ordering. - LogFileLauncher.RevealInExplorer opened the parent of a directory argument, because it unconditionally called Path.GetDirectoryName. Refs #1242 Co-Authored-By: Claude Opus 5 <[email protected]> * fix(local-ai): never surface unrecognized llama-server response bodies The HTTP error-body fallback in LlamaServerInferenceClient returned raw, unvetted response text (HTML, malformed JSON, JSON without an "error" field) whenever the response did not match llama-server's recognized {"error": ...} shape. That raw text flowed into the inference exception's Message, then into StepResult.Message, the setup log (ctx.Logger.Error), and the completion page's error text - contradicting the documented invariant that only recognized llama-server diagnostic text is surfaced. Remove the raw-body fallback: ReadErrorDetailAsync now returns null (status-only) unless a recognized error field is present. Add sentinel assertions in LlamaServerInferenceClientTests proving unrecognized bodies never reach the exception, and an end-to-end sentinel test in LocalAiInferenceFailureDiagnosticsTests driving the real HTTP client through VerifyLocalAiInferenceStep to prove the sentinel never reaches StepResult.Message or LocalAiFailureDetail. Co-authored-by: Copilot App <[email protected]> * fix(local-ai): never derive a clickable help link from llama-server text Rubber-duck review of the diagnostic-flow change surfaced a second security-boundary gap: CompletePage.OnNavigatedTo scanned every failure message (including the setup step's error message, which now can carry llama-server's own text via LlamaServerInferenceException.Message) for a URL and, if found, rendered it as a clickable HelpLink. A malicious or compromised local model server could therefore plant a navigable link in the completion UI by returning a recognized {"error": {"message": "https://..."}} shape. Skip the URL scan whenever CompletePageArgs.Detail is present, since Detail is populated only for Local AI inference failures and reliably identifies server-originated text. Non-Local-AI failures keep their existing curated help links (e.g. the WSL update link). Add a source-text contract test (CompletePage is a WinUI Page and cannot be unit-instantiated without a XAML host). Also fix a related display bug the same review pass found: the "Open Local AI logs" link showed the un-translated app path instead of the MSIX-container-resolved real path used by the setup log link and by RevealInExplorer itself, so the visible/tooltip text could disagree with what actually opens under MSIX virtualization. Route it through LogFileLauncher.ResolveRealPath like the existing log link. Finally, tighten the end-to-end sentinel test added in the prior commit: the LocalAiFailureDetail assertions were vacuous (no log files were written, so Diagnostics was trivially empty and LogDirectory is never derived from the HTTP body). Replaced with assertions that actually hold meaning: Diagnostics stays empty and LogDirectory equals the app-controlled LocalAiPaths value. Co-authored-by: Copilot App <[email protected]> * fix(local-ai): hide broken log link and tighten diagnostic matching Structured (Codex) review of the diagnostic-flow change surfaced two more issues before landing: 1. The "Open Local AI logs" link stayed visible even when the WinUI setup wizard's default RollbackOnFailure=true had already deleted the whole Local AI tree (including the log directory) before the completion page renders. Clicking it could not open the promised folder. The diagnostic text lines above the link remain accurate regardless (they were captured before the rollback); only the link itself now checks Directory.Exists on the resolved real path and hides when the target is gone. 2. LocalAiLogTail's diagnostic-line regex matched any "ggml_xxx:" prefixed line, which also matches routine, non-failure llama.cpp initialization logging (e.g. "ggml_cuda_init: found 1 CUDA devices:"). A timeout or unrelated failure could therefore surface ordinary startup lines as if they were the failure's root cause. Removed that overly broad alternative; the remaining patterns (CUDA error, cudaError, exited with status, failed to load, out of memory, and a generic "error:" marker) already cover genuine failure text without the false-positive risk. Added focused regression tests for both: a source-text contract test proving the log link is gated on Directory.Exists, and a fixture test proving a benign ggml_ startup log is not misclassified as a diagnostic line. Co-authored-by: Copilot App <[email protected]> * fix(local-ai): recognize llama.cpp buffer-allocation failure lines A second structured-review pass found that LocalAiLogTail's diagnostic pattern missed a real, documented llama.cpp failure vocabulary: host and device memory allocation failures reported as "failed to allocate ... buffer" (e.g. from ggml_gallocr_reserve_n_impl or graph_reserve during llama_new_context_with_model). Those lines matched none of the existing markers (CUDA error, cudaError, exited with status, failed to load, out of memory, error:), so a model-load failure caused by an allocation error would surface only the router's generic "failed to load" line instead of the actual root cause. Add "failed to allocate" to the recognized pattern. Add a fixture test using representative real llama.cpp allocation-failure lines and assert the routine "constructing llama_context" line beside them is still excluded. Co-authored-by: Copilot App <[email protected]> * fix(tests): read context tokens from run profile LocalModelRunRecipe no longer carries ContextTokens after #1281 moved capacity settings to LocalInferenceRunProfile. The merged LocalAiInferenceFailureDiagnosticsTests still referenced model.Recipe.ContextTokens, which broke the CI test job with CS1061. Thread the selected profile's ContextTokens through CreateInstall like LocalAiSetupSteps does. * fix(local-ai): redact inference diagnostics Reject verbose llama-server request and response records before extracting failure evidence, redact accepted diagnostics, normalize server-controlled line separators, and isolate the new setup tests from user data. Co-authored-by: Copilot App <[email protected]> Copilot-Session: afecb137-a9e6-4dcb-a151-72ffd3f3b3eb * fix(local-ai): reject payload records in diagnostics Apply the verbose request/response guard to recognized HTTP errors, normalize log diagnostics to one line, and retain explicit model-format failure markers. Co-authored-by: Copilot App <[email protected]> Copilot-Session: afecb137-a9e6-4dcb-a151-72ffd3f3b3eb --------- Co-authored-by: Pedro Larroy <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Scott Hanselman <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: afecb137-a9e6-4dcb-a151-72ffd3f3b3eb
|
holy cow bold |

Summary - Recommend models by explicit generation priority, then select the largest fitting context and highest KV precision. - Add measured-conservative Qwen3.8 27B context profiles with F16 and Q8_0 KV fallbacks. - Persist the selected profile through setup and launch llama-server with its context and KV-cache settings. - Retire Qwen3.5 9B from new installs and reject 16 GiB GPUs, while keeping existing managed 9B installations launchable. - Show true binary GiB values. Default capacity examples: - RTX 5090 class (34,190,458,880 CUDA-visible bytes): Qwen3.8 27B, 192K, Q8_0. - 24 GiB: Qwen3.8 27B, 64K, F16. - 16 GiB: unsupported. Qwen3.5 9B is no longer selectable. Fixes #1280. ## Release blocker fixes (
74b008fe) Two release blockers found in the earlier head28092144are fixed in this branch. 1. Implicit consent for the user-wide WSL change (security).28092144deleted the affirmative consent checkbox and setconfig.LocalAi.WslMirroredNetworkingConsent = config.LocalAi.Enabled, so merely enabling Local AI silently authorized a user-wide.wslconfigmirrored-networking rewrite and a globalwsl.exe --shutdownthat stops every running distribution. The checkbox, the_localAiNetworkingConsentRequiredgate, the reset-on-state-change helper, and the Continue gate are restored. Enabling Local AI alone no longer grants consent, and Continue stays blocked until the box is checked whenever the change is actually required. The entire consent surface inCapabilitiesPage.xaml.csis byte-identical to the pre-regression state. 2. Existing Qwen3.5 9B installs stranded on upgrade (compatibility).28092144deleted the 9B entry outright. Because the launch path resolvesLocalModelCatalog.Find(manifest.ModelCatalogId)and throws when it returns null, every user with an existing managed 9B installation would have been unable to start Local AI after upgrading. The entry is now a hidden legacy catalog record: excluded fromModels,ExplicitAlternatives, andDefault, so it can never be offered, recommended, or newly installed, but resolvable throughFindInstalledon the installed-receipt, launch, and display paths only. Its pins are reproduced exactly as installed, and it exposes only the native-context F16 profile a pre-profile install could have recorded, so nothing is remapped and a receipt that could never have existed still fails closed. ## Merge with currentmain(569ebeec) Regular merge oforigin/mainat09bc834f, which includes #1253 (fix(local-ai): bound GPU admission by dedicated device memory), #1300, and #1302. No rebase or force push. Three conflicts, resolved as follows: -CapabilitiesPage.xaml.cs: comment-only conflict; took main's CUDA-read wording. -LocalAiInstallReconciler.cs: kept both sides. This branch's five profile receipt checks (context plus the four KV precisions) and #1253's newGpuIdsMatchhelper, which replaced the previous ordinalSelectedGpuIdcomparison. -LocalInferenceQualificationTests.Evaluate_IgnoresLegacySharedMemoryFields: the one semantic conflict. #1253 owns the memory semantics, so shared/unified memory stays ignored and the 8 GiB dedicated GPU isUnsupportedwith 8 GiB detected and free. #1281 owns the catalog, so the unsupported-fallback plan is the smallest offered model.LocalInferenceSelector.SelectDefaultModelAndProfilefalls back toModels.OrderBy(m => m.Weights.SizeBytes).First(), and Qwen3.8 27B (16,464,440,224 bytes) is smaller than Qwen3.6 27B (17,106,773,120) and Qwen3.6 35B-A3B (22,663,387,424), so the expectation is Qwen3.8 27B. This branch does not modify #1253's GPU-capacity contract. ## Required proof pools -windows-11-arm64: native ARM64 model selection and app launch behavior changed. -windows-wsl-dgx-blackwell: DGX/Blackwell model selection, setup, and fixed-prompt inference changed. -windows-winui-interactive: model details and the WSL consent prompt changed. ## Validation Current head:8df3fb7c-.\build.ps1: passed, all projects and documentation validation succeeded. -dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj: 3,905 passed, 32 environment-gated skips. -dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj: 2,829 passed. -dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj: 1,030 passed. -dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj: 709 passed. - Rubber-duck review of the blocker fixes and of the merge resolution: no blocking issues. Regression coverage added for both blockers: -LocalAiWslNetworkingConsentTestsproves that without consent the step returnsFailedTerminalbefore applying anything:ApplyMirroredNetworkingis never called, the.wslconfigbytes are unchanged, no backup is staged, and no shutdown is issued. A second case proves enabling Local AI alone does not satisfy the gate. -LocalAiSetupUxContractTestsasserts the consent checkbox exists, thatWslMirroredNetworkingConsentis never assigned from the enable toggle or a literaltrue, and that the Continue gate requires the checkbox. -LocalAiPortLifecycleTests.Router_LaunchesRetiredQwen9BInstallAfterUpgradebuilds a manifest with the KV-precision fields stripped from disk, exactly as a pre-upgrade install would have been written, and proves it still resolves and launches. -LocalAiPortLifecycleTests.Catalog_DoesNotOfferRetiredQwen9BForNewInstallsproves the retired entry cannot re-enter selection. -LocalAiPortLifecycleTests.Router_RejectsRetiredQwen9BReceiptWithUnsupportedProfileproves compatibility did not become silent remapping. ## Real behavior proof Consent gate, live WinUI at this head. Setup was launched isolated on the consent step. Screenshot attached in the PR thread. - Local AI on, consent unchecked: warning panel shown with the full prompt ("Local AI needs mirrored WSL networking. Setup will update your global .wslconfig and stop all running WSL distributions once. No distributions are deleted. Save any work in WSL first.") and the checkbox "I understand and allow this global WSL change and one-time shutdown." "Install & set up" is disabled. - Checking the box: accessibility tree diff showsLocalAiNetworkingConsentCheckBoxoff -> onandPrimaryButton(disabled) -> enabledin the same action. - Toggling Local AI off and back on: the checkbox returns tooffand "Install & set up" is disabled again, so re-enabling never silently re-grants consent. Consent deny changes nothing. The host.wslconfigSHA-256 was5B5A9A4B...61542F0with no running distributions before the run, and byte-identical with no running distributions after. The denied-consent path was exercised against a redirected temp config so the user's real global config was never a test subject. Selection and receipt behavior at this head, from a standalone harness built against this branch after the merge:Offered models (3): - qwen3.8-27b-mtp-ud-q4-k-m priority=400 default=True - qwen3.6-35b-a3b-mtp-q4-k-m priority=300 default=False - qwen3.6-27b-mtp-q4-k-m priority=200 default=False Find(qwen3.5-9b) offered for new installs: False FindInstalled(qwen3.5-9b) resolvable for existing installs: True RTX 5090 class (31.84 GiB): Eligible model=qwen3.8-27b profile=ctx-196608-q8_0 required=29.11 GiB 24 GiB class: Eligible model=qwen3.8-27b profile=ctx-65536-f16 required=23.58 GiB 16 GiB class: Unsupported (required 21.59 GiB) Retired Qwen3.5 9B install, KV fields stripped from the on-disk manifest: launch.ModelAlias = qwen3.5-9b-mtp-q4-k-m gateway primary model = llamacpp/qwen3.5-9b-mtp-q4-k-m ctx-size = 262144 / cache-type-k = f16 / cache-type-v = f16 RESULT: existing Qwen3.5 9B install launches after upgrade. Non-installable legacy profile: Rejected: "The managed local AI context and KV cache receipt do not match a qualified catalog profile."This reproduces the three capacity claims in the summary at the current head, after the #1253 merge. Not verified / blocked: - Hardware blocker: Qwen3.8 selection, download, launch, and fixed-prompt inference could not be recaptured at this head. The available validation host is a 16 GiB RTX 4080 SUPER, which this PR intentionally classifies as unsupported, so it cannot select or run the Qwen3.8 27B profile at all. This needs thewindows-wsl-dgx-blackwellor RTX 5090 pool. - The earlier Windows model-selection proof was collected from integration head38a172f1. Its quoted WSL warning string is superseded: that concise message came from the removed-consent build, and the affirmative checkbox prompt shown above is what ships here. ## Security and compatibility - The user-wide.wslconfigmirrored-networking rewrite and the one-time globalwsl.exe --shutdownrequire explicit affirmative consent. Enabling Local AI does not imply it, and setup cannot proceed without it when the change is needed. - Existing manifests referencing the retired Qwen3.5 9B model ID keep launching from their own pinned receipt. Model artifacts are never silently remapped, and the retired model can never be newly installed. - No new permissions or credential handling are introduced.