fix(agents): keep oracle available on first run without cache
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -115,6 +115,7 @@ export async function createBuiltinAgents(
|
|||||||
browserProvider,
|
browserProvider,
|
||||||
uiSelectedModel,
|
uiSelectedModel,
|
||||||
availableModels,
|
availableModels,
|
||||||
|
isFirstRunNoCache,
|
||||||
disabledSkills,
|
disabledSkills,
|
||||||
disableOmoEnv,
|
disableOmoEnv,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { AGENT_MODEL_REQUIREMENTS, isModelAvailable } from "../../shared"
|
|||||||
import { buildAgent, isFactory } from "../agent-builder"
|
import { buildAgent, isFactory } from "../agent-builder"
|
||||||
import { applyOverrides } from "./agent-overrides"
|
import { applyOverrides } from "./agent-overrides"
|
||||||
import { applyEnvironmentContext } from "./environment-context"
|
import { applyEnvironmentContext } from "./environment-context"
|
||||||
import { applyModelResolution } from "./model-resolution"
|
import { applyModelResolution, getFirstFallbackModel } from "./model-resolution"
|
||||||
|
|
||||||
export function collectPendingBuiltinAgents(input: {
|
export function collectPendingBuiltinAgents(input: {
|
||||||
agentSources: Record<BuiltinAgentName, import("../agent-builder").AgentSource>
|
agentSources: Record<BuiltinAgentName, import("../agent-builder").AgentSource>
|
||||||
@@ -21,6 +21,7 @@ export function collectPendingBuiltinAgents(input: {
|
|||||||
browserProvider?: BrowserAutomationProvider
|
browserProvider?: BrowserAutomationProvider
|
||||||
uiSelectedModel?: string
|
uiSelectedModel?: string
|
||||||
availableModels: Set<string>
|
availableModels: Set<string>
|
||||||
|
isFirstRunNoCache: boolean
|
||||||
disabledSkills?: Set<string>
|
disabledSkills?: Set<string>
|
||||||
useTaskSystem?: boolean
|
useTaskSystem?: boolean
|
||||||
disableOmoEnv?: boolean
|
disableOmoEnv?: boolean
|
||||||
@@ -37,6 +38,7 @@ export function collectPendingBuiltinAgents(input: {
|
|||||||
browserProvider,
|
browserProvider,
|
||||||
uiSelectedModel,
|
uiSelectedModel,
|
||||||
availableModels,
|
availableModels,
|
||||||
|
isFirstRunNoCache,
|
||||||
disabledSkills,
|
disabledSkills,
|
||||||
disableOmoEnv = false,
|
disableOmoEnv = false,
|
||||||
} = input
|
} = input
|
||||||
@@ -66,13 +68,16 @@ export function collectPendingBuiltinAgents(input: {
|
|||||||
|
|
||||||
const isPrimaryAgent = isFactory(source) && source.mode === "primary"
|
const isPrimaryAgent = isFactory(source) && source.mode === "primary"
|
||||||
|
|
||||||
const resolution = applyModelResolution({
|
let resolution = applyModelResolution({
|
||||||
uiSelectedModel: (isPrimaryAgent && !override?.model) ? uiSelectedModel : undefined,
|
uiSelectedModel: (isPrimaryAgent && !override?.model) ? uiSelectedModel : undefined,
|
||||||
userModel: override?.model,
|
userModel: override?.model,
|
||||||
requirement,
|
requirement,
|
||||||
availableModels,
|
availableModels,
|
||||||
systemDefaultModel,
|
systemDefaultModel,
|
||||||
})
|
})
|
||||||
|
if (!resolution && isFirstRunNoCache && !override?.model) {
|
||||||
|
resolution = getFirstFallbackModel(requirement)
|
||||||
|
}
|
||||||
if (!resolution) continue
|
if (!resolution) continue
|
||||||
const { model, variant: resolvedVariant } = resolution
|
const { model, variant: resolvedVariant } = resolution
|
||||||
|
|
||||||
|
|||||||
@@ -483,17 +483,23 @@ describe("createBuiltinAgents without systemDefaultModel", () => {
|
|||||||
cacheSpy.mockRestore?.()
|
cacheSpy.mockRestore?.()
|
||||||
})
|
})
|
||||||
|
|
||||||
test("agents NOT created when no cache and no systemDefaultModel (first run without defaults)", async () => {
|
test("oracle is created on first run when no cache and no systemDefaultModel", async () => {
|
||||||
// #given
|
// #given
|
||||||
const cacheSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(null)
|
const cacheSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(null)
|
||||||
|
const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue(new Set())
|
||||||
|
|
||||||
// #when
|
try {
|
||||||
const agents = await createBuiltinAgents([], {}, undefined, undefined)
|
// #when
|
||||||
|
const agents = await createBuiltinAgents([], {}, undefined, undefined)
|
||||||
|
|
||||||
// #then
|
// #then
|
||||||
expect(agents.oracle).toBeUndefined()
|
expect(agents.oracle).toBeDefined()
|
||||||
cacheSpy.mockRestore?.()
|
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 () => {
|
test("sisyphus created via connected cache fallback when all providers available", async () => {
|
||||||
// #given
|
// #given
|
||||||
|
|||||||
Reference in New Issue
Block a user