mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:57:40 +00:00
fix(agents): fall back to agents.defaults.model when agent has no model config (#24210)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 0f272b1027
Co-authored-by: bianbiandashen <16240681+bianbiandashen@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -82,6 +82,25 @@ describe("models set + fallbacks", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves primary when adding fallbacks to string defaults.model", async () => {
|
||||
mockConfigSnapshot({ agents: { defaults: { model: "openai/gpt-4.1-mini" } } });
|
||||
const runtime = makeRuntime();
|
||||
|
||||
await modelsFallbacksAddCommand("anthropic/claude-opus-4-6", runtime);
|
||||
|
||||
expect(writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const written = getWrittenConfig();
|
||||
expect(written.agents).toEqual({
|
||||
defaults: {
|
||||
model: {
|
||||
primary: "openai/gpt-4.1-mini",
|
||||
fallbacks: ["anthropic/claude-opus-4-6"],
|
||||
},
|
||||
models: { "anthropic/claude-opus-4-6": {} },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes provider casing in models set", async () => {
|
||||
mockConfigSnapshot({});
|
||||
const runtime = makeRuntime();
|
||||
@@ -90,4 +109,20 @@ describe("models set + fallbacks", () => {
|
||||
|
||||
expectWrittenPrimaryModel("zai/glm-4.7");
|
||||
});
|
||||
|
||||
it("rewrites string defaults.model to object form when setting primary", async () => {
|
||||
mockConfigSnapshot({ agents: { defaults: { model: "openai/gpt-4.1-mini" } } });
|
||||
const runtime = makeRuntime();
|
||||
|
||||
await modelsSetCommand("anthropic/claude-opus-4-6", runtime);
|
||||
|
||||
expect(writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const written = getWrittenConfig();
|
||||
expect(written.agents).toEqual({
|
||||
defaults: {
|
||||
model: { primary: "anthropic/claude-opus-4-6" },
|
||||
models: { "anthropic/claude-opus-4-6": {} },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user