diff --git a/src/liveWatcher.ts b/src/liveWatcher.ts index c3f6619..3139731 100644 --- a/src/liveWatcher.ts +++ b/src/liveWatcher.ts @@ -391,7 +391,7 @@ export class LiveWatcher { }): void { if (!this.isWatcherActive) return; const entry = this.buffer.find(e => e.id === params.requestId); - if (!entry) return; + if (!entry || (entry.endTime !== undefined && entry.status === 'completed')) return; entry.endTime = Date.now(); entry.durationMs = entry.endTime - entry.startTime; @@ -426,7 +426,7 @@ export class LiveWatcher { public cancelRequest(requestId: string): void { if (!this.isWatcherActive) return; const entry = this.buffer.find(e => e.id === requestId); - if (!entry) return; + if (!entry || entry.endTime !== undefined) return; entry.endTime = Date.now(); entry.durationMs = entry.endTime - entry.startTime; diff --git a/src/revolverEngine.ts b/src/revolverEngine.ts index 2af74c6..ddc9525 100644 --- a/src/revolverEngine.ts +++ b/src/revolverEngine.ts @@ -627,7 +627,9 @@ export class RevolverEngine { // If we reached here, all tiers and all candidates failed cleanupTimers(); if (onFailure) onFailure('all_tiers_exhausted'); - const finalErrorMessage = lastError ? lastError.message : 'All model tiers and provider keys are exhausted or rate-limited.'; + const finalErrorMessage = lastError?.cause?.message + ? `${lastError.message}: ${lastError.cause.message}` + : (lastError ? lastError.message : 'All model tiers and provider keys are exhausted or rate-limited.'); const journey: RequestFallbackJourney = { requestId, @@ -673,6 +675,7 @@ export class RevolverEngine { })); res.end(); } else { + res.setHeader('Cache-Control', 'no-cache, no-transform'); res.status(503).json({ error: { message: `[Revolver Fallback Error]: ${finalErrorMessage}`,