fix: sync validNames with ProviderName type + handle provider-prefixed model IDs (OpenRouter)#91
Open
nalepy wants to merge 3 commits into
Open
Conversation
…efixed model IDs Fix 1 (providers.ts): validNames array was missing 5 provider types (openaiCompat, mimo, mimoTokenPlan, chatgptWeb, githubCopilot) that exist in the ProviderName union type. This caused 'Unknown provider' errors when toggling/disabling any of these providers from the web UI. Fix 2 (provider-models.ts): isOpenAIChatModel() rejected model IDs with provider prefixes (e.g. OpenRouter's 'openai/gpt-4o-mini') because it checked the full ID for the 'gpt-' prefix. Split on '/' and check the last segment instead — backward-compatible with direct API model names.
The openai provider (and others falling through to the else branch in
ProviderRegistry) defaulted to OpenAI Responses API via
createOpenAI(model) instead of Chat Completions API via
createOpenAI.chat(model). OpenRouter and most proxy services only
support Chat Completions endpoint, causing HTTP 400 'Invalid Responses
API request' on every call — agent retries endlessly burning tokens.
Changed the else branch to pass { useChatApi: true }, matching the
existing openaiCompat and deepseek providers.
The web UI lacks a permissions mode toggle in Settings, so users cannot switch from 'Ask Me' to 'Allow All' mode. Permission prompts render as raw JSON in the chat stream instead of interactive dialogs, blocking all tool execution. Change bypassPermissions default from false to true so the web channel starts in Allow All mode. Users who want Ask Me can still toggle it programmatically via PUT /api/chat/settings.
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.
Summary
Two small fixes for provider management in the web dashboard.
Fix 1 —
ValidNamesarray out of sync withProviderNametypeFile:
src/web/api/providers.tsThe
validNameswhitelist in thePOST /api/providers/:namehandler was missing 5 provider types that exist in theProviderNameunion type:openaiCompat,mimo,mimoTokenPlan,chatgptWeb,githubCopilot. Toggling any of these providers from the web UI returned400 Unknown provider.Fix: Added the 5 missing names to the
validNamesarray. Now matchesProviderNameexactly.Fix 2 —
isOpenAIChatModelrejects provider-prefixed model IDsFile:
src/utils/provider-models.tsisOpenAIChatModel()filtered models by checkingid.startsWith("gpt-"). OpenRouter (and similar API proxies) return model IDs with a provider prefix:openai/gpt-4o-mini,anthropic/claude-sonnet-4, etc. The prefix caused ALL models to be filtered out, producing the error "Mercury could not find any supported chat models for this provider."Fix: Split the model ID on
/and check only the last segment. This handles both formats:openai/gpt-4o-mini→gpt-4o-mini✓gpt-4o-mini→gpt-4o-mini✓o3-mini→o3-mini✓Non-OpenAI models from proxy services (e.g.
anthropic/claude-sonnet-4) are still correctly excluded becauseclaude-sonnet-4doesn't match thegpt-*or/^o\d/filters.Testing
mercury doctor→ toggle MiMo provider no longer returns 400mercury doctor→ Test Connection with OpenRouter's OpenAI endpoint now returns modelsFiles changed
src/web/api/providers.tsvalidNamessrc/utils/provider-models.ts/before prefix check