fix(model-resolution): normalize model format and remove dead config flag

This commit is contained in:
YeonGyu-Kim
2026-03-03 00:31:12 +09:00
parent d4033da41a
commit c80a74c5f4
4 changed files with 60 additions and 5 deletions
@@ -4,6 +4,7 @@ import { resolveSubagentExecution } from "./subagent-resolver"
import type { DelegateTaskArgs } from "./types"
import type { ExecutorContext } from "./executor-types"
import * as logger from "../../shared/logger"
import * as connectedProvidersCache from "../../shared/connected-providers-cache"
function createBaseArgs(overrides?: Partial<DelegateTaskArgs>): DelegateTaskArgs {
return {
@@ -79,4 +80,25 @@ describe("resolveSubagentExecution", () => {
error: "network timeout",
})
})
test("normalizes matched agent model string before returning categoryModel", async () => {
//#given
const cacheSpy = spyOn(connectedProvidersCache, "readProviderModelsCache").mockReturnValue({
models: { openai: ["grok-3"] },
connected: ["openai"],
updatedAt: "2026-03-03T00:00:00.000Z",
})
const args = createBaseArgs({ subagent_type: "oracle" })
const executorCtx = createExecutorContext(async () => ([
{ name: "oracle", mode: "subagent", model: "openai/gpt-5.3-codex" },
]))
//#when
const result = await resolveSubagentExecution(args, executorCtx, "sisyphus", "deep")
//#then
expect(result.error).toBeUndefined()
expect(result.categoryModel).toEqual({ providerID: "openai", modelID: "gpt-5.3-codex" })
cacheSpy.mockRestore()
})
})
+12 -3
View File
@@ -51,7 +51,11 @@ Create the work plan directly - that's your job as the planning agent.`,
try {
const agentsResult = await client.app.agents()
type AgentInfo = { name: string; mode?: "subagent" | "primary" | "all"; model?: { providerID: string; modelID: string } }
type AgentInfo = {
name: string
mode?: "subagent" | "primary" | "all"
model?: string | { providerID: string; modelID: string }
}
const agents = normalizeSDKResponse(agentsResult, [] as AgentInfo[], {
preferResponseOnMissingData: true,
})
@@ -99,7 +103,9 @@ Create the work plan directly - that's your job as the planning agent.`,
if (agentOverride?.model || agentRequirement || matchedAgent.model) {
const availableModels = await getAvailableModelsForDelegateTask(client)
const normalizedMatchedModel = normalizeModelFormat(matchedAgent.model as Parameters<typeof normalizeModelFormat>[0])
const normalizedMatchedModel = matchedAgent.model
? normalizeModelFormat(matchedAgent.model)
: undefined
const matchedAgentModelStr = normalizedMatchedModel
? `${normalizedMatchedModel.providerID}/${normalizedMatchedModel.modelID}`
: undefined
@@ -122,7 +128,10 @@ Create the work plan directly - that's your job as the planning agent.`,
}
if (!categoryModel && matchedAgent.model) {
categoryModel = matchedAgent.model
const normalizedMatchedModel = normalizeModelFormat(matchedAgent.model)
if (normalizedMatchedModel) {
categoryModel = normalizedMatchedModel
}
}
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)