fix: tolerate unknown LM Studio reasoning levels - #48
Open
dgnsrekt wants to merge 1 commit into
Open
Conversation
`capabilities.reasoning` pinned `allowed_options` and `default` to `off|on|low|medium|high`. LM Studio now publishes an `xhigh` level, and because the enum sits inside the response schema a single model carrying it fails `LMStudioModelsResponseSchema.safeParse` for the entire payload. `discoverModels` then throws `unsupported response`, so discovery yields no models at all and the provider falls back to models.dev entries the user has not downloaded. The reasoning block is parsed but never mapped: the v1 contract leaves OpenCode's `reasoning` flag unset until both projects publish an interoperable mapping. Validating these values strictly gains nothing and costs total discovery whenever LM Studio adds a level. Accept any string and keep the known levels as an exported constant for documentation, so a future level cannot break discovery the same way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7Wjrr4wy4Eiig1PqtHfpD
This was referenced Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
rc.2discovers no models at all against current LM Studio builds.LMStudioCapabilitiesSchemapins reasoning values tooff|on|low|medium|high. LM Studio now publishes anxhighlevel:Because the enum sits inside
LMStudioModelsResponseSchema, one model carryingxhighfailssafeParsefor the whole payload:discoverModelsthrowsunsupported response, so the config hook logsLM Studio model discovery unavailableand contributes nothing. The provider then falls back to models.dev's built-inlmstudiocatalog, offering models the user has never downloaded.On my instance 2 of 37 records report
xhigh, and discovery returned 0 models.Fix
Accept any string for
allowed_optionsanddefault.This block is parsed but never mapped — per the v1 contract, OpenCode's
reasoningflag is deliberately left unset "until the two projects publish an interoperable mapping." Validating the values strictly gains nothing today and costs total discovery every time LM Studio adds a level. The known levels stay as an exportedKNOWN_REASONING_LEVELSconstant for documentation.I went with permissive rather than adding
xhighto the enum so the next new level can't reproduce this.Verification
Regression test added — it fails on
mainwithLMStudioAPIError: LM Studio models API returned an unsupported responseand passes with the fix.npm run validateclean (lint, typecheck, 28 tests, build).End-to-end against LM Studio 0.4.x with 37 records, via
opencode models lmstudio:Notes
Related to #34. This is a prerequisite for a follow-up PR I'd like to send adding an opt-in
onlyLoadedoption (#17) — that one can't be exercised at all until discovery works.🤖 Generated with Claude Code
https://claude.ai/code/session_01S7Wjrr4wy4Eiig1PqtHfpD