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
+5 -4
View File
@@ -63,18 +63,17 @@ function extractErrorName(error: unknown): string | undefined {
return undefined;
}
function extractErrorMessage(error: unknown): string {
export function extractErrorMessage(error: unknown): string {
if (!error) return "";
if (typeof error === "string") return error;
if (error instanceof Error) return error.message;
if (isRecord(error)) {
const candidates: unknown[] = [
error,
error.data,
error.error,
isRecord(error.data) ? error.data.error : undefined,
error.error,
error.cause,
error,
];
for (const candidate of candidates) {
@@ -84,6 +83,8 @@ function extractErrorMessage(error: unknown): string {
}
}
if (error instanceof Error) return error.message;
try {
return JSON.stringify(error);
} catch {