Repository navigation
Description
Problem
The managed llama-server client treats a successful /health response as sufficient router health even when the configured model cannot be verified through /models.
After /health succeeds, ProbeRouterAsync returns IsHealthy = true when the model-status request times out or returns invalid data. It also returns IsHealthy = true with ModelState = NotInstalled when the configured alias is absent.
openclaw-windows-node/src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs
Lines 167 to 199 in 31dffdb
| public async Task<LlamaServerRouterProbeResult> ProbeRouterAsync( | |
| Uri endpoint, | |
| string modelAlias, | |
| string expectedModelPath, | |
| CancellationToken cancellationToken = default) | |
| { | |
| ArgumentNullException.ThrowIfNull(endpoint); | |
| ArgumentException.ThrowIfNullOrWhiteSpace(modelAlias); | |
| ArgumentException.ThrowIfNullOrWhiteSpace(expectedModelPath); | |
| ValidateManagedEndpoint(endpoint); | |
| if (!await ProbeHealthAsync(endpoint, cancellationToken).ConfigureAwait(false)) | |
| { | |
| return new( | |
| false, | |
| LocalAiModelAvailabilityState.Unknown, | |
| null, | |
| "The llama-server router health check did not succeed."); | |
| } | |
| try | |
| { | |
| return await ProbeModelAsync(endpoint, modelAlias, expectedModelPath, cancellationToken) | |
| .ConfigureAwait(false); | |
| } | |
| catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested) | |
| { | |
| return new(true, LocalAiModelAvailabilityState.Unknown, null, "The model status check timed out."); | |
| } | |
| catch (Exception ex) when (ex is HttpRequestException or IOException or JsonException or InvalidDataException) | |
| { | |
| return new(true, LocalAiModelAvailabilityState.Unknown, null, "The model status response was invalid."); | |
| } |
openclaw-windows-node/src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs
Lines 231 to 258 in 31dffdb
| private async Task<LlamaServerRouterProbeResult> ProbeModelAsync( | |
| Uri endpoint, | |
| string modelAlias, | |
| string expectedModelPath, | |
| CancellationToken cancellationToken) | |
| { | |
| using var response = await _client.GetAsync( | |
| BuildEndpointUri(endpoint, "/models", "autoload=false"), | |
| HttpCompletionOption.ResponseHeadersRead, | |
| cancellationToken) | |
| .ConfigureAwait(false); | |
| if (!response.IsSuccessStatusCode) | |
| throw new HttpRequestException($"llama-server model status returned HTTP {(int)response.StatusCode}."); | |
| byte[] payload = await ReadBoundedAsync(response.Content, cancellationToken).ConfigureAwait(false); | |
| using JsonDocument document = JsonDocument.Parse(payload, new JsonDocumentOptions { MaxDepth = 16 }); | |
| LlamaServerModelStatusEvidence? evidence = LlamaServerModelStatusParser.Parse( | |
| document.RootElement, | |
| modelAlias, | |
| expectedModelPath); | |
| if (evidence is null) | |
| return new(true, LocalAiModelAvailabilityState.NotInstalled, null, "The configured model is not registered."); | |
| return new( | |
| true, | |
| evidence.State, | |
| evidence.ModelPath, | |
| $"llama-server reports the model as {evidence.ServerStatus}."); | |
| } |
LlamaServerRuntimeService checks only probe.IsHealthy. It then saves the endpoint, publishes the provider, and reports Healthy, regardless of ModelState or ReportedModelPath.
openclaw-windows-node/src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs
Lines 243 to 270 in 31dffdb
| LlamaServerRouterProbeResult probe = await _client.ProbeRouterAsync( | |
| ownership.Endpoint, | |
| install.Manifest.ModelAlias, | |
| install.ModelPath, | |
| cancellationToken) | |
| .ConfigureAwait(false); | |
| if (probe.IsHealthy) | |
| { | |
| LocalAiInstallManifest verifiedManifest = install.Manifest with | |
| { | |
| Endpoint = ownership.Endpoint.AbsoluteUri, | |
| }; | |
| await _manifestStore.SaveAsync(verifiedManifest, cancellationToken).ConfigureAwait(false); | |
| _install = _manifestStore.ResolveAndValidate(verifiedManifest); | |
| LocalAiEndpointLifecycleResult published = await _options.EndpointLifecycle | |
| .PublishAsync(_install, cancellationToken) | |
| .ConfigureAwait(false); | |
| if (!published.Success) | |
| { | |
| return await FailStartupAsync( | |
| LocalAiRuntimeState.Failed, | |
| published.Detail ?? "The Local AI gateway provider could not be safely published.") | |
| .ConfigureAwait(false); | |
| } | |
| return PublishHealthy(probe); | |
| } |
The refresh path has the same predicate:
openclaw-windows-node/src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs
Lines 343 to 356 in 31dffdb
| LlamaServerRouterProbeResult probe = await _client.ProbeRouterAsync( | |
| ownership.Endpoint, | |
| install.Manifest.ModelAlias, | |
| install.ModelPath, | |
| cancellationToken) | |
| .ConfigureAwait(false); | |
| return probe.IsHealthy | |
| ? PublishHealthy(probe) | |
| : Publish( | |
| LocalAiRuntimeState.Starting, | |
| LocalAiOwnership.CompanionManaged, | |
| "The local AI router is not healthy yet.", | |
| _managedProcess.ProcessId, | |
| _managedProcess.StartedAtUtc); |
Impact
The gateway can receive a provider endpoint that is alive at the process level but cannot serve the configured managed model. The tray can also report Local AI as healthy while model evidence is unknown or not installed.
Expected behavior
Before saving or publishing the endpoint:
- Require router health to succeed.
- Require
ModelStateto beVerifiedorLoaded. - Require the reported model path to match the expected managed path.
- Keep startup unready or fail it when evidence is
UnknownorNotInstalled. - Apply the same readiness predicate during refresh.
Tests
Add focused coverage for:
- Model-status timeout after successful
/health - Invalid
/modelsresponse - Missing configured alias (
NotInstalled) - Unknown model state
- Wrong or missing model path
- Verified and loaded success cases
- No manifest save or provider publish for unverified evidence
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Aug 21, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 21, 2026, 3:58 PM ET / 19:58 UTC.
Summary
This remains necessary as a focused correctness follow-up to the open Local AI implementation. Current main and the latest release contain no Local AI surface, and the linked PR is still open, so it must not be closed as implemented.
Reproducibility: no. current-main reproduction exists because current main lacks the Local AI subsystem. The supplied PR-head line references describe a deterministic focused test matrix, but that branch commit was unavailable for local source inspection.
Root-cause cluster
Relationship:
canonicalCanonical: #1192
Summary: This issue is the focused readiness follow-up for the broader open Local AI implementation.
Members:
partial_overlap: feat: add managed local AI with llama-server #1178 - The PR introduces the broader managed Local AI feature containing the reported probe-and-publication path.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Ways to help us reproduce this
Next step
The linked open feature PR already owns the affected code, so a separate repair PR should not be dispatched.
Review details
Best possible solution:
Use one tested model-evidence predicate in startup and refresh, and permit endpoint saving, provider publication, and healthy status only when the expected managed model is verified or loaded.
Do we have a high-confidence way to reproduce the issue?
No current-main reproduction exists because current main lacks the Local AI subsystem. The supplied PR-head line references describe a deterministic focused test matrix, but that branch commit was unavailable for local source inspection.
Is this the best way to solve the issue?
Yes. A shared predicate is the narrowest maintainable direction because it prevents startup and refresh readiness decisions from drifting.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against d3ed6c78bf14.
Label changes
Label changes:
P2: A published Local AI endpoint that cannot serve its selected model is a bounded provider-routing correctness problem.impact:auth-provider: The report concerns publication and routing eligibility of a Local AI provider endpoint.issue-rating: 🦐 gold shrimp: Current issue advisory state selects this label.clawsweeper:needs-info: Current issue advisory state selects this label.Label justifications:
P2: A published Local AI endpoint that cannot serve its selected model is a bounded provider-routing correctness problem.impact:auth-provider: The report concerns publication and routing eligibility of a Local AI provider endpoint.Evidence reviewed
What I checked:
src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs:243, 31dffdb0dbd9)src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs:167, 31dffdb0dbd9)src/OpenClaw.Connection/ConnectionStateMachine.cs:1, 428db773d8be)Likely related people:
src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs,src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs)src/OpenClaw.Connection/ConnectionStateMachine.cs)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.