UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

37 lines (36 loc) • 2.05 kB
import { o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs"; import { d as isProviderRequestSizeCeilingError, f as isRateLimitErrorMessage, o as isBillingErrorMessage } from "./message-patterns-xrpp7Aip.mjs"; import { i as looksLikeProviderContextOverflowCandidate, n as isContextOverflowErrorFromTables, r as isReasoningConstraintErrorMessage, t as hasRateLimitTpmHint } from "./context-overflow-tables-CeoOZL8Z.mjs"; import { t as classifyProviderFailoverSignalWithPlugin } from "./provider-failover-lkD4o4u_.mjs"; import { matchesContextOverflowMessage } from "@openclaw/ai/internal/shared"; //#region src/agents/failover/provider-patterns.ts function classifyProviderPluginError(e) { const { providerPlugin: t, ...n } = e; if (t === null) return null; if (t) { const e = { ...n, provider: t.id }; if (t.matchesContextOverflowError?.(e)) return "context_overflow"; return t.classifyFailoverReason?.(e) ?? null; } return classifyProviderFailoverSignalWithPlugin({ provider: e.provider, context: n }) ?? null; } //#endregion //#region src/agents/failover/context-overflow.ts function isContextOverflowError(e) { if (!e) return false; return isContextOverflowErrorFromTables(e) || looksLikeProviderContextOverflowCandidate(e) && classifyProviderPluginError({ errorMessage: e }) === "context_overflow"; } function isLikelyContextOverflowError(e) { if (!e) return false; if (isProviderRequestSizeCeilingError(e)) return isContextOverflowErrorFromTables(e); if (hasRateLimitTpmHint(e) || isReasoningConstraintErrorMessage(e) || isBillingErrorMessage(e) || matchesContextOverflowMessage(e, "context-window-too-small") || isRateLimitErrorMessage(e)) return false; return isContextOverflowError(e) || !normalizeLowercaseStringOrEmpty(e).includes("prompt template") && !matchesContextOverflowMessage(e, "rate-limit-hint") && matchesContextOverflowMessage(e, "failover-hint"); } //#endregion export { isLikelyContextOverflowError as n, classifyProviderPluginError as r, isContextOverflowError as t };