fix(provider): preserve config precedence after model hooks#30211
Open
shlroland wants to merge 4 commits into
Open
fix(provider): preserve config precedence after model hooks#30211shlroland wants to merge 4 commits into
shlroland wants to merge 4 commits into
Conversation
6bceb6a to
f39864e
Compare
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.
Issue for this PR
Closes #25630
Type of change
What does this PR do?
After PR #25167, the plugin
provider.models()hook runs before config providers are merged into theprovidersmap. This means the hook looks updatabase[providerID]which only contains providers from the models.dev catalog. Custom providers declared inopencode.jsonthat aren't in the catalog are skipped entirely.This PR fixes the regression by:
Extracting config application into a reusable
applyConfig()function — the inline config-to-database merge is now a function that can operate on anyRecord<string, Info>target.Running plugin model hooks on
providersafter env/auth/custom loaders — this ensures custom providers from user config are present in theprovidersmap when hooks execute.Calling
applyConfig(providers)after hooks — this restores the intended precedence: user config overrides hook-supplied models, while still allowing hooks to add new models to custom providers.How did you verify your code works?
Added a test
"provider hook runs for config-only providers and preserves config model overrides"that:All existing provider tests pass
Typecheck passes
Checklist