fix: honor category-derived model overrides in call_omo_agent
This commit is contained in:
@@ -265,6 +265,60 @@ describe("createCallOmoAgent", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("forwards category-derived model override to background executor", async () => {
|
||||||
|
//#given
|
||||||
|
const launch = mock((_input: { model?: { providerID: string; modelID: string } }) => Promise.resolve({
|
||||||
|
id: "task-category-model",
|
||||||
|
sessionID: "sub-session",
|
||||||
|
description: "Test task",
|
||||||
|
agent: "explore",
|
||||||
|
status: "pending",
|
||||||
|
}))
|
||||||
|
const managerWithLaunch = {
|
||||||
|
launch,
|
||||||
|
getTask: mock(() => undefined),
|
||||||
|
}
|
||||||
|
const toolDef = createCallOmoAgent(
|
||||||
|
mockCtx,
|
||||||
|
managerWithLaunch,
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
explore: {
|
||||||
|
category: "research",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
research: {
|
||||||
|
model: "openai/gpt-5.4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
const executeFunc = toolDef.execute as Function
|
||||||
|
|
||||||
|
//#when
|
||||||
|
await executeFunc(
|
||||||
|
{
|
||||||
|
description: "Test category model override",
|
||||||
|
prompt: "Test prompt",
|
||||||
|
subagent_type: "explore",
|
||||||
|
run_in_background: true,
|
||||||
|
},
|
||||||
|
{ sessionID: "test", messageID: "msg", agent: "test", abort: new AbortController().signal }
|
||||||
|
)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
const firstLaunchCall = launch.mock.calls[0]
|
||||||
|
if (firstLaunchCall === undefined) {
|
||||||
|
throw new Error("Expected launch to be called")
|
||||||
|
}
|
||||||
|
|
||||||
|
const [launchArgs] = firstLaunchCall
|
||||||
|
expect(launchArgs.model).toEqual({
|
||||||
|
providerID: "openai",
|
||||||
|
modelID: "gpt-5.4",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
test("should return a tool error when sync spawn depth validation fails", async () => {
|
test("should return a tool error when sync spawn depth validation fails", async () => {
|
||||||
//#given
|
//#given
|
||||||
reserveSubagentSpawnMock.mockRejectedValueOnce(new Error("Subagent spawn blocked: child depth 4 exceeds background_task.maxDepth=3."))
|
reserveSubagentSpawnMock.mockRejectedValueOnce(new Error("Subagent spawn blocked: child depth 4 exceeds background_task.maxDepth=3."))
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ function resolveModelAndFallbackChain(args: {
|
|||||||
?? (agentOverrides
|
?? (agentOverrides
|
||||||
? Object.entries(agentOverrides).find(([key]) => key.toLowerCase() === agentConfigKey)?.[1]
|
? Object.entries(agentOverrides).find(([key]) => key.toLowerCase() === agentConfigKey)?.[1]
|
||||||
: undefined)
|
: undefined)
|
||||||
|
const agentCategoryModel = agentOverride?.category
|
||||||
|
? userCategories?.[agentOverride.category]?.model
|
||||||
|
: undefined
|
||||||
|
const agentCategoryVariant = agentOverride?.category
|
||||||
|
? userCategories?.[agentOverride.category]?.variant
|
||||||
|
: undefined
|
||||||
|
|
||||||
let model: DelegatedModelConfig | undefined
|
let model: DelegatedModelConfig | undefined
|
||||||
if (agentOverride?.model) {
|
if (agentOverride?.model) {
|
||||||
@@ -39,6 +45,18 @@ function resolveModelAndFallbackChain(args: {
|
|||||||
variant: agentOverride.variant,
|
variant: agentOverride.variant,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else if (agentCategoryModel) {
|
||||||
|
const normalized = normalizeModelFormat(agentCategoryModel)
|
||||||
|
if (normalized) {
|
||||||
|
const variantToUse = agentOverride?.variant ?? agentCategoryVariant
|
||||||
|
model = variantToUse ? { ...normalized, variant: variantToUse } : normalized
|
||||||
|
log("[call_omo_agent] Resolved model override from agent category", {
|
||||||
|
agent: subagentType,
|
||||||
|
category: agentOverride?.category,
|
||||||
|
model: agentCategoryModel,
|
||||||
|
variant: variantToUse,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedFallbackModels = normalizeFallbackModels(
|
const normalizedFallbackModels = normalizeFallbackModels(
|
||||||
|
|||||||
Reference in New Issue
Block a user