Masking: move the boundary rarely (context > compact_at/3), record it per request #110

Merged
hermes merged 1 commits from mask-hysteresis into main 2026-10-01 22:36:24 +00:00
Collaborator

Measured on a 93-request session after #106: 7 of the 8 largest cache writes sat exactly 8 turns apart (requests 17,25,...,73), each re-writing the whole history (reads 3295 = prefix only), ~345k extra write tokens vs ~1.4M fewer read tokens. A boundary change rewrites the cache from the first changed result on, so stepping every 8 turns costs more than it saves at these context sizes.

  • Agent keeps mask_boundary; it only moves forward, and only when the estimated target boundary moved AND the context is above compact_at / 3. Below that, no masking at all (no cache breaks). Reset on session replace / fork / clear / compaction.
  • mask_old_results(msgs, boundary) is now a pure function of the boundary; target_boundary keeps the 8-turn rule as the target.
  • The boundary used is stored on each assistant session entry (mask); hx stats replays exactly that (older files: stepwise rule).
  • Tests: no masking below the threshold, boundary monotone and recorded above it, no compaction side effects.

The /3 factor is a guess; re-check the cache-write outlier list in hx stats after the next long session.

Measured on a 93-request session after #106: 7 of the 8 largest cache writes sat exactly 8 turns apart (requests 17,25,...,73), each re-writing the whole history (reads 3295 = prefix only), ~345k extra write tokens vs ~1.4M fewer read tokens. A boundary change rewrites the cache from the first changed result on, so stepping every 8 turns costs more than it saves at these context sizes. - `Agent` keeps `mask_boundary`; it only moves forward, and only when the estimated target boundary moved AND the context is above `compact_at / 3`. Below that, no masking at all (no cache breaks). Reset on session replace / fork / clear / compaction. - `mask_old_results(msgs, boundary)` is now a pure function of the boundary; `target_boundary` keeps the 8-turn rule as the target. - The boundary used is stored on each assistant session entry (`mask`); `hx stats` replays exactly that (older files: stepwise rule). - Tests: no masking below the threshold, boundary monotone and recorded above it, no compaction side effects. The `/3` factor is a guess; re-check the cache-write outlier list in `hx stats` after the next long session.
hermes added 1 commit 2026-10-01 22:35:49 +00:00
hermes merged commit 4b343aa786 into main 2026-10-01 22:36:24 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#110