61083d499d
Bug fixes: 1. OAuth token refresh (#3149): buildHttpRequestInit() now attempts silent refresh via refresh_token before triggering full browser re-auth. Added refresh() method to McpOAuthProvider. Includes test isolation fix for discovery mock. 2. Quota error STOP (#3126): Added STOP_MESSAGE_PATTERNS in model-error-classifier that take precedence over RETRYABLE_MESSAGE_PATTERNS. Message-only quota errors now non-retryable. Runtime-fallback: quota_exceeded with 'retrying in' signal still triggers fallback (provider-managed auto-retry). Restored removed patterns. 3. Compaction loop (#3127): MAX_RECOVERY_ATTEMPTS=3 cap + additional suppression guard from opencode session in degradation monitor. Also: refactored extractAutoRetrySignal to auto-retry-signal.ts, new regression tests for quota classifier and compaction degradation monitor.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
export interface AutoRetrySignal {
|
|
signal: string
|
|
}
|
|
|
|
const AUTO_RETRY_PATTERNS: Array<(combined: string) => boolean> = [
|
|
(combined) => /retrying\s+in/i.test(combined),
|
|
(combined) =>
|
|
/(?:too\s+many\s+requests|quota\s+will\s+reset\s+after|quota\s*exceeded|usage\s+limit|rate\s+limit|limit\s+reached|all\s+credentials\s+for\s+model|cool(?:ing)?\s*down|exhausted\s+your\s+capacity)/i.test(combined),
|
|
]
|
|
|
|
export function extractAutoRetrySignal(info: Record<string, unknown> | undefined): AutoRetrySignal | undefined {
|
|
if (!info) return undefined
|
|
|
|
const candidates: string[] = []
|
|
|
|
const directStatus = info.status
|
|
if (typeof directStatus === "string") candidates.push(directStatus)
|
|
|
|
const summary = info.summary
|
|
if (typeof summary === "string") candidates.push(summary)
|
|
|
|
const message = info.message
|
|
if (typeof message === "string") candidates.push(message)
|
|
|
|
const details = info.details
|
|
if (typeof details === "string") candidates.push(details)
|
|
|
|
const combined = candidates.join("\n")
|
|
if (!combined) return undefined
|
|
|
|
return AUTO_RETRY_PATTERNS.some((test) => test(combined)) ? { signal: combined } : undefined
|
|
}
|