fix(core): prevent emergency fallback from masking original errors

This commit is contained in:
diegosouzapw
2026-03-29 01:46:05 -03:00
parent 3a5450039d
commit d23b19c466

View File

@@ -504,7 +504,7 @@ async function handleSingleModelChat(
`${currentModelStr} -> ${fallbackModelStr} | reason=${fallbackDecision.reason}`
);
return handleSingleModelChat(
const fallbackResponse = await handleSingleModelChat(
fallbackBody,
fallbackModelStr,
clientRawRequest,
@@ -514,6 +514,15 @@ async function handleSingleModelChat(
telemetry,
{ ...runtimeOptions, emergencyFallbackTried: true }
);
if (fallbackResponse.ok) {
return fallbackResponse;
}
log.warn(
"EMERGENCY_FALLBACK",
`Emergency fallback to ${fallbackModelStr} failed with status ${fallbackResponse.status}. Resuming original provider account fallback.`
);
}
}
}