mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-21 22:21:33 +00:00
fix: normalize status summary provider config lookup
This commit is contained in:
23
src/commands/status.summary.runtime.test.ts
Normal file
23
src/commands/status.summary.runtime.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user