Repository navigation
Description
Summary
Immediately after Local AI setup hot-reloads agents.defaults.model.primary and models.providers.llamacpp, the embedded agent can still dispatch one or more requests through the stale openai/gpt-5.6-sol primary. On a Local AI-only installation with no OpenAI credential, the first prompt fails with missing-provider-auth even though the llama.cpp provider configuration was just applied.
This is separate from #1282. That PR removes stale setup-managed gateway records; it does not synchronize gateway provider reload with embedded-agent dispatch.
Environment
- Windows 11 ARM64 on RTX Spark hardware
- Windows integration branch
integration/local-ai-2026-09-02, head38a172f1 - Gateway
OpenClaw 2026.6.34 (5c38f99)in the managedOpenClawGatewayWSL distro - Managed Local AI model: Qwen3.8 27B through the
llamacppprovider
Reproduction
- Run managed Local AI setup from a clean/isolated Windows app state.
- Complete model/provider configuration.
- Send the first embedded-agent prompt immediately after setup reports completion and the gateway reports the provider/model hot reload as applied.
Actual behavior
The gateway log shows the new Local AI configuration applied, followed about one second later by a request using the stale OpenAI primary:
2026-09-02T16:59:32.323Z config change detected (agents.defaults.model.primary, models.providers.llamacpp)
2026-09-02T16:59:33.144Z config hot reload applied (agents.defaults.model.primary, models.providers.llamacpp)
2026-09-02T16:59:34.174Z ProviderAuthError: No API key found for provider "openai"
2026-09-02T16:59:34.186Z requestedProvider="openai" requestedModel="gpt-5.6-sol" code="missing-provider-auth"
After the provider/model configuration is applied again and the gateway settles, the same installation routes correctly:
2026-09-02T17:03:55.625Z provider=llamacpp model=qwen3.8-27b-mtp-ud-q4-k-m POST /v1/chat/completions
2026-09-02T17:04:36.148Z provider=llamacpp status=200
The user-visible failure is:
Agent failed before reply: No API key found for provider "openai" ... | missing-provider-auth
No OpenAI provider is intended or required for this Local AI-only setup.
Expected behavior
Once the grouped provider/model reload reports success, every newly dispatched embedded-agent request should resolve the new llamacpp primary. A request must not observe stale model/provider state or tell the user to configure an unrelated OpenAI credential.
Suggested acceptance criteria
- Apply the provider registration and default-model switch atomically from the embedded agent's point of view.
- Gate or retry first dispatch while provider/model state is reloading instead of falling through to stale auth state.
- Add a deterministic test that pauses reload between config persistence, provider registration, agent model resolution, and first dispatch.
- Add current-head proof for setup completion followed immediately by a successful first Local AI prompt without a manual gateway restart or second config write.
Diagnostics
- The setup log
setup-engine-20260902-164018.jsonlrecords a separate pre-cleanup recipe-mismatch failure and is not the source of this provider-auth error. - The relevant evidence is in gateway logs around
2026-09-02T16:59:32Zthrough17:04:36Z. - Identifiers and tokens are intentionally omitted from the excerpts above.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Sep 2, 2026
ClawSweeper status: review started.
I am starting a fresh review of this issue: fix(local-ai): avoid stale OpenAI primary after provider hot reload This is item 1/1 in the current shard. Shard 0/1.
This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.
Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.
larroy commentedon Sep 4, 2026
Reproduced on Windows 11 x64 / RTX 5090 with the same model (Qwen3.8 27B UD-Q4_K_M via
llamacpp), gateway2026.6.34. I dug into it and I think the diagnosis in the issue body is slightly off in a way that matters for the fix: this is not a stale-reload/dispatch race inside the gateway. The companion deliberately unsets the Local AI config and leaves it unset for ~10 seconds.What actually happens
~/.openclaw/logs/config-audit.jsonlin the managed distro shows three writes on tray startup:openclaw config unset agents.defaults.model.primaryopenclaw config unset models.providers.llamacppopenclaw config set --batch-file /dev/stdin(re-publishes provider + primary)My first prompt landed at 18:26:15 local — inside that ~9s hole. Gateway journal:
So the reload at 18:26:14 was correct — it correctly applied the unset. With
agents.defaults.model.primaryabsent, the gateway resolves its built-in defaultopenai/gpt-5.6-sol, which has no credential. Nothing is stale and no dispatch observed torn state; the gateway did exactly what the config told it to. Once the batch write lands at 18:26:22 the same install routes cleanly (provider=llamacpp ... status=200 elapsedMs=3987at 18:28:36).Why the window exists
LlamaServerRuntimeService.EnsureStartedCoreAsync(src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs:168) sequences quiesce → start → probe → publish:QuiesceAsyncunsetsmodels.providers.llamacpp, and becausemanifest.GatewayFallbackModelisnullit unsetsagents.defaults.model.primaryoutright (LocalAiGatewayProviderCoordinator.cs:75-90)."requestedPort": 0, so the endpoint port is OS-assigned on every run and the previously publishedbaseUrlis stale by construction.PublishAsyncrestores provider + primary only after the probe succeeds.StartLocalAiRouterInBackground(src/OpenClaw.Tray.WinUI/App.xaml.cs:966) is intentionally fire-and-forget so it can't delay tray startup, so the chat window is live and accepting sends for the whole window. That is why it reproduces every time: send anything within ~10s of app start.Worth noting this reproduces on plain app start, not just immediately after setup — the quiesce/publish cycle runs on every launch.
Implication for the acceptance criteria
The listed criteria target gateway-side reload/dispatch synchronization, which I don't think is where the defect is. Suggested reframing:
agents.defaults.model.primarywhile Local AI is the selected route. Unsetting is what hands routing to the built-in OpenAI default. Keeping it pointed atllamacpp/<alias>across the cycle turns the failure into a local transport error instead of a foreign-provider auth error.requestedPort); with a stable endpoint the previous run's published config is already valid, soEnsureStartedCoreAsynccan skipQuiesceAsyncentirely when the live config already matches the managed definition.PublishAsyncalready returnsOkon an exact match (LocalAiGatewayProviderCoordinator.cs:118-127).config set --batch-filerather than unset-now / set-later._localAiRuntimeis already in the DI context (App.xaml.cs:469); surfacingLocalAiRuntimeSnapshot.Stateto the composer covers the residual cold-start seconds.Useful regression test: assert that across a full restart cycle, no observed gateway config state has the primary model unset. That fails today and is independent of any gateway-side timing.
Separately (not the cause here, but relevant to first-prompt latency): the generated preset sets
load-on-startup = false, so the first real request also pays model load — ~4s in my run, well inside the provider'stimeoutSeconds: 300.Tokens, session keys and identifiers omitted from all excerpts above.
fix(local-ai): stop routing to OpenAI while the endpoint restarts
fix(local-ai): stop routing to OpenAI while the endpoint restarts
fix(local-ai): keep routing safe across endpoint restarts (#1390)
github-actions commentedon Sep 19, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updated OpenClaw Windows details or it will be closed.
github-actions commentedon Sep 26, 2026
Closing due to inactivity.
If this still affects OpenClaw Windows, open a new issue with the current version, logs, and fresh reproduction details.