fix(runtime-fallback): gate retry prompts
This commit is contained in:
@@ -40,6 +40,7 @@ describe("runtime-fallback", () => {
|
||||
messages?: (args: unknown) => Promise<unknown>
|
||||
promptAsync?: (args: unknown) => Promise<unknown>
|
||||
abort?: (args: unknown) => Promise<unknown>
|
||||
status?: () => Promise<unknown>
|
||||
}
|
||||
}) {
|
||||
return unsafeTestValue({
|
||||
@@ -57,6 +58,7 @@ describe("runtime-fallback", () => {
|
||||
messages: overrides?.session?.messages ?? (async () => ({ data: [] })),
|
||||
promptAsync: overrides?.session?.promptAsync ?? (async () => ({})),
|
||||
abort: overrides?.session?.abort ?? (async () => ({})),
|
||||
...(overrides?.session?.status ? { status: overrides.session.status } : {}),
|
||||
},
|
||||
},
|
||||
directory: "/test/dir",
|
||||
@@ -2471,6 +2473,66 @@ describe("runtime-fallback", () => {
|
||||
expect(callBody?.agent).toBe("prometheus")
|
||||
expect(callBody?.model).toEqual({ providerID: "github-copilot", modelID: "claude-opus-4.7" })
|
||||
})
|
||||
|
||||
test("should not dispatch a second fallback prompt while the accepted retry session is still active", async () => {
|
||||
const sessionID = "test-runtime-fallback-active-gate"
|
||||
let sessionStatus = "idle"
|
||||
const promptCalls: Array<Record<string, unknown>> = []
|
||||
const hook = createRuntimeFallbackHook(
|
||||
createMockPluginInput({
|
||||
session: {
|
||||
messages: async () => ({
|
||||
data: [
|
||||
{
|
||||
info: { role: "user" },
|
||||
parts: [{ type: "text", text: "retry this" }],
|
||||
},
|
||||
],
|
||||
}),
|
||||
promptAsync: async (args: unknown) => {
|
||||
promptCalls.push(args as Record<string, unknown>)
|
||||
sessionStatus = "busy"
|
||||
return {}
|
||||
},
|
||||
status: async () => ({ data: { [sessionID]: { type: sessionStatus } } }),
|
||||
},
|
||||
}),
|
||||
{
|
||||
config: createMockConfig({ notify_on_fallback: false }),
|
||||
pluginConfig: createMockPluginConfigWithCategoryFallback([
|
||||
"github-copilot/claude-opus-4.7",
|
||||
"openai/gpt-5.4",
|
||||
]),
|
||||
},
|
||||
)
|
||||
SessionCategoryRegistry.register(sessionID, "test")
|
||||
|
||||
await hook.event({
|
||||
event: {
|
||||
type: "session.created",
|
||||
properties: { info: { id: sessionID, model: "anthropic/claude-opus-4-7" } },
|
||||
},
|
||||
})
|
||||
|
||||
await hook.event({
|
||||
event: {
|
||||
type: "session.error",
|
||||
properties: { sessionID, error: { statusCode: 503, message: "Service unavailable" } },
|
||||
},
|
||||
})
|
||||
await hook.event({
|
||||
event: {
|
||||
type: "session.error",
|
||||
properties: {
|
||||
sessionID,
|
||||
model: "github-copilot/claude-opus-4.7",
|
||||
error: { statusCode: 503, message: "Service unavailable" },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(promptCalls).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("cooldown mechanism", () => {
|
||||
|
||||
Reference in New Issue
Block a user