fix: align sync fallback chain, fix model-fallback test determinism
- Hoist resolveFallbackChainForCallOmoAgent before sync/background branch so sync executor also receives the fallback chain - Add fallbackChain parameter to sync-executor with setSessionFallbackChain - Mock connected-providers-cache in event.model-fallback tests for deterministic behavior (no dependency on local cache files) - Update test expectations to account for no-op fallback skip when normalized current model matches first fallback entry - Add cache spy isolation for subagent-resolver fallback_models tests
This commit is contained in:
@@ -9,6 +9,7 @@ describe("executeSync", () => {
|
||||
createOrGetSession: mock(async () => ({ sessionID: "ses-test-123", isNew: true })),
|
||||
waitForCompletion: mock(async () => {}),
|
||||
processMessages: mock(async () => "agent response"),
|
||||
setSessionFallbackChain: mock(() => {}),
|
||||
}
|
||||
|
||||
let promptArgs: any
|
||||
@@ -53,6 +54,7 @@ describe("executeSync", () => {
|
||||
createOrGetSession: mock(async () => ({ sessionID: "ses-test-123", isNew: true })),
|
||||
waitForCompletion: mock(async () => {}),
|
||||
processMessages: mock(async () => "agent response"),
|
||||
setSessionFallbackChain: mock(() => {}),
|
||||
}
|
||||
|
||||
let promptArgs: any
|
||||
@@ -88,4 +90,48 @@ describe("executeSync", () => {
|
||||
expect(promptAsync).toHaveBeenCalled()
|
||||
expect(promptArgs.body.tools.task).toBe(false)
|
||||
})
|
||||
|
||||
test("applies fallbackChain to sync sessions", async () => {
|
||||
//#given
|
||||
const { executeSync } = require("./sync-executor")
|
||||
|
||||
const setSessionFallbackChain = mock(() => {})
|
||||
const deps = {
|
||||
createOrGetSession: mock(async () => ({ sessionID: "ses-test-456", isNew: true })),
|
||||
waitForCompletion: mock(async () => {}),
|
||||
processMessages: mock(async () => "agent response"),
|
||||
setSessionFallbackChain,
|
||||
}
|
||||
|
||||
const args = {
|
||||
subagent_type: "explore",
|
||||
description: "test task",
|
||||
prompt: "find something",
|
||||
}
|
||||
|
||||
const toolContext = {
|
||||
sessionID: "parent-session",
|
||||
messageID: "msg-3",
|
||||
agent: "sisyphus",
|
||||
abort: new AbortController().signal,
|
||||
metadata: mock(async () => {}),
|
||||
}
|
||||
|
||||
const ctx = {
|
||||
client: {
|
||||
session: { promptAsync: mock(async () => ({ data: {} })) },
|
||||
},
|
||||
}
|
||||
|
||||
const fallbackChain = [
|
||||
{ providers: ["quotio"], model: "kimi-k2.5", variant: undefined },
|
||||
{ providers: ["openai"], model: "gpt-5.2", variant: "high" },
|
||||
]
|
||||
|
||||
//#when
|
||||
await executeSync(args, toolContext, ctx as any, deps, fallbackChain)
|
||||
|
||||
//#then
|
||||
expect(setSessionFallbackChain).toHaveBeenCalledWith("ses-test-456", fallbackChain)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user