mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
fix: merge normalized OpenRouter provider settings
This commit is contained in:
@@ -1145,13 +1145,13 @@ describe("openrouter provider hooks", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("merges routing split across trimmed duplicate OpenRouter provider keys", async () => {
|
||||
it("merges routing split across case- and whitespace-equivalent OpenRouter keys", async () => {
|
||||
const provider = await registerSingleProviderPlugin(openrouterPlugin);
|
||||
const patch = provider.extraParamsForTransport?.({
|
||||
config: {
|
||||
models: {
|
||||
providers: {
|
||||
" openrouter ": {
|
||||
" OpenRouter ": {
|
||||
params: {
|
||||
provider: {
|
||||
order: ["anthropic"],
|
||||
|
||||
@@ -75,20 +75,11 @@ function resolveOpenRouterProviderConfigParams(
|
||||
}
|
||||
|
||||
const providers = Object.entries(ctx.config?.models?.providers ?? {});
|
||||
const exactKey = providers.find(([provider]) => provider.trim() === requestedProvider)?.[0];
|
||||
const fallbackKey = providers.find(
|
||||
([provider]) => normalizeProviderId(provider) === normalizedProvider,
|
||||
)?.[0];
|
||||
const providerKey = (exactKey ?? fallbackKey)?.trim();
|
||||
if (!providerKey) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Preserve routing split across normalized duplicates; merge nested params
|
||||
// field-wise while allowing later scalar settings to override earlier ones.
|
||||
let matchedParams: Record<string, unknown> | undefined;
|
||||
for (const [provider, config] of providers) {
|
||||
if (provider.trim() !== providerKey) {
|
||||
if (normalizeProviderId(provider) !== normalizedProvider) {
|
||||
continue;
|
||||
}
|
||||
const params = readRecord(config.params);
|
||||
|
||||
Reference in New Issue
Block a user