mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-23 02:45:38 -06:00
fix(config): clone catalog metadata before defaults (#126123)
* fix(config): clone catalog metadata before defaults * refactor(config): keep catalog clone net neutral
This commit is contained in:
committed by
GitHub
parent
bf420e92c6
commit
3666fa6825
@@ -310,6 +310,56 @@ describe("applyModelDefaults catalog seeding", () => {
|
||||
expect(model.input).toEqual(["text", "image"]);
|
||||
});
|
||||
|
||||
it("copies frozen catalog metadata before downstream normalization", async () => {
|
||||
const supportedReasoningEfforts = Object.freeze(["low", "high"]);
|
||||
const compat = Object.freeze({ supportedReasoningEfforts });
|
||||
const frozenRegistry = {
|
||||
plugins: [
|
||||
{
|
||||
id: "openai",
|
||||
modelCatalog: {
|
||||
providers: {
|
||||
openai: {
|
||||
models: [
|
||||
Object.freeze({
|
||||
id: "gpt-5.6-sol",
|
||||
name: "GPT-5.6 Sol",
|
||||
reasoning: true,
|
||||
compat,
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
// SAFETY: minimal frozen manifest record reproducing production registry ownership.
|
||||
} as never;
|
||||
const { applyModelDefaults } = await import("./defaults.js");
|
||||
const cfg = applyModelDefaults(
|
||||
{
|
||||
models: {
|
||||
providers: {
|
||||
openai: {
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
models: [{ id: "gpt-5.6-sol", name: "GPT-5.6" } as never],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ manifestRegistry: frozenRegistry },
|
||||
);
|
||||
const model = expectDefined(
|
||||
cfg.models?.providers?.openai?.models?.[0],
|
||||
"materialized model entry",
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
model.compat!.supportedReasoningEfforts = ["low"];
|
||||
}).not.toThrow();
|
||||
expect(compat.supportedReasoningEfforts).toEqual(["low", "high"]);
|
||||
});
|
||||
|
||||
it("falls back to generic defaults when no catalog row matches", async () => {
|
||||
const { applyModelDefaults } = await import("./defaults.js");
|
||||
const cfg = applyModelDefaults(
|
||||
|
||||
@@ -206,7 +206,7 @@ function buildManifestCatalogModelLookup(
|
||||
}
|
||||
}
|
||||
}
|
||||
return index.get(keyFor(providerId, modelId));
|
||||
return structuredClone(index.get(keyFor(providerId, modelId)));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user