pi-cache-optimizer 2.5.4 → 2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +7 -4
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -3411,6 +3411,13 @@ function buildLowHitDiagnosis(
|
|
|
3411
3411
|
const hasRouterRisk = routerNotes.length > 0;
|
|
3412
3412
|
const hasUsageMissing = missingUsageSamples > 0;
|
|
3413
3413
|
|
|
3414
|
+
// Today's cached-token ratio is used both inside and outside the recent-sample
|
|
3415
|
+
// branch. Keep it block-external so doctor/stats never throw for low-hit
|
|
3416
|
+
// models that have persisted counters but no recent in-memory samples.
|
|
3417
|
+
const todayHitRatio = todayStats.totalInputTokens > 0
|
|
3418
|
+
? Math.round((todayStats.cachedInputTokens / todayStats.totalInputTokens) * 100)
|
|
3419
|
+
: 0;
|
|
3420
|
+
|
|
3414
3421
|
// Determine if there are actual issues worth flagging
|
|
3415
3422
|
const hasActualIssues = hasMissingCompat || hasUsageMissing ||
|
|
3416
3423
|
// Low hit trend (today total > 3 and hit ratio < 30%)
|
|
@@ -3451,10 +3458,6 @@ function buildLowHitDiagnosis(
|
|
|
3451
3458
|
// Priority 4: recent trend low
|
|
3452
3459
|
if (recent10Total > 0) {
|
|
3453
3460
|
const hitRatio = recent10Input > 0 ? Math.round((recent10Cached / recent10Input) * 100) : 0;
|
|
3454
|
-
const todayHitRatio = todayStats.totalInputTokens > 0
|
|
3455
|
-
? Math.round((todayStats.cachedInputTokens / todayStats.totalInputTokens) * 100)
|
|
3456
|
-
: 0;
|
|
3457
|
-
|
|
3458
3461
|
if (recent10Hits === 0 && todayStats.totalRequests > 3 && todayHitRatio < 30) {
|
|
3459
3462
|
lines.push(`📉 Cache hit rate is low: ${todayHitRatio}% today (${recent10Total} recent samples).`);
|
|
3460
3463
|
lines.push(" Likely causes: proxy routing to different backends per request,");
|
package/package.json
CHANGED