You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
compaction: idle cache-lapse guard so deep-ride never spikes the price
Deep-ride (95%) is cheap only while the prompt cache holds the prefix.
The one case it would cost you: ride a 1M window to 950k, walk away past
the cache TTL (~1h), and the next message re-prices all 950k at full
input rate. That's the "price went up" case.
Fix: a bounded, idle-only pre-compaction. StreamState stamps last_wire_at
on every stream start; the Tick handler (update/meta.cpp), while idle and
not already compacting, calls should_compact_on_idle() — which fires a
compaction only when the prefix is large (>= 200k) AND we've been idle
~48 min (80% of the 1h TTL). The summary runs while the prefix is still a
warm cache hit, so the user returns to a small warm context instead of
eating a cold full re-price.
Bounded to large + near-TTL-idle so ordinary pauses never trip it and
active work still rides to 95% — no early compaction during a live
session. Net: deep context retention with no price spike, ever.
Tests cover should_compact_on_idle (fires only on large prefix +
near-TTL idle; never before the first request; never on short idle even
with a huge prefix). ARCHITECTURE.md updated. Full compaction/stream/
persist/palette test group green (8/8).
0 commit comments