feat(runtime-fallback): add timeout toggle for quota retry detection

Make provider auto-retry signal detection respect timeout_seconds setting:
- When timeout_seconds=0, disable quota-based fallback escalation
- Only treat auto-retry signals as errors when timeout is enabled
- Add test to verify behavior when timeout_seconds is disabled
- Update documentation to explain timeout_seconds=0 behavior

This allows users to disable timeout-based fallbacks while keeping
error-based fallback functionality intact.
This commit is contained in:
Youngbin Kim
2026-02-12 17:49:13 -05:00
committed by YeonGyu-Kim
parent 8b2ae957e5
commit 68f5d982fc
3 changed files with 47 additions and 6 deletions
+6 -4
View File
@@ -805,7 +805,9 @@ export function createRuntimeFallbackHook(
const sessionID = info?.sessionID as string | undefined
const retrySignalResult = extractAutoRetrySignal(info)
const retrySignal = retrySignalResult?.signal
const error = info?.error ?? (retrySignal ? { name: "ProviderRateLimitError", message: retrySignal } : undefined)
const timeoutEnabled = config.timeout_seconds > 0
// Only treat auto-retry signal as an error if timeout-based fallback is enabled
const error = info?.error ?? (retrySignal && timeoutEnabled ? { name: "ProviderRateLimitError", message: retrySignal } : undefined)
const role = info?.role as string | undefined
const model = info?.model as string | undefined
@@ -840,7 +842,7 @@ export function createRuntimeFallbackHook(
return
}
if (retrySignal && sessionRetryInFlight.has(sessionID)) {
if (retrySignal && sessionRetryInFlight.has(sessionID) && timeoutEnabled) {
log(`[${HOOK_NAME}] Overriding in-flight retry due to provider auto-retry signal`, {
sessionID,
model,
@@ -849,7 +851,7 @@ export function createRuntimeFallbackHook(
sessionRetryInFlight.delete(sessionID)
}
if (retrySignal) {
if (retrySignal && timeoutEnabled) {
log(`[${HOOK_NAME}] Detected provider auto-retry signal`, { sessionID, model })
}
@@ -918,7 +920,7 @@ export function createRuntimeFallbackHook(
sessionLastAccess.set(sessionID, Date.now())
if (state.pendingFallbackModel) {
if (retrySignal) {
if (retrySignal && timeoutEnabled) {
log(`[${HOOK_NAME}] Clearing pending fallback due to provider auto-retry signal`, {
sessionID,
pendingFallbackModel: state.pendingFallbackModel,