Skip to content

bodhi-realtime-agent / computeCacheHitRatio

Function: computeCacheHitRatio() ​

computeCacheHitRatio(usage, source): number | undefined

Defined in: src/core/usage-helpers.ts:23

Provider-aware cache hit ratio. Returns cachedTokens / inputTokens ONLY when caching is known to be reported by that provider+source AND inputTokens > 0. In every other case (transcription, Gemini Live today, missing breakdown), returns undefined.

This avoids mislabeling "no signal" as a 0% cache hit. Dashboards can safely filter on cacheHitRatio !== undefined.

Parameters ​

usage ​

RealtimeLLMUsageEvent

source ​

RealtimeUsageSource

Returns ​

number | undefined

Built with VitePress