mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 02:00:21 +00:00
Agents: fix subagent model precedence
This commit is contained in:
committed by
Ayaan Zaidi
parent
d4cccda570
commit
e394262bd8
@@ -95,6 +95,7 @@ async function runSubagentModelCase(params: {
|
||||
home: string;
|
||||
cfgOverrides?: Partial<OpenClawConfig>;
|
||||
jobModelOverride?: string;
|
||||
agentId?: string;
|
||||
}) {
|
||||
const storePath = await writeSessionStore(params.home);
|
||||
mockEmbeddedAgent();
|
||||
@@ -102,6 +103,9 @@ async function runSubagentModelCase(params: {
|
||||
if (params.jobModelOverride) {
|
||||
job.payload = { kind: "agentTurn", message: "do work", model: params.jobModelOverride };
|
||||
}
|
||||
if (params.agentId) {
|
||||
job.agentId = params.agentId;
|
||||
}
|
||||
|
||||
await runCronIsolatedAgentTurn({
|
||||
cfg: makeCfg(params.home, storePath, params.cfgOverrides),
|
||||
@@ -192,4 +196,25 @@ describe("runCronIsolatedAgentTurn: subagent model resolution (#11461)", () => {
|
||||
expect(call?.model).toBe("gpt-4o");
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers the agent model over agents.defaults.subagents.model", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const call = await runSubagentModelCase({
|
||||
home,
|
||||
agentId: "research",
|
||||
cfgOverrides: {
|
||||
agents: {
|
||||
defaults: {
|
||||
model: "anthropic/claude-sonnet-4-5",
|
||||
workspace: path.join(home, "openclaw"),
|
||||
subagents: { model: "ollama/llama3.2:3b" },
|
||||
},
|
||||
list: [{ id: "research", model: { primary: "anthropic/claude-opus-4-6" } }],
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(call?.provider).toBe("anthropic");
|
||||
expect(call?.model).toBe("claude-opus-4-6");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ export type ResolveCronModelSelectionParams = {
|
||||
cfg: OpenClawConfig;
|
||||
cfgWithAgentDefaults: OpenClawConfig;
|
||||
agentConfigOverride?: {
|
||||
model?: unknown;
|
||||
subagents?: {
|
||||
model?: unknown;
|
||||
};
|
||||
@@ -61,6 +62,7 @@ export async function resolveCronModelSelection(
|
||||
|
||||
const subagentModelRaw =
|
||||
normalizeModelSelection(params.agentConfigOverride?.subagents?.model) ??
|
||||
normalizeModelSelection(params.agentConfigOverride?.model) ??
|
||||
normalizeModelSelection(params.cfg.agents?.defaults?.subagents?.model);
|
||||
if (subagentModelRaw) {
|
||||
const resolvedSubagent = resolveAllowedModelRef({
|
||||
|
||||
Reference in New Issue
Block a user