Skip to content

Require verified managed-model evidence before publishing Local AI #1192

Closed

Description

@joelagnel

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.

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.");
}

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.

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:

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 ModelState to be Verified or Loaded.
  • Require the reported model path to match the expected managed path.
  • Keep startup unready or fail it when evidence is Unknown or NotInstalled.
  • Apply the same readiness predicate during refresh.

Tests

Add focused coverage for:

  • Model-status timeout after successful /health
  • Invalid /models response
  • 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

Raised by @larroy during the PR #1178 review follow-up.

Activity

  1. added
    clawsweeper:needs-info
    impact:auth-provider
    issue-rating: 🦐 gold shrimp
    P2
    on Aug 21, 2026
  2. clawsweeper commented on Aug 21, 2026

    @clawsweeper

    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: canonical
    Canonical: #1192
    Summary: This issue is the focused readiness follow-up for the broader open Local AI implementation.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    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:

    • If the open Local AI PR publishes an endpoint after only process-level health, the gateway can route to a provider that cannot serve the selected managed model.

    Codex review notes: model internal, reasoning high; reviewed against d3ed6c78bf14.

    Label changes

    Label changes:

    • add P2: A published Local AI endpoint that cannot serve its selected model is a bounded provider-routing correctness problem.
    • add impact:auth-provider: The report concerns publication and routing eligibility of a Local AI provider endpoint.
    • add issue-rating: 🦐 gold shrimp: Current issue advisory state selects this label.
    • add 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:

    • Current-main and release surface: Neither current main nor v2026.7.1 contains tracked Local AI or llama-server paths, so the requested readiness behavior is not already implemented or shipped. (d3ed6c78bf14)
    • Release provenance: v2026.7.1 is an ancestor of current main, and main is currently at d3ed6c7; neither revision has the affected subsystem. (4206611f2b2e)
    • Open implementation path: The report explicitly identifies the open Local AI feature PR as the review follow-up containing the affected probe and publication path. That PR is unmerged and therefore does not resolve this issue. (src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs:243, 31dffdb0dbd9)
    • PR-head inspection limit: The supplied report links exact PR-head source lines, but this read-only promisor checkout does not contain that commit and its attempted read-only fetch could not resolve github.com. The exact predicate was therefore not independently verified from the branch tree. (src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs:167, 31dffdb0dbd9)
    • Adjacent connection history: Current connection-area history shows a recent gateway compatibility change, providing an adjacent routing contact but no merged Local AI feature history yet. (src/OpenClaw.Connection/ConnectionStateMachine.cs:1, 428db773d8be)

    Likely related people:

    • larroy: The issue says this readiness requirement was raised during review of the Local AI PR, and the timeline records their mention on this issue. (role: review-origin reporter; confidence: medium; files: src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs, src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs)
    • Barbara Kudiess: Recent current-main history covers the connection subsystem that will consume the Local AI provider endpoint. (role: recent adjacent contributor; confidence: low; commits: 428db773d8be; files: src/OpenClaw.Connection/ConnectionStateMachine.cs)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. locked as resolved and limited conversation to collaborators on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:needs-infoimpact:auth-providerissue-rating: 🦐 gold shrimp

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions