fix: openrouter in providers and modellist length is greater than 0#766
Open
penzhan8451 wants to merge 1 commit intosipeed:mainfrom
Open
fix: openrouter in providers and modellist length is greater than 0#766penzhan8451 wants to merge 1 commit intosipeed:mainfrom
penzhan8451 wants to merge 1 commit intosipeed:mainfrom
Conversation
penzhan8451
commented
Feb 25, 2026
Author
penzhan8451
left a comment
There was a problem hiding this comment.
In the case of openrouter is in providers and modellist is not empty && modellist does not contain openrouter config, an error will be returned and the process will quit.
yumosx
reviewed
Feb 25, 2026
Comment on lines
+26
to
+35
| providerModels := config.ConvertProvidersToModelList(cfg) | ||
| existingModelNames := make(map[string]bool) | ||
| for _, m := range cfg.ModelList { | ||
| existingModelNames[m.ModelName] = true | ||
| } | ||
| for _, pm := range providerModels { | ||
| if !existingModelNames[pm.ModelName] { | ||
| cfg.ModelList = append(cfg.ModelList, pm) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| providerModels := config.ConvertProvidersToModelList(cfg) | |
| existingModelNames := make(map[string]bool) | |
| for _, m := range cfg.ModelList { | |
| existingModelNames[m.ModelName] = true | |
| } | |
| for _, pm := range providerModels { | |
| if !existingModelNames[pm.ModelName] { | |
| cfg.ModelList = append(cfg.ModelList, pm) | |
| } | |
| } | |
| providerModels := config.ConvertProvidersToModelList(cfg) | |
| existing := make(map[string]struct{}, len(cfg.ModelList)+len(providerModels)) | |
| for _, m := range cfg.ModelList { | |
| existing[m.ModelName] = struct{}{} | |
| } | |
| var toAdd []Model | |
| for _, pm := range providerModels { | |
| if _, ok := existing[pm.ModelName]; !ok { | |
| toAdd = append(toAdd, pm) | |
| existing[pm.ModelName] = struct{}{} | |
| } | |
| } | |
| cfg.ModelList = append(cfg.ModelList, toAdd...) |
nikolasdehor
approved these changes
Feb 25, 2026
nikolasdehor
left a comment
There was a problem hiding this comment.
Good bug fix. The problem is clear: when a user has both model_list entries and providers config, the old code skipped ConvertProvidersToModelList entirely if model_list was non-empty, meaning provider-sourced models (like OpenRouter) were silently dropped.
The fix correctly merges by deduplicating on ModelName. One edge case worth noting:
- Name collision with different config: If a model in
model_listand a provider have the sameModelNamebut different API keys or base URLs, the explicitmodel_listentry wins (it is kept, the provider entry is skipped). This seems like the right precedence but may be worth documenting.
Otherwise clean and minimal. LGTM.
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.
📝 Description
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
Reference URL:
Reasoning:
/////////////
when user setup both:
this will skip providers configuration,and will return with err
/////////////
🧪 Test Environment
📸 Evidence (Optional)
Details
when user setup both:
this will skip providers configuration,and will return with err
Click to view Logs/Screenshots
☑️ Checklist