Repository navigation
fix(local-ai): surface llama-server root cause on inference failure - #1284
Conversation
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 (openclaw#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 openclaw#1242 Co-Authored-By: Claude Opus 5 <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 2:55 AM ET / 06:55 UTC. ClawSweeper reviewWhat this changesThe PR surfaces sanitized llama-server inference failures and selected log diagnostics in the Local AI setup failure page, with a link to the managed server-log directory. Merge readiness✅ Ready for maintainer review Keep open. This is a coherent, current implementation of bounded Local AI failure diagnostics; the introduced path is not already present in its pinned main base, and review found no actionable correctness defect. Priority: P2 Review scores
Verification
How this fits togetherDuring setup, OpenClaw verifies a managed local llama-server before continuing onboarding. A failed inference check now carries bounded diagnostic evidence from the loopback response and managed logs into the setup completion UI. flowchart LR
A[Setup pipeline] --> B[Local AI inference check]
B --> C{Request succeeds?}
C -->|No| D[Bounded server diagnostics]
D --> E[Setup failure result]
E --> F[Completion page and log folder]
C -->|Yes| G[Continue setup]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain the bounded, sanitized diagnostic path and land it through the normal exact-head checks. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: a managed loopback llama-server HTTP failure plus its stdout/stderr failure lines reaches the changed setup step, with focused fixtures covering the path. This read-only review did not run a Local AI host itself. Is this the best way to solve the issue? Yes. Carrying bounded, sanitized evidence through the existing setup-result path is narrower and safer than exposing raw server responses or full logs in the UI. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c57002c5c3ba. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
|
@clawsweeper addressed P1 and provided behaviour proof, please review again |
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]>
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]>
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]>
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]>
db50083 to
adcaf91
Compare
…surface-llama-error
|
@clawsweeper provided proof with latest commit, is this ready to merge? |
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.
…surface-llama-error
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
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

Summary
Surface bounded llama-server failure evidence when setup-time Local AI inference fails, instead of showing only a bare HTTP status.
{"error": ...}fields from bounded loopback HTTP failures.LocalAiFailureDetailthrough the setup pipeline and show diagnostics plus the resolved log directory on the completion page.log_server,request:, andresponse:records so prompts and assistant output cannot enter setup logs or UI.The branch was merged with current
mainthroughc57002c5, including the recently landed CI, release, cache, and triage changes.Maintainer landing review
Hanselman adversarial review ran with Claude Opus 5 and GPT-5.3-Codex over the complete post-merge diff. Both models identified the same high-confidence privacy boundary: broad keyword matching could select verbose llama-server request/response records containing prompt or assistant content. The landing commits close that path and add direct sentinel coverage.
Final exact-head re-review certified
4c669607901ec9f16261977f6239077381e1acbcwith no remaining CRITICAL, HIGH, or MEDIUM actionable findings.Required proof pools
windows-winui-interactive: the setup completion page renders Local AI diagnostics and the Local AI log link. Contributor-provided visible proof is attached below, and the current exact-head isolated WinUI app was launched successfully during the landing pass.noneforwindows-wsl-dgx-blackwell: this change does not alter GPU detection, model execution, or hardware support. The Blackwell failure signatures are fixture inputs to bounded diagnostic extraction, so no live Blackwell host is required to validate this behavior.Validation
Local Windows 11, exact head
4c669607901ec9f16261977f6239077381e1acbc:.\build.ps1- passed in 50.8s. Shared, CLI, WinNodeCli, SetupEngine, and WinUI built; docs and proof-pool validation passed.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore- 3905 passed, 32 skipped, 0 failed in 30.1s.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore- 2840 passed, 0 failed in 40.1s.dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore- 1045 passed, 0 failed in 38.3s.dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore- 718 passed, 0 failed in 22.0s..\run-app-local.ps1 -NoBuild -Isolated -AllowNonMain- exact-head WinUI setup launched successfully with an isolated data directory.33845966180, exact head - all required lanes passed and CI Gate passed in 10s. Job timings: change classification 12s, fast validation 38s, proof-pool contracts 18s, release metadata 38s, core/CLI 5m28s, tray/setup/integration 6m30s, UI/functional/accessibility 11m17s, network recovery E2E 11m46s, setup/connect E2E 24m12s, revocation recovery E2E 21m18s, and x64 release smoke 5m19s.Real behavior proof
LlamaServerInferenceClientTestsdrives the real HTTP parsing path and proves recognized model-load failures surface, unrecognized bodies fall back to status-only, verbose request records are rejected, credentials are redacted, Unicode line separators are flattened, and assistant output never enters exceptions.LocalAiLogTailTestsuses abridged real CUDA failure lines and adversarial request/response fixtures. It proves prompt and assistant sentinels are dropped even when they contain failure keywords, accepted diagnostics are credential-redacted and single-line, and CUDA/allocation/exit/model-format markers remain visible.LocalAiInferenceFailureDiagnosticsTestsdrives the real setup step and proves diagnostics are captured before router restart, threaded throughStepResult, and isolated from real user data.CompletePageLocalAiHelpLinkContractTestsproves Local AI detail bypasses URL extraction, packaged-path display is resolved, and unavailable log directories are hidden.The image URL was rechecked during landing: HTTP 200,
image/png, 79,916 bytes.Not blocked: no signing, credential, CI/workflow, gateway, or hardware-support behavior is changed by this PR. Live Blackwell execution was not run because it is outside this diagnostic-surfacing change and is not an applicable required proof pool.
Change Type
Scope
winnodeSecurity Impact
NoOnly stricter redaction of diagnostic textNo; this reads the bounded body of the existing loopback-only inference request.NoNo; only bounded app-managed llama-server logs and recognized loopback error fields are read.Compatibility and Migration
YesNoNoReview Conversations