Fix custom no-auth model providers / 修复自定义免密模型接入#4685
Merged
SivanCola merged 1 commit intoJun 17, 2026
Conversation
This was referenced Jun 17, 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
Fixes #4612.
Custom OpenAI-compatible providers could disappear from the desktop model switcher when they were configured as local/no-auth gateways. A common Settings path made this worse by auto-populating an
api_key_envname even when the user did not save a key, so the provider looked keyless to the backend and the chat dropdown filtered out every model.This also made
/modelsdiscovery unusable for no-auth local gateways, because the fetch path required a key before attempting the request.Root Cause
ProviderEntry.Configured()treated every provider as unavailable unlessapi_key_envresolved to a non-empty value. That was correct for official hosted providers, but too strict for local or private OpenAI-compatible gateways that intentionally do not require authentication.The frontend provider editor also used the generated env-var placeholder as a saved value. For a custom provider with manually entered models and no key, saving through Settings persisted an env var such as
LOCAL_API_KEYwithout a credential, which made the backend hide the provider on reload.Fix
api_key_envis blank.api_key_envfor custom providers unless the user actually supplies a key or an explicit env var./modelsdiscovery and omit emptyAuthorizationheaders for model fetches and chat requests.context_window/price metadata, no-auth providers, loopback providers with missing key envs, and Settings key-env persistence.Cache impact
None. This changes provider availability, credential handling, and request headers only when no API key is configured. It does not change prompts, tool schemas, model request bodies, compaction content, or cache-sensitive prefixes.
Verification
go test ./internal/config -run 'TestProviderConfigured|TestValidateAllowsNoAuthProvider|TestProviderFetchModels' -count=1cd desktop && go test ./... -run 'TestModelsForTabLists(CustomMultiModelProviderWithoutMetadata|KeylessCustomMultiModelProvider|LoopbackCustomProviderWithMissingKeyEnv)' -count=1cd desktop/frontend && corepack pnpm exec tsx src/__tests__/provider-model-refresh.test.tsgo test ./...cd desktop && go test ./...cd desktop/frontend && corepack pnpm run test:allcd desktop/frontend && corepack pnpm run buildgo vet ./...cd desktop && go vet ./...gofmt -l .git diff --check