Repository navigation
Description
Environment
- OpenClaw: 2026.6.9-beta.1 (build 687234a)
- LM Studio: 0.4.17-beta+3
- Host: Pop!_OS Linux 7.0.11-76070011-generic (x64)
- Reproducer agent:
daji(heartbeat every 19m, primarylmstudio/gemma-4-e4b-it-ultra-uncensored-heretic) - LM Studio JIT model loading: disabled
Summary
When an OpenClaw-managed LM Studio assistant turn fails to find a primary model loaded and retries (or attempts to load the model), OpenClaw appends a GGUF quant suffix like @q4_k_m or @q8_0 to the model identifier. LM Studio's identifier namespace does not include these suffixes — the only place they exist is in the on-disk filename. As a result:
- LM Studio returns
400 Invalid model identifier "<id>@q4_k_m"(verbatim, the suffix appears in the error). - OpenClaw records the assistant turn with
stopReason="error"even though LM Studio successfully completed an earlier turn with the same model identifier (without suffix) seconds before. - The Usage dashboard's "errors" counter increases for sessions that actually completed their work via a fallback chain (
openrouter/deepseek/deepseek-v4-flash).
Reproduction
Setup
- Run OpenClaw with at least one agent whose
model.primaryis an LM Studio model with multiple quant variants on disk but only one loaded. - Set that agent's
heartbeat.everyto a small interval (e.g. 19m), or simply chat with it. - LM Studio must NOT have the primary model loaded at turn time (or have just finished streaming with another model).
Trigger
Send a turn to the agent when its primary LM Studio model is unloaded. OpenClaw will:
- First try the clean identifier (
gemma-4-e4b-it-ultra-uncensored-heretic) → LM Studio returns 400 "Invalid model identifier" (cleanly, without suffix). - Wait for any currently-running model to finish streaming (e.g.
huihui-gemma-4-e2b-it-qat-unquantized-abliterated-i1). - Make a second
POST /v1/chat/completionsrequest with the identifiergemma-4-e4b-it-ultra-uncensored-heretic@q4_k_m— with the suffix appended. - LM Studio rejects it again, this time echoing the
@q4_k_msuffix in the error message. - OpenClaw records the turn as
stopReason="error"with the corrupted identifier in the session log.
Evidence from a real session (4acdc79b-fedc-4698-af68-ce7e5797297f.jsonl, today 2026-06-20 20:03–20:04)
OpenClaw session JSONL entries (verbatim from /home/spacenet/.openclaw/agents/daji/sessions/4acdc79b-fedc-4698-af68-ce7e5797297f.jsonl):
[2026-06-20T20:03:05.846] session_id=4acdc79b
[2026-06-20T20:03:05.866] model_change: lmstudio:huihui-gemma-4-e2b-it-qat-unquantized-abliterated-i1
[2026-06-20T20:03:05.866] thinking: medium
[2026-06-20T20:03:05.935] msg role=user stop=- ← heartbeat poll prompt
[2026-06-20T20:04:05.910] msg role=assistant stop=aborted lmstudio:huihui-gemma-4-e2b-it-qat-unquantized-abliterated-i1
[2026-06-20T20:04:06.391] msg role=assistant stop=error lmstudio:gemma-4-e4b-it-ultra-uncensored-heretic@q4_k_m ← suffix appended
[2026-06-20T20:04:13.316] msg role=assistant stop=toolUse openrouter:deepseek/deepseek-v4-flash
[2026-06-20T20:04:16.240] msg role=assistant stop=toolUse openrouter:deepseek/deepseek-v4-flash
[2026-06-20T20:04:22.282] msg role=assistant stop=stop openrouter:deepseek/deepseek-v4-flash
LM Studio server log (~/.lmstudio/server-logs/2026-06/2026-06-20.2.log) for the same window:
[2026-06-20 20:03:57][DEBUG] Received request: POST to /v1/chat/completions with body [Sensitive]
[2026-06-20 20:03:57][ERROR] Invalid model identifier "gemma-4-e4b-it-ultra-uncensored-heretic".
No matching loaded model found, and just-in-time (JIT) model loading is disabled.
[2026-06-20 20:04:05][INFO][huihui-gemma-4-e2b-it-qat-unquantized-abliterated-i1] Finished streaming response
[2026-06-20 20:04:06][DEBUG] Received request: POST to /api/v1/models/load with body [Sensitive]
[2026-06-20 20:04:06][DEBUG] Received request: POST to /v1/chat/completions with body [Sensitive]
[2026-06-20 20:04:06][ERROR] Invalid model identifier "gemma-4-e4b-it-ultra-uncensored-heretic@q4_k_m".
No matching loaded model found, and just-in-time (JIT) model loading is disabled.
Note the suffix appears inside the LM Studio error message verbatim, meaning OpenClaw sent it on the wire. Also note the /api/v1/models/load request at 20:04:06 — OpenClaw is trying to auto-load the model, but the load request body apparently contains the suffix (it is [Sensitive] in the published logs).
The smoking gun
The [ERROR] lines for @q4_k_m in the LM Studio log are 100% the time correlated with OpenClaw retries; LM Studio's own /v1/models endpoint never advertises an identifier with a quant suffix:
$ curl -s http://127.0.0.1:1234/v1/models | jq '.data[].id'
"text-embedding-nomic-embed-text-v1.5"
"qwen3.5-0.8b"
"toolcalls-2b"
"gemma-4-e4b-it-ultra-uncensored-heretic"
The only place @q4_k_m exists is in the on-disk filename: gemma-4-E4B-it-ultra-uncensored-heretic-Q4_K_M.gguf. So OpenClaw is reading the filename (or some other GGUF-metadata path) and grafting the suffix onto the logical identifier on the retry/load path.
Impact
- Inflated error counters. The Usage dashboard counts
stopReason ∈ {"error","aborted","timeout"}per assistant turn asmessageCounts.errors. For the daji agent in a typical day, ~30% of heartbeats have one such false-positive error, contributing 35/90 = 39% of today's reported errors. Sessions are otherwise completing successfully via the openrouter deepseek fallback. - Wasted LM Studio calls. Two invalid
/v1/chat/completionsper affected heartbeat (one without suffix, one with) plus a failed/api/v1/models/load. - Inflated "Invalid model identifier" warnings in the LM Studio log. This masks genuine config drift issues because the dashboard-level error stream is dominated by this false signal.
- Visibility drift. The session log's
modelfield carries the corrupted identifier (gemma-4-e4b-it-ultra-uncensored-heretic@q4_k_m), so usage analytics split a single logical model into multiple phantom entries.
Workaround
Tried on this end — DaJi's heartbeat model was changed to lmstudio/qwen3.5-0.8b (which is permanently loaded) and that agent's model.primary was corrected to a model identifier without a quant suffix. The retry path still triggers the suffix append, so the bug persists for any agent whose model.primary is an LM Studio identifier with a quant variant on disk.
Suggested fix
In OpenClaw's LM Studio provider, when resolving the model identifier for retry/load paths:
- Use the logical identifier from
/v1/models("data": [{"id": "gemma-4-e4b-it-ultra-uncensored-heretic"}]), not anything derived from the on-disk GGUF filename. - Strip any
@<quant>suffix from the identifier before issuing chat-completion or load requests. - When receiving an "Invalid model identifier" from LM Studio, do not re-issue with the suffix appended — log the resolved identifier at the time of the original request for debugging instead.
How to reproduce quickly
# 1. Make sure gemma-4-e4b is NOT loaded in LM Studio
lms unload gemma-4-e4b-it-ultra-uncensored-heretic
# 2. Send any prompt to daji agent (heartbeat will fire it within 19m anyway)
# 3. Watch LM Studio log tail:
tail -f ~/.lmstudio/server-logs/$(date +%Y-%m-%d).2.log | grep -i 'invalid model'
# 4. Look for the @q4_k_m suffix in the error message — comes from OpenClaw retry.Reporter
Marcus, OpenClaw 2026.6.9-beta.1 on Pop!_OS, LM Studio 0.4.17-beta+3. Repro available at will.
Related
- Bug: TUI mid-session model switch passes raw alias instead of resolved model ID #75163 — TUI mid-session model switch passes raw alias instead of resolved model ID (same family of bug: identifier not resolved correctly before hitting LM Studio)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 20, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Close as implemented: current main resolves LM Studio advertised variant ids to canonical model keys through preload, load failure, cooldown, and chat streaming, so the reported false error path is fixed on main.
I found the merged PR that appears to have closed this: #95401: fix(lmstudio): canonicalize variant model keys.
Root-cause cluster
Relationship:
canonicalCanonical: #95394
Summary: This issue is the canonical report for the LM Studio variant-key preload/chat bug; the merged PR fixes it, while the older TUI alias issue is only a broader model-resolution overlap.
Members:
fixed_by_candidate: fix(lmstudio): canonicalize variant model keys #95401 - The merged PR references this issue and changes the implicated LM Studio provider preload and stream files.partial_overlap: Bug: TUI mid-session model switch passes raw alias instead of resolved model ID #75163 - That issue also concerns non-canonical model identifiers reaching LM Studio, but its TUI alias persistence path is distinct.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the merged provider-local canonicalization on main and let the next release carry the fix to users.
Do we have a high-confidence way to reproduce the issue?
Yes. The issue provides real LM Studio and session logs, and the pre-fix v2026.6.9 code path sent the requested suffix-bearing model key through load and stream unchanged.
Is this the best way to solve the issue?
Yes. The main implementation is the narrow provider-local fix: resolve variants from LM Studio discovery data instead of blanket-stripping quant suffixes.
Security review:
Security review: No patch security review applies to this non-PR issue triage.
AGENTS.md: found and applied where relevant.
What I checked:
resolveLmstudioCanonicalModelKey, where exactkeymatches win andvariantsorselected_variantmap back to the canonical LM Studiokey. (extensions/lmstudio/src/models.ts:242, 9fa14ff61a85)ensureLmstudioModelLoadednow resolvescanonicalModelKey, posts that value to/api/v1/models/load, returns it on success, and attaches it to load failures. (extensions/lmstudio/src/models.fetch.ts:241, 9fa14ff61a85)wrapLmstudioInferencePreloadnow carries the resolved model key through preload success, preload failure, and cooldown before calling the OpenAI-compatible stream. (extensions/lmstudio/src/stream.ts:248, 9fa14ff61a85)extensions/lmstudio/src/models.test.ts:498, 9fa14ff61a85)modelKeydirectly to/api/v1/models/load, matching the reported release behavior. (extensions/lmstudio/src/models.fetch.ts:248, c645ec4555c0)fix(lmstudio): canonicalize variant model keys (#95401), committed at 2026-06-22T17:20:54Z. (405896a4a31b)Likely related people:
extensions/lmstudio/src/models.ts,extensions/lmstudio/src/models.fetch.ts,extensions/lmstudio/src/stream.ts)extensions/lmstudio/src/models.ts,extensions/lmstudio/src/models.fetch.ts,extensions/lmstudio/src/stream.ts)extensions/lmstudio/src/models.ts,extensions/lmstudio/src/models.fetch.ts)extensions/lmstudio/src/models.fetch.ts)extensions/lmstudio/src/stream.ts)Codex review notes: model internal, reasoning high; reviewed against 9fa14ff61a85; fix evidence: merged PR #95401, commit 405896a4a31b, main fix timestamp 2026-06-22T17:20:54Z.