fix: normalize status summary provider config lookup

This commit is contained in:
Tak Hoffman
2026-03-27 21:06:27 -05:00
parent c1fb18189b
commit 2877a7d8b2
2 changed files with 26 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { statusSummaryRuntime } from "./status.summary.runtime.js";
describe("statusSummaryRuntime.resolveContextTokensForModel", () => {
it("matches provider context window overrides across canonical provider aliases", () => {
const contextTokens = statusSummaryRuntime.resolveContextTokensForModel({
cfg: {
models: {
providers: {
"z.ai": {
models: [{ id: "glm-4.7", contextWindow: 123_456 }],
},
},
},
} as never,
provider: "z-ai",
model: "glm-4.7",
fallbackContextTokens: 999,
});
expect(contextTokens).toBe(123_456);
});
});

View File

@@ -1,5 +1,6 @@
import { resolveConfiguredProviderFallback } from "../agents/configured-provider-fallback.js";
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
import { normalizeProviderId } from "../agents/provider-id.js";
import { resolveAgentModelPrimaryValue } from "../config/model-input.js";
import type { SessionEntry } from "../config/sessions/types.js";
import type { OpenClawConfig } from "../config/types.js";
@@ -106,9 +107,9 @@ function resolveConfiguredProviderContextWindow(
if (!providers || typeof providers !== "object") {
return undefined;
}
const providerKey = provider.trim().toLowerCase();
const providerKey = normalizeProviderId(provider);
for (const [id, providerConfig] of Object.entries(providers)) {
if (id.trim().toLowerCase() !== providerKey || !Array.isArray(providerConfig?.models)) {
if (normalizeProviderId(id) !== providerKey || !Array.isArray(providerConfig?.models)) {
continue;
}
for (const entry of providerConfig.models) {