Skip to content

fix(agents): preserve LM Studio @iq* quant suffixes in model refs - #71490

Closed
Sanjays2402 wants to merge 1 commit into
openclaw:mainfrom
Sanjays2402:fix/71474-lmstudio-at-model-names-2
Closed

Sanjays2402 wants to merge 1 commit into
openclaw:mainfrom
Sanjays2402:fix/71474-lmstudio-at-model-names-2

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Fixes #71474

Problem

LM Studio names imatrix-quant variants like qwen3.6-27b@iq3_xxs (note: iq prefix, not q). splitTrailingAuthProfile only special-cased @q* / <n>bit suffixes, so:

/model lmstudio/qwen3.6-27b@iq3_xxs

was parsed as model="lmstudio/qwen3.6-27b" + profile="iq3_xxs", producing GatewayRequestError: model not allowed: lmstudio/qwen3.6-27b and (when it didn't fail) sending the truncated id to LM Studio, which then picked an arbitrary quant.

Fix

Extend the protected quant pattern to allow an optional i prefix:

- /^(?:q\d+(?:_[a-z0-9]+)*|\d+bit)(?:@|$)/i
+ /^(?:(?:i?q)\d+(?:_[a-z0-9]+)*|\d+bit)(?:@|$)/i

This keeps @iq3_xxs, @iq4_xs, etc. as part of the model id while still allowing an explicit auth profile via a second @ suffix (e.g. lmstudio/foo@iq3_xxs@work).

Tests

Added regression cases in:

  • src/agents/model-ref-profile.test.ts
  • src/agents/model-selection.test.ts
  • src/auto-reply/model.test.ts

Verified the splitter against representative inputs:

input model profile
lmstudio/qwen3.6-27b@iq3_xxs lmstudio/qwen3.6-27b@iq3_xxs —
lmstudio-mb-pro/gemma-4-31b-it@q8_0 …@q8_0 —
lmstudio/qwen3.6-27b@iq3_xxs@work …@iq3_xxs work
openai/gpt-5@work openai/gpt-5 work
openai/@cf/openai/gpt-oss-20b@cf:default openai/@cf/openai/gpt-oss-20b cf:default

LM Studio names quant variants like 'qwen3.6-27b@iq3_xxs' (imatrix
quants prefixed with 'i'). splitTrailingAuthProfile only protected
@q*/<n>bit suffixes, so '/model lmstudio/qwen3.6-27b@iq3_xxs' was
parsed as model='lmstudio/qwen3.6-27b' + profile='iq3_xxs', causing
'model not allowed' and sending a truncated model id to LM Studio
(which then picked an arbitrary quant).

Extend the protected pattern to match optional 'i' prefix
(i?q\d+...), preserving '@iq3_xxs', '@iq4_xs', etc. while still
allowing an explicit auth profile via a second @ suffix
(e.g. lmstudio/foo@iq3_xxs@work).

Fixes openclaw#71474
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 25, 2026
@greptile-apps

greptile-apps Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends splitTrailingAuthProfile in src/agents/model-ref-profile.ts to recognise LM Studio's imatrix-quantised model naming convention (@iq3_xxs, @iq4_xs, etc.) as part of the model id rather than an auth-profile delimiter, mirroring the existing @q* / \d+bit special-casing. The one-character regex change (i?q) is minimal and correct, and the accompanying regression tests in three test files give good coverage of the happy path and the compound @iq*@profile form.

Confidence Score: 5/5

Safe to merge — a small, targeted regex fix with solid regression test coverage and no risk of breaking existing behaviour.

The change is a single-character regex extension that only broadens the set of strings recognised as quant suffixes; existing @q* and \d+bit paths are unchanged. The three test files cover the new cases directly and the fix matches the described failure mode exactly.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(agents): preserve LM Studio @iq* qua..." | Re-trigger Greptile

@steipete

Copy link
Copy Markdown
Contributor

Codex maintainer review: valid bug and the high-level tests here are useful, but the patch is incomplete for #71474 as written.

It fixes /model parsing through splitTrailingAuthProfile(), but current main also has a separate provider/runtime path in src/plugins/providers.ts:

function stripModelProfileSuffix(value: string): string {
  const trimmed = value.trim();
  const at = trimmed.indexOf("@");
  return at <= 0 ? trimmed : trimmed.slice(0, at).trim();
}

That still truncates qwen3.6-27b@iq3_xxs to qwen3.6-27b, matching the second symptom in #71474 where LM Studio receives the truncated model id / chooses the wrong quant.

Best fix is to combine this PR's resolveModelRefFromString + /model tests with #71486's src/plugins/providers.ts change, so both user-facing paths are covered.

@steipete

Copy link
Copy Markdown
Contributor

Codex maintainer update: closing this as a duplicate/incomplete variant of the #71474 fix.

The bug is real, but this PR only fixes the parser and high-level /model path. It does not cover the provider/runtime truncation still present on current main in src/plugins/providers.ts, where stripModelProfileSuffix() cuts at the first @.

#71486 is the better canonical base because it fixes both the shared parser and src/plugins/providers.ts. The useful part to carry over from this PR is the higher-level test coverage for resolveModelRefFromString() and /model ...@iq3_xxs[@profile].

Thanks @Sanjays2402 for the strong test shape; I left the specific porting request on #71486.

@steipete steipete closed this Apr 25, 2026
Sanjays2402 added a commit to Sanjays2402/openclaw that referenced this pull request Apr 25, 2026
…ting

Address Codex maintainer review on openclaw#71490: `splitTrailingAuthProfile`
already preserves `@iq*` / `@q*` quant suffixes in /model parsing, but
the provider/runtime routing path in `src/plugins/providers.ts` had its
own naive `stripModelProfileSuffix` that still truncated
`qwen3.6-27b@iq3_xxs` → `qwen3.6-27b`. That sent the wrong (or no) model
id to LM Studio, matching the second symptom in openclaw#71474.

Reuse `splitTrailingAuthProfile` from the canonical splitter so both
user-facing paths honor the same protected-suffix rules. Export the two
helpers via `__testing` and add 12 dedicated regression tests covering:

- bare model ids
- provider/model
- @Profile stripping
- @q* and @iq* quant preservation (regression for openclaw#71474)
- @<n>bit quant preservation
- profile-after-quant (`...@iq3_xxs@work`)
@Sanjays2402

Copy link
Copy Markdown
Contributor Author

Good catch — fixed in c84c4c3.

Rather than duplicate the protected-suffix regex, I had stripModelProfileSuffix in src/plugins/providers.ts reuse splitTrailingAuthProfile from src/agents/model-ref-profile.ts. That way both user-facing paths (/model parsing and provider/runtime routing) honor the exact same rules — single source of truth, no drift if someone adds e.g. @gguf-q5_k_m later.

Also exported splitExplicitModelRef + stripModelProfileSuffix via __testing and added src/plugins/providers-model-ref.test.ts with 12 regression cases:

All 192 tests across model-ref-profile, model-selection, auto-reply/model, providers, and the new file pass. oxlint clean.

@Sanjays2402

Copy link
Copy Markdown
Contributor Author

Acknowledged — closing on my side too. Posted the higher-level test patch onto #71486 (here) so the maintainer's requested coverage lands with @Bartok9's canonical fix. Thanks for the clear triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect handling on LM Studio model names with "@‘

2 participants