Address PR review follow-ups for retry status handling

This commit is contained in:
Ravi Tharuma
2026-03-04 20:52:15 +01:00
committed by YeonGyu-Kim
parent 86c6bc7716
commit c598afa521
6 changed files with 39 additions and 39 deletions
+1 -16
View File
@@ -6,6 +6,7 @@ import { extractStatusCode, extractErrorName, classifyErrorType, isRetryableErro
import { createFallbackState, prepareFallback } from "./fallback-state"
import { getFallbackModelsForSession } from "./fallback-models"
import { SessionCategoryRegistry } from "../../shared/session-category-registry"
import { normalizeRetryStatusMessage, extractRetryAttempt } from "../../shared/retry-status-utils"
export function createEventHandler(deps: HookDeps, helpers: AutoRetryHelpers) {
const { config, pluginConfig, sessionStates, sessionLastAccess, sessionRetryInFlight, sessionAwaitingFallbackResult, sessionFallbackTimeouts } = deps
@@ -184,22 +185,6 @@ export function createEventHandler(deps: HookDeps, helpers: AutoRetryHelpers) {
}
}
const normalizeRetryStatusMessage = (message: string): string =>
message
.replace(/\[retrying in [^\]]*attempt\s*#\d+\]/gi, "[retrying]")
.replace(/retrying in\s+[^(]*attempt\s*#\d+/gi, "retrying")
.replace(/\s+/g, " ")
.trim()
.toLowerCase()
const extractRetryAttempt = (statusAttempt: unknown, message: string): string => {
if (typeof statusAttempt === "number" && Number.isFinite(statusAttempt)) {
return String(statusAttempt)
}
const match = message.match(/attempt\s*#\s*(\d+)/i)
return match?.[1] ?? "?"
}
const handleSessionStatus = async (props: Record<string, unknown> | undefined) => {
const sessionID = props?.sessionID as string | undefined
const status = props?.status as { type?: string; message?: string; attempt?: number } | undefined