4type FailedRec = { failedAt: number, classification: OrrErrClass } 6const runtimeFailedModels = new Map<string, FailedRec>() 9 classification === 'permanent' ? Infinity 10 : classification === 'rateLimit' ? 60_000 11 : 5 * 60_000 // transient | unknown 13export const markModelFailed = (modelId: string, classification: OrrErrClass = 'permanent') => { 14 const prev = runtimeFailedModels.get(modelId) 15 if (!prev) mcpDebugLog(`Model failed at runtime, will skip: ${modelId} (${classification})`) 16 runtimeFailedModels.set(modelId, {failedAt: Date.now(), classification}) 19export const isModelFailed = (modelId: string) => { 20 const rec = runtimeFailedModels.get(modelId) 21 if (!rec) return false 22 if (Date.now() - rec.failedAt >= ttlMsFor(rec.classification)) { 23 runtimeFailedModels.delete(modelId) 29export const getFailedModelInfo = (modelId: string) => runtimeFailedModels.get(modelId)