Skip to content

About

Command Code mod that puts cache hit ratio and decode throughput in the footer.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmd-footer

Command Code mod that puts cache hit ratio and decode throughput in the footer, next to the input panel.

The footer segment looks like:

cache last 99.5% | avg 97.8% | 250 t/s
Segment Meaning
cache last Cache hit ratio of the last request: cache reads over prompt tokens
avg Session-wide ratio, weighted by tokens rather than averaged per request
t/s Decode rate of the last reply: output tokens over the stream window

cache last turns red when a request re-billed tokens that should have been cache reads, even when the ratio still looks healthy. A 99% request that re-reads 3k tokens shows red, because those tokens cost full price.

Type /cache for the detailed line: token counts, request count, decode rate, and whether the last turn re-billed.

Install

cmd mods add npm:@iaziz786/cmd-footer

Or try it without installing:

cmd --mod ./src/cmd-footer.ts

How the numbers are measured

Cache ratio. cacheReadTokens / inputTokens. The AI SDK reports inputTokens as the whole prompt, with cache reads and writes already inside it, so the ratio is the cached share of that total.

Decode rate. Output tokens over the span from the first streamed delta to the end of the response, so the wait for the first token is excluded. Three conditions make a measurement untrustworthy and the previous reading is kept instead:

  • fewer than 4 stream deltas, or a window shorter than 300ms: delivery could not be observed as a stream
  • a rate above 400 t/s: a proxy buffered the reply and flushed it in one burst, which compresses the window and invents impossible throughput

Miss detection. A request re-billed when the prompt of the previous request was not read back from cache. Re-bills at or below 1024 tokens are treated as cache breakpoint granularity noise. A compaction clears the baseline, so freshly compacted content is not mistaken for a re-bill. Providers that never report caching never show a miss.

The flag covers the whole run rather than a single request, because one prompt can take several model calls and an early call can miss while the last one hits.

Tuning

The thresholds are exported constants in src/cmd-footer.ts:

Constant Default Effect
MAX_PLAUSIBLE_RATE 400 Raise it on faster hardware, or the rate stops updating
MISS_NOISE_FLOOR_TOKENS 1024 Lower it to flag smaller re-bills
MIN_RATE_SPAN_MS 300 Shortest window that can resolve a rate
MIN_RATE_CHUNKS 4 Fewest deltas that count as a stream

Persistence

Totals survive /reload and resuming a session. One entry per run is written through the session API, so a restored session continues its average instead of starting over. A new session starts at zero.

Develop

bun test

Publish

Publishing runs on version tags. The tag must match package.json.

npm version patch
git push --follow-tags

About

Command Code mod that puts cache hit ratio and decode throughput in the footer.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages