Skip to content

fix(lmstudio): honor embedding JIT and canonical model identity - #117320

Merged
vincentkoc merged 2 commits into
mainfrom
codex/qa400-lmstudio-jit-canonical-identity
Aug 3, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
codex/qa400-lmstudio-jit-canonical-identity

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where LM Studio memory embeddings ignored
models.providers.<provider>.params.preload: false, eagerly loaded a model during provider
creation, and sent unusable @variant identifiers to LM Studio when JIT loading was enabled.

Why This Change Was Made

Embedding setup now follows the provider-owned preload policy already used by chat. Canonical model
IDs skip native discovery and loading entirely when preload is disabled. Variant IDs perform only a
catalog lookup so provider, cache, and wire identity are stable before memory snapshots them; the
actual model load remains owned by LM Studio JIT on the first embedding request.

Preload-enabled setups still warm the model and retain the canonical ID returned by native
discovery, including when the subsequent load fails.

User Impact

Operators can use LM Studio JIT, idle TTL, and auto-eviction for memory embeddings without OpenClaw
eagerly loading weights. Quantized variant configurations now use the canonical LM Studio wire ID
while keeping provider and memory-cache identity consistent. Configured local-service leases remain
balanced for discovery, warmup, and embedding requests.

Evidence

  • Exact repaired head: 7c3f8b0a286f4f; rebased onto a67c52611e5768.
  • Focused owner suite:
    node scripts/run-vitest.mjs extensions/lmstudio/src/embedding-provider.test.ts - 17 passed.
  • Sibling model/stream suites:
    node scripts/run-vitest.mjs extensions/lmstudio/src/models.test.ts extensions/lmstudio/src/stream.test.ts
    • 73 passed.
  • Formatting and patch checks:
    oxfmt --check extensions/lmstudio/src/embedding-provider.ts extensions/lmstudio/src/embedding-provider.test.ts
    and git diff --check passed.
  • Extension test type lane reached one unrelated current-main error only:
    packages/terminal-core/src/ansi.ts(194,38): TS2554; all LM Studio branch type errors found during
    repair were corrected.
  • TruffleHog scan of the committed branch diff was clean. The structured reviewer service did not
    return a verdict within its 32-minute window, so this is recorded as unavailable rather than
    passed.

Live LM Studio proof

Tested against LM Studio 0.4.20+1 with no Ollama model loaded.

GET /api/v1/models
key:              google/gemma-4-e4b
variant:          google/gemma-4-e4b@4bit
loaded_instances: []

POST /api/v1/models/load {"model":"google/gemma-4-e4b@4bit","context_length":512}
error.type:    model_not_found
error.message: Model google/gemma-4-e4b@4bit not found in downloaded models

lms ps
[]

This proves LM Studio advertises the variant but requires its canonical key on the native load
route. The preload-disabled variant regression verifies that OpenClaw performs catalog discovery
without calling the native load helper, freezes the canonical provider/cache identity, and sends
that same canonical ID through the embedding transport.

LM Studio JIT was also exercised from a fully unloaded state:

before request: no models loaded
POST /v1/embeddings model=text-embedding-nomic-embed-text-v1.5
response.model: text-embedding-nomic-embed-text-v1.5
dimensions:     768
error:          null
after request:  text-embedding-nomic-embed-text-v1.5, 84.11 MB, IDLE
cleanup:        LM Studio server OFF; Ollama loaded models []

Hosted exact-head CI is required before merge.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 2:20 PM ET / 18:20 UTC.

ClawSweeper review

What this changes

The PR updates LM Studio memory embeddings so disabled preload avoids eager native loading while variant model identifiers resolve to a stable canonical key before JIT embedding calls.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this PR open for the explicit maintainer decision required by its protected maintainer label. The prior canonical-identity blocker is addressed on the current head: the LM Studio plugin now skips native warmup when preload is disabled, resolves JIT variant aliases through the existing catalog path, and uses the resulting key for embedding transport and memory identity; exact-head CI is still running.

Priority: P2
Reviewed head: 7c3f8b0a286f4f6b29684dfa1ced3a63fea6a28b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) This is a focused provider repair with targeted regression coverage and credible real-service terminal proof; exact-head CI completion and protected-label review remain before merge.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body includes redacted terminal output from a real unloaded LM Studio instance showing the variant/native-load distinction and a successful JIT embedding request with the canonical key; this directly supports the repaired behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes redacted terminal output from a real unloaded LM Studio instance showing the variant/native-load distinction and a successful JIT embedding request with the canonical key; this directly supports the repaired behavior.
Evidence reviewed 6 items Current-main failure path: Current main always acquires a local-service lease and calls the native LM Studio load helper while creating an embedding provider, irrespective of params.preload; it also leaves the embedding client on the requested model string.
Current-head owner-boundary repair: The PR applies the existing provider-owned preload policy to embeddings. When preload is disabled, an @ variant performs catalog-only canonical-key resolution, while the actual model load remains deferred to LM Studio’s embedding endpoint.
Transport contract: The shared remote embedding provider serializes client.model directly as the model field in each embedding request, so resolving the client before provider creation also fixes the wire identifier.
Findings None None.
Security None None.

How this fits together

The LM Studio plugin converts OpenClaw provider configuration into an OpenAI-compatible local embedding client for Memory Core. It may acquire a configured local-service lease, discover LM Studio’s model catalog, optionally warm the model, then passes the chosen model key into embedding requests and memory cache identity.

flowchart LR
  Config[LM Studio provider config] --> Provider[Embedding provider]
  Provider --> Policy[Preload policy]
  Catalog[LM Studio model catalog] --> Identity[Canonical model key]
  Policy --> Identity
  Identity --> Client[Embedding client]
  Client --> Memory[Memory embeddings and cache]
Loading

Decision needed

Question Recommendation
Should this protected LM Studio compatibility change merge once the current-head CI lanes complete successfully and maintainers accept canonical-key cache identity for existing variant configurations? Merge after exact-head checks: Accept the focused plugin repair once the remaining current-head CI lanes are green and the canonical cache-identity upgrade behavior is approved.

Why: The patch is a focused repair with sufficient proof, but the protected maintainer label and intentional upgrade-visible identity change require explicit maintainer acceptance.

Before merge

  • Resolve merge risk (P1) - The source branch is behind current main while GitHub reports it cleanly mergeable; retain the exact-head CI result and a merge/review refresh rather than treating base drift as a code regression.
  • Resolve merge risk (P1) - Existing LM Studio embedding configurations using variant identifiers will intentionally move from the variant string to the canonical model key for provider and cache identity; maintainers should explicitly accept that upgrade behavior.
  • Resolve merge risk (P1) - Official LM Studio documentation could not be reached from this read-only environment, so the external API contract is supported here by the recorded live LM Studio output plus the existing catalog/load implementation rather than an independently fetched upstream document.
  • Complete next step (P2) - No mechanical repair remains; the protected compatibility change needs maintainer acceptance after the remaining exact-head CI lanes finish.
Agent review details

Security

None.

PR surface

Source +53, Tests +172. Total +225 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 67 14 +53
Tests 1 178 6 +172
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 245 20 +225

Review metrics

Metric Value Why it matters
Production versus test delta production +67/-14, tests +178/-6 The production growth is justified by a new owner-boundary branch for preload policy and canonical identity, with materially larger targeted regression coverage.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/lmstudio/src/embedding-provider.test.ts, unknown-data-model-change: extensions/lmstudio/src/embedding-provider.ts, vector/embedding metadata: extensions/lmstudio/src/embedding-provider.test.ts, vector/embedding metadata: extensions/lmstudio/src/embedding-provider.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Merge after exact-head checks (recommended)
    Keep the focused canonical-key regression coverage and merge when the remaining exact-head CI lanes pass.
  2. Pause for upgrade proof
    Request a maintainer-reviewed existing-configuration upgrade run if cache identity migration needs stronger operational evidence.

Technical review

Best possible solution:

Retain the plugin-local repair, merge after exact-head CI and a maintainer compatibility check, and preserve the canonical key as the single identity used by preload-enabled warmup, preload-disabled JIT requests, and memory caching.

Do we have a high-confidence way to reproduce the issue?

Yes: current main unconditionally invokes LM Studio native warmup during embedding-provider creation, while the current-head tests directly exercise params.preload: false, variant discovery, canonical provider/cache identity, and the resulting embedding transport model.

Is this the best way to solve the issue?

Yes: this is the best fix because vendor-specific catalog and model-key semantics remain in the LM Studio plugin, reuse existing catalog and canonical-key helpers, and avoid adding a new core configuration or compatibility layer.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted terminal output from a real unloaded LM Studio instance showing the variant/native-load distinction and a successful JIT embedding request with the canonical key; this directly supports the repaired behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded local-provider embedding workflow with limited blast radius rather than an emergency availability, security, or data-loss issue.
  • merge-risk: 🚨 compatibility: Merging changes the model identifier and preload behavior used by existing LM Studio embedding configurations and their cache identity.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Sufficient (terminal): The PR body includes redacted terminal output from a real unloaded LM Studio instance showing the variant/native-load distinction and a successful JIT embedding request with the canonical key; this directly supports the repaired behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted terminal output from a real unloaded LM Studio instance showing the variant/native-load distinction and a successful JIT embedding request with the canonical key; this directly supports the repaired behavior.

Evidence

What I checked:

  • Current-main failure path: Current main always acquires a local-service lease and calls the native LM Studio load helper while creating an embedding provider, irrespective of params.preload; it also leaves the embedding client on the requested model string. (extensions/lmstudio/src/embedding-provider.ts:244, 21a767639fa0)
  • Current-head owner-boundary repair: The PR applies the existing provider-owned preload policy to embeddings. When preload is disabled, an @ variant performs catalog-only canonical-key resolution, while the actual model load remains deferred to LM Studio’s embedding endpoint. (extensions/lmstudio/src/embedding-provider.ts:267, 7c3f8b0a286f)
  • Transport contract: The shared remote embedding provider serializes client.model directly as the model field in each embedding request, so resolving the client before provider creation also fixes the wire identifier. (packages/memory-host-sdk/src/host/embeddings-remote-provider.ts:41, 21a767639fa0)
  • Regression coverage: The added JIT-variant case verifies no native load occurs, catalog discovery runs under a local-service lease, provider and cache identities use the canonical key, and the subsequent embedding transport uses that same key. (extensions/lmstudio/src/embedding-provider.test.ts:203, 7c3f8b0a286f)
  • Feature history: Current history shows an earlier LM Studio canonical-variant repair and subsequent embedding local-service work, supporting a plugin-local canonical-key repair rather than a new core seam. (extensions/lmstudio/src/models.ts:273, 405896a4a31b)
  • Real behavior proof: The PR body supplies redacted LM Studio terminal output from an unloaded state: a variant fails on the native load route, while a JIT /v1/embeddings request using the canonical key succeeds and leaves the model idle afterward. The supplied checks also show the real-behavior-proof workflow succeeded; hosted exact-head CI remains in progress. (7c3f8b0a286f)

Likely related people:

  • steipete: Current-main history contains repeated LM Studio model, onboarding, and provider maintenance by Peter Steinberger, including adjacent model-catalog work. (role: recent area contributor; confidence: high; commits: b6c3ff1aa1a2, 6ef6c9a15d88; files: extensions/lmstudio/src/models.ts, extensions/lmstudio/src/embedding-provider.ts)
  • vincentkoc: Current-main history attributes the embedding local-service lease and alias-credential path to Vincent Koc, directly adjacent to the changed provider initialization. (role: recent area contributor; confidence: high; commits: 1aca83abf53f; files: extensions/lmstudio/src/embedding-provider.ts)
  • Ted Li: Feature history attributes the canonical LM Studio variant-key repair to Ted Li, the helper this PR reuses for the embedding path. (role: feature contributor; confidence: medium; commits: 405896a4a31b; files: extensions/lmstudio/src/models.ts, extensions/lmstudio/src/models.fetch.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the in-progress exact-head CI lanes and complete the protected maintainer compatibility decision.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-01T09:23:33.748Z sha 0fdf7b0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-02T15:16:08.398Z sha 0fdf7b0 :: needs real behavior proof before merge. :: [P1] Resolve canonical identity on the JIT embedding request
  • reviewed 2026-08-02T15:23:43.812Z sha 0fdf7b0 :: needs real behavior proof before merge. :: [P1] Resolve the canonical key on the JIT embedding request
  • reviewed 2026-08-03T10:38:38.002Z sha 0fdf7b0 :: needs real behavior proof before merge. :: [P1] Resolve canonical identity when preload is disabled

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 2, 2026
@vincentkoc vincentkoc self-assigned this Aug 3, 2026
@vincentkoc
vincentkoc force-pushed the codex/qa400-lmstudio-jit-canonical-identity branch from 0fdf7b0 to 7c3f8b0 Compare August 3, 2026 18:12
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Repaired head 7c3f8b0a286f4f resolves the preload-disabled variant path and the PR body now contains redacted live LM Studio proof plus focused test evidence.

@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member

Maintainer decision: accepted.

The canonical-key cache identity change is intentional: LM Studio variant identifiers are request selections, while the resolved canonical model key is the stable provider, wire, and cache identity. This avoids cache fragmentation and keeps preload-enabled and JIT paths consistent.

Exact repaired head 7c3f8b0a286f4f6b29684dfa1ced3a63fea6a28b has completed all hosted checks with no failures. ClawSweeper reports no findings and sufficient real-service proof. Merging with a merge commit to preserve the two-commit author history.

@vincentkoc

Copy link
Copy Markdown
Member

GitHub's merge API rejected merge because merge commits are disabled for this repository. Squash is intentionally not being used, and GitHub rebase would rewrite the commit objects.

I am direct-landing a normal merge commit onto main instead. This preserves Peter's original commit and Vincent's repair commit exactly, and the PR remains the canonical review/proof record.

@vincentkoc
vincentkoc merged commit 137462a into main Aug 3, 2026
93 of 96 checks passed
@vincentkoc
vincentkoc deleted the codex/qa400-lmstudio-jit-canonical-identity branch August 3, 2026 18:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
…claw#117320)

* codex/qa400-lmstudio-jit-canonical-identity:
  fix(lmstudio): resolve JIT embedding variants
  fix(lmstudio): preserve embedding preload and model identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: lmstudio maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants