Repository navigation
fix(lmstudio): avoid fresh-session overflow after slow model loads - #168044
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR extends LM Studio loading deadlines and reports failed context-capacity upgrades instead of sending inference to a known undersized instance. Example: Gemma 4 E4B requests 49152 context tokens while loaded instances provide 8192 and 32768 tokens.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it repairs a concrete LM Studio inference failure still present on current main, with supplied Gateway behavior proof and no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe LM Studio plugin prepares model capacity before OpenAI-compatible inference; core projects structured loading failures into live replies and saved chat history. flowchart TD
A[Gateway chat request] --> B[LM Studio preload wrapper]
B --> C[Native model discovery and loading]
C --> D[Prepared inference instance]
D --> E[Chat completion]
C --> F[Structured capacity failure]
F --> G[Live reply and history renderer]
Technical reviewBest possible solution: Land the plugin-owned capacity repair with shared safe loading guidance and existing model identities and configuration intact. Do we have a high-confidence way to reproduce the issue? Yes: the supplied delayed-load replay matches current main's 30-second deadline and fallback path; this review inspected source and supplied evidence without executing target code. Is this the best way to solve the issue? The repair addresses the loading owner, preserves unknown-capacity fallback and canonical routing, and gives live replies and history one safe renderer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ac1a8028b31. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +38, Tests +119, Docs +6, Other -3. Total +160 across 10 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 9, 2026, 10:04 PM ET / October 10, 2026, 02:04 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#168044) * fix(lmstudio): preserve context capacity when model loading fails * test(lmstudio): collect preload events within supported TypeScript lib * fix(agents): render structured model-loading failure guidance
…168044) (extracted hotfix) Extracted from #168044 (41cd441): took only the default preload timeout in extensions/lmstudio/src/models.fetch.ts (30s -> 120s). The branch's stream preload never passes a timeout, so slow LM Studio model loads hit the 30s default, fall back to a too-small context instance, and fresh sessions overflow. Left out the LmstudioModelLoadError class, the stream.ts rework that threads configured request/provider timeouts into preload, the failover copy in src/agents, docs, and baseline updates: they are a larger behavior and error-surface change beyond the approved one-line fix. Extracted-from: 41cd441 Co-authored-by: Peter Steinberger <[email protected]>
Release provenance: 89329f6 -> #168587 Release provenance: e6a9022 -> #168905 Release provenance: 15f3f12 -> #162266 Release provenance: 20805b8 -> #169430 Release provenance: 568fec8 -> #169102 Release provenance: 39dba6d -> #160440 Release provenance: 5df28c7 -> #168393 Release provenance: 10bcd8e -> #168164 Release provenance: dc5f1f5 -> #168446 Release provenance: 9f1e441 -> #168044 Release provenance: 5a235fc -> #168651
What Problem This Solves
Fixes fresh LM Studio sessions failing with context overflow after a slow preload falls back to a loaded instance that is too small. Related: #141357.
User Impact
OpenClaw waits for cold loads using the existing provider/request timeout or a two-minute default. Failed capacity upgrades stop inference and show the model, requested context, and loading/retry guidance in both the live error and saved history. Existing configuration is preserved; no new configuration or migration is required.
Why This Change Was Made
The LM Studio plugin previously used a 30-second native-load deadline and discarded failed capacity upgrades. It now retains that failure through backoff and failed rediscovery until preparation succeeds. Unknown-capacity discovery failures keep their best-effort fallback. Shared load cancellation and canonical conversation identity are preserved.
The plugin owns loading decisions. Core renders a generic loading-failure code and validated context count through the existing error envelope, with a redacted, bounded, escaped model label. It creates fixed guidance rather than exposing provider diagnostics; no SDK field, trusted-text hook, or retry policy was added.
Evidence
Real LM Studio, Gemma 4 E4B, isolated Gateway on port 19247, proxy on 19248 forwarding to LM Studio on 1234. Configured
contextTokens: 49152, with canonical 8192-token and named 32768-token instances. Replay uses the production Gateway client and freshchat.sendsessions, then readschat.history./api/v1/models/loadby 35 seconds. Main aborted loading at 30 seconds, sent inference to the canonical 8K ID, and returned the misleading overflow/reset error in 50.221 seconds.google/gemma-4-e4b:2, and real Gemma repliedPRELOAD_OK.through the Gateway in 72.664 seconds.agents-othercore test graph, targeted core/plugin lint, formatting, and all required baseline ratchets pass. Config-doc and plugin-inventory checks pass. Final runtime-onlypnpm buildpassed in 2m08s; full default declaration build was not run, but SDK boundary declarations completed for lint. The first declaration preparation hit its five-minute tool deadline; the supported longer compiler budget completed it.openclaw/ci-gate. Changed Node shards took 58–228 seconds; the changed extension-config shard took 73 seconds; baseline ratchets took 94 seconds.2d1bd18f3c886457e4808362d7104314b2c2b117.Commands and change size
Gateway:
pnpm openclaw --profile lmstudio-fixes gateway run --port 19247 --bind loopback --auth none, with task-ownedOPENCLAW_STATE_DIRandOPENCLAW_CONFIG_PATH.chat.sendprompt:/think off\nReply exactly PRELOAD_OK. Do not use tools.No external channel sends.Production +130/-92, net +38. Plugin loading/backoff code is LOC neutral after removing redundant error and abort wrappers. The net growth supplies one shared safe renderer for live and saved errors; trimming it further would remove required fact validation or sanitization. Tests +140/-21, net +119; docs +6; ratchet baselines -3 obsolete entries. No model-facing prompt/tool text changes.
The generic fresh-session
/resetoverflow copy remains a separate follow-up: multiple renderers lack session-freshness facts. This fix keeps capacity-loading failures out of that overflow path.