fix(model-fallback): retry forbidden provider errors

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Choi Kijin / 최 기진 / チョイ キジン
2026-04-28 15:29:33 +09:00
parent 613e4a6c12
commit 25548f2561
6 changed files with 59 additions and 29 deletions
@@ -33,16 +33,15 @@ export function extractErrorName(error: unknown): string | undefined {
export function extractErrorMessage(error: unknown): string | undefined {
if (!error) return undefined
if (typeof error === "string") return error
if (error instanceof Error) return error.message
if (isRecord(error)) {
const dataRaw = error["data"]
const candidates: unknown[] = [
error,
dataRaw,
error["error"],
isRecord(dataRaw) ? (dataRaw as Record<string, unknown>)["error"] : undefined,
error["error"],
error["cause"],
error,
]
for (const candidate of candidates) {
@@ -57,6 +56,8 @@ export function extractErrorMessage(error: unknown): string | undefined {
}
}
if (error instanceof Error) return error.message
try {
return JSON.stringify(error)
} catch {