fix(agents): prefer agent model for subagent spawns
This commit is contained in:
parent
f036ed27f4
commit
fbc62c4976
@ -14,6 +14,7 @@ import {
|
||||
resolveConfiguredModelRef,
|
||||
resolveThinkingDefault,
|
||||
resolveModelRefFromString,
|
||||
resolveSubagentConfiguredModelSelection,
|
||||
} from "./model-selection.js";
|
||||
|
||||
const EXPLICIT_ALLOWLIST_CONFIG = {
|
||||
@ -826,3 +827,21 @@ describe("normalizeModelSelection", () => {
|
||||
expect(normalizeModelSelection(42)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSubagentConfiguredModelSelection", () => {
|
||||
it("prefers the target agent primary model over the global subagent default", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
subagents: { model: "minimax/MiniMax-M2.5" },
|
||||
model: { primary: "openai/gpt-5.4" },
|
||||
},
|
||||
list: [{ id: "research", model: { primary: "opencode/claude" } }],
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(resolveSubagentConfiguredModelSelection({ cfg, agentId: "research" })).toBe(
|
||||
"opencode/claude",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -381,8 +381,8 @@ export function resolveSubagentConfiguredModelSelection(params: {
|
||||
const agentConfig = resolveAgentConfig(params.cfg, params.agentId);
|
||||
return (
|
||||
normalizeModelSelection(agentConfig?.subagents?.model) ??
|
||||
normalizeModelSelection(params.cfg.agents?.defaults?.subagents?.model) ??
|
||||
normalizeModelSelection(agentConfig?.model)
|
||||
normalizeModelSelection(agentConfig?.model) ??
|
||||
normalizeModelSelection(params.cfg.agents?.defaults?.subagents?.model)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -230,6 +230,24 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("sessions_spawn prefers target agent primary model over global subagent default", async () => {
|
||||
await expectSpawnUsesConfiguredModel({
|
||||
config: {
|
||||
session: { mainKey: "main", scope: "per-sender" },
|
||||
agents: {
|
||||
defaults: {
|
||||
subagents: { model: "minimax/MiniMax-M2.5" },
|
||||
model: { primary: "openai/gpt-5.4" },
|
||||
},
|
||||
list: [{ id: "research", model: { primary: "opencode/claude" } }],
|
||||
},
|
||||
},
|
||||
runId: "run-agent-primary-over-subagent-default",
|
||||
callId: "call-agent-primary-over-subagent-default",
|
||||
expectedModel: "opencode/claude",
|
||||
});
|
||||
});
|
||||
|
||||
it("sessions_spawn prefers target agent primary model over global default", async () => {
|
||||
await expectSpawnUsesConfiguredModel({
|
||||
config: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user