fix: honor category-derived model overrides in call_omo_agent

This commit is contained in:
YeonGyu-Kim
2026-03-31 17:03:42 -07:00
parent 9f2c4500e8
commit de7d72db27
2 changed files with 72 additions and 0 deletions
+54
View File
@@ -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 () => {
//#given
reserveSubagentSpawnMock.mockRejectedValueOnce(new Error("Subagent spawn blocked: child depth 4 exceeds background_task.maxDepth=3."))
+18
View File
@@ -27,6 +27,12 @@ function resolveModelAndFallbackChain(args: {
?? (agentOverrides
? Object.entries(agentOverrides).find(([key]) => key.toLowerCase() === agentConfigKey)?.[1]
: undefined)
const agentCategoryModel = agentOverride?.category
? userCategories?.[agentOverride.category]?.model
: undefined
const agentCategoryVariant = agentOverride?.category
? userCategories?.[agentOverride.category]?.variant
: undefined
let model: DelegatedModelConfig | undefined
if (agentOverride?.model) {
@@ -39,6 +45,18 @@ function resolveModelAndFallbackChain(args: {
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(