Repository navigation
fix: merge provider routing options in chat and completion models - #628
Open
mattapperson wants to merge 3 commits into
Open
mattapperson wants to merge 3 commits into
mattapperson wants to merge 3 commits into
Conversation
5 tasks done
…models - mergeProviderRouting(configured, runtime): runtime null clears routing, plain-object check via prototype, nested values documented as replaced - chat/completion/image always set provider to the merged result so non-object extraBody/settings provider values never leak - embedding uses the shared helper instead of its local copy - tests for null-clears and no-leak in chat, completion, embedding, image; drop 'as never' casts in favor of SharedV4ProviderOptions - changeset and README document shallow-merge semantics and the image/ embedding null behavior change
mattapperson
force-pushed
the
claude/merge-provider-routing
branch
from
November 4, 2026 14:40
d492ff7 to
3452d33
Compare
christineschen
approved these changes
Nov 4, 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.
Description
Fixes #587
The chat model built the request body as
{ ...this.getArgs(options), ...restOpenrouterOptions }, so a call-timeproviderOptions.openrouter.providerreplaced the configuredsettings.provider/extraBody.provideroutright. Configured keys such asallow_fallbacksandsortwere dropped. The completion model had the same problem withextraBody.provider.Changes:
src/utils/merge-provider-routing.ts,mergeProviderRouting(configured, runtime):Object.prototypeornull), later sources winning; nested arrays/objects (order,only,ignore,max_price) are replaced, not mergedundefined,null, arrays, primitives, class instances)provider: nullclears routing entirely (returnsundefined), keeping the escape hatch that existed on main for chat/completionundefinedwhen nothing appliesdoGenerate/doStream:settings.provider< factoryextraBody.provider< modelextraBody.provider<providerOptions.openrouter.provider.doGenerate/doStream: factoryextraBody.provider< modelextraBody.provider< runtime. Completion settings have noproviderfield.providerto the helper result, so a non-objectprovidercoming fromextraBody(e.g.extraBody: { provider: null }) never leaks into the body.undefinedis dropped by JSON serialization.src/embedding/index.tsis removed.nullclears everything).Behavior changes (see changeset, minor):
providerobject now merges with configured routing instead of replacing it. Runtimenullstill clears routing.provider: nullpreviously was ignored (configured routing kept); it now clears routing, consistent with chat/completion. Image no longer forwards non-objectextraBody.providervalues.Checklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests passChangeset
pnpm changesetto create a changeset file