Skip to main content

Module adaptive_compression

Module adaptive_compression 

Source
Expand description

Cache-aware compression decisions using provider billing economics (#1195).

Compression of an already-sent prompt prefix can turn cheap cache reads into cache writes. This module compares that penalty with the actual token reduction and chooses the candidate with the highest expected USD benefit.

Structs§

CandidateEconomics
CompressionCandidate
CompressionContext
CompressionDecision

Enums§

CompressionDepth

Functions§

decide
Compare candidates using all provider input token classes affected here.
predict_session_length
Deterministic session-length estimate used when no explicit forecast exists. Short sessions retain a small horizon; established long sessions reserve a further 50% of their current length for cache-reuse economics.
prefix_stability_score
Ratio of the previous prefix preserved at the start of the current prefix. Appending content is perfectly stable; a mutation near the front scores low.