fix(runtime-fallback): detect bare 429 rate-limit signals (fixes #2677)

This commit is contained in:
MoerAI
2026-03-20 11:00:00 +09:00
parent d2a49428b9
commit 3773e370ec
3 changed files with 41 additions and 1 deletions
@@ -1,6 +1,7 @@
import { describe, expect, it } from "bun:test"
import type { RuntimeFallbackPluginInput } from "./types"
import { hasVisibleAssistantResponse } from "./visible-assistant-response"
import { extractAutoRetrySignal } from "./error-classifier"
function createContext(messagesResponse: unknown): RuntimeFallbackPluginInput {
return {
@@ -53,4 +54,29 @@ describe("hasVisibleAssistantResponse", () => {
// then
expect(result).toBe(true)
})
it("#given a too-many-requests assistant reply #when visibility is checked #then it is treated as an auto-retry signal", async () => {
// given
const checkVisibleResponse = hasVisibleAssistantResponse(extractAutoRetrySignal)
const ctx = createContext({
data: [
{ info: { role: "user" }, parts: [{ type: "text", text: "latest question" }] },
{
info: { role: "assistant" },
parts: [
{
type: "text",
text: "Too Many Requests: Sorry, you've exhausted this model's rate limit. Please try a different model.",
},
],
},
],
})
// when
const result = await checkVisibleResponse(ctx, "session-rate-limit", undefined)
// then
expect(result).toBe(false)
})
})