Skip to content

[Bug]: LM Studio model identifier gets @q4_k_m/@q8_0 quant suffix appended on retry path — assistant turn falsely marked as error #95394

Closed

Description

@spacenet-Pop-OS

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, primary lmstudio/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:

  1. LM Studio returns 400 Invalid model identifier "<id>@q4_k_m" (verbatim, the suffix appears in the error).
  2. 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.
  3. 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

  1. Run OpenClaw with at least one agent whose model.primary is an LM Studio model with multiple quant variants on disk but only one loaded.
  2. Set that agent's heartbeat.every to a small interval (e.g. 19m), or simply chat with it.
  3. 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:

  1. First try the clean identifier (gemma-4-e4b-it-ultra-uncensored-heretic) → LM Studio returns 400 "Invalid model identifier" (cleanly, without suffix).
  2. Wait for any currently-running model to finish streaming (e.g. huihui-gemma-4-e2b-it-qat-unquantized-abliterated-i1).
  3. Make a second POST /v1/chat/completions request with the identifier gemma-4-e4b-it-ultra-uncensored-heretic@q4_k_m — with the suffix appended.
  4. LM Studio rejects it again, this time echoing the @q4_k_m suffix in the error message.
  5. 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 as messageCounts.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/completions per 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 model field 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

Activity

  1. clawsweeper commented on Jun 20, 2026

    @clawsweeper
    Contributor

    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: canonical
    Canonical: #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:

    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:

    • Current-main canonicalization source: Current main adds resolveLmstudioCanonicalModelKey, where exact key matches win and variants or selected_variant map back to the canonical LM Studio key. (extensions/lmstudio/src/models.ts:242, 9fa14ff61a85)
    • Current-main load path source: ensureLmstudioModelLoaded now resolves canonicalModelKey, 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)
    • Current-main stream path source: wrapLmstudioInferencePreload now 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)
    • Regression tests: Tests cover canonical-key loading for advertised variants, retaining canonical keys after load failure, preserving exact suffixed server keys, and streaming with the canonical key during preload failure/cooldown. (extensions/lmstudio/src/models.test.ts:498, 9fa14ff61a85)
    • Pre-fix shipped behavior: The v2026.6.9 source lacks variant canonicalization and posts modelKey directly to /api/v1/models/load, matching the reported release behavior. (extensions/lmstudio/src/models.fetch.ts:248, c645ec4555c0)
    • Fix provenance: The fix/proof commit is fix(lmstudio): canonicalize variant model keys (#95401), committed at 2026-06-22T17:20:54Z. (405896a4a31b)

    Likely related people:

    • MonkeyLeeT: Live path history shows the merged LM Studio canonicalization PR as the latest relevant provider change. (role: candidate fix author; confidence: high; commits: 405896a4a31b; files: extensions/lmstudio/src/models.ts, extensions/lmstudio/src/models.fetch.ts, extensions/lmstudio/src/stream.ts)
    • rugvedS07: GitHub history shows the original LM Studio integration introduced the provider discovery, preload, and stream surfaces involved here. (role: original feature contributor; confidence: high; commits: 0cfb83edfae9; files: extensions/lmstudio/src/models.ts, extensions/lmstudio/src/models.fetch.ts, extensions/lmstudio/src/stream.ts)
    • steipete: Recent path history includes LM Studio discovery and context validation work in the same provider model files. (role: recent area contributor; confidence: medium; commits: 80f7e36ddc59; files: extensions/lmstudio/src/models.ts, extensions/lmstudio/src/models.fetch.ts)
    • vincentkoc: Recent path history includes LM Studio model-load error handling work in the same load path. (role: recent area contributor; confidence: medium; commits: aff6e221a7b5; files: extensions/lmstudio/src/models.fetch.ts)
    • xantorres: History shows prior preload backoff work in the stream wrapper whose cooldown path now carries the canonical key. (role: adjacent preload behavior contributor; confidence: medium; commits: b555214c9626; files: 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.

  2. added
    P2
    impact:session-state
    impact:auth-provider
    issue-rating: 🐚 platinum hermit
    clawsweeper:needs-live-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    and removed
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-live-repro
    issue-rating: 🐚 platinum hermit
    on Jun 20, 2026
  3. locked as resolved and limited conversation to collaborators on Jun 25, 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:source-reproimpact:auth-providerimpact:session-stateissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions