mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 11:21:07 +00:00
fix: normalize explicit context provider aliases
This commit is contained in:
@@ -366,4 +366,19 @@ describe("lookupContextTokens", () => {
|
||||
});
|
||||
expect(result).toBe(1_048_576);
|
||||
});
|
||||
|
||||
it("resolveContextTokensForModel normalizes explicit provider aliases before config lookup", async () => {
|
||||
mockDiscoveryDeps([]);
|
||||
|
||||
const cfg = createContextOverrideConfig("z.ai", "glm-5", 256_000);
|
||||
const { resolveContextTokensForModel } = await import("./context.js");
|
||||
await flushAsyncWarmup();
|
||||
|
||||
const result = resolveContextTokensForModel({
|
||||
cfg: cfg as never,
|
||||
provider: "z-ai",
|
||||
model: "glm-5",
|
||||
});
|
||||
expect(result).toBe(256_000);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -292,9 +292,11 @@ function resolveProviderModelRef(params: {
|
||||
}
|
||||
const providerRaw = params.provider?.trim();
|
||||
if (providerRaw) {
|
||||
// Keep the exact (lowercased) provider key; callers that need the canonical
|
||||
// alias (e.g. cache key construction) apply normalizeProviderId explicitly.
|
||||
return { provider: providerRaw.toLowerCase(), model: modelRaw };
|
||||
const provider = normalizeProviderId(providerRaw);
|
||||
if (!provider) {
|
||||
return undefined;
|
||||
}
|
||||
return { provider, model: modelRaw };
|
||||
}
|
||||
const slash = modelRaw.indexOf("/");
|
||||
if (slash <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user