diff --git a/src/agents/builtin-agents.ts b/src/agents/builtin-agents.ts index 07fcc64fa..350d69e54 100644 --- a/src/agents/builtin-agents.ts +++ b/src/agents/builtin-agents.ts @@ -115,6 +115,7 @@ export async function createBuiltinAgents( browserProvider, uiSelectedModel, availableModels, + isFirstRunNoCache, disabledSkills, disableOmoEnv, }) diff --git a/src/agents/builtin-agents/general-agents.ts b/src/agents/builtin-agents/general-agents.ts index e75baa146..7727cf999 100644 --- a/src/agents/builtin-agents/general-agents.ts +++ b/src/agents/builtin-agents/general-agents.ts @@ -7,7 +7,7 @@ import { AGENT_MODEL_REQUIREMENTS, isModelAvailable } from "../../shared" import { buildAgent, isFactory } from "../agent-builder" import { applyOverrides } from "./agent-overrides" import { applyEnvironmentContext } from "./environment-context" -import { applyModelResolution } from "./model-resolution" +import { applyModelResolution, getFirstFallbackModel } from "./model-resolution" export function collectPendingBuiltinAgents(input: { agentSources: Record @@ -21,6 +21,7 @@ export function collectPendingBuiltinAgents(input: { browserProvider?: BrowserAutomationProvider uiSelectedModel?: string availableModels: Set + isFirstRunNoCache: boolean disabledSkills?: Set useTaskSystem?: boolean disableOmoEnv?: boolean @@ -37,6 +38,7 @@ export function collectPendingBuiltinAgents(input: { browserProvider, uiSelectedModel, availableModels, + isFirstRunNoCache, disabledSkills, disableOmoEnv = false, } = input @@ -66,13 +68,16 @@ export function collectPendingBuiltinAgents(input: { const isPrimaryAgent = isFactory(source) && source.mode === "primary" - const resolution = applyModelResolution({ + let resolution = applyModelResolution({ uiSelectedModel: (isPrimaryAgent && !override?.model) ? uiSelectedModel : undefined, userModel: override?.model, requirement, availableModels, systemDefaultModel, }) + if (!resolution && isFirstRunNoCache && !override?.model) { + resolution = getFirstFallbackModel(requirement) + } if (!resolution) continue const { model, variant: resolvedVariant } = resolution diff --git a/src/agents/utils.test.ts b/src/agents/utils.test.ts index f49c5230b..645e0edc0 100644 --- a/src/agents/utils.test.ts +++ b/src/agents/utils.test.ts @@ -483,17 +483,23 @@ describe("createBuiltinAgents without systemDefaultModel", () => { cacheSpy.mockRestore?.() }) - test("agents NOT created when no cache and no systemDefaultModel (first run without defaults)", async () => { - // #given - const cacheSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(null) + test("oracle is created on first run when no cache and no systemDefaultModel", async () => { + // #given + const cacheSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(null) + const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue(new Set()) - // #when - const agents = await createBuiltinAgents([], {}, undefined, undefined) + try { + // #when + const agents = await createBuiltinAgents([], {}, undefined, undefined) - // #then - expect(agents.oracle).toBeUndefined() - cacheSpy.mockRestore?.() - }) + // #then + expect(agents.oracle).toBeDefined() + expect(agents.oracle.model).toBe("openai/gpt-5.4") + } finally { + fetchSpy.mockRestore() + cacheSpy.mockRestore() + } + }) test("sisyphus created via connected cache fallback when all providers available", async () => { // #given