Files
hermes-agent/agent
kshitij 469296c748 refactor(compression): tighten the oversized-turn exception after review
Review findings folded into the exception added by the previous commit:

- The anchored-region check now reuses `_walk_tail_budget` instead of a
  second token sum with the default thought-charge rule. The walk charges
  thinking only on the newest assistant turn unless the route replays stale
  thinking (#73624/#84371), so the second rule could fire the exception on a
  region the walk itself considers inside the ceiling.
- Two conjuncts (`last_user_idx >= head_end`, `last_user_idx < cut_idx`) are
  implied by `user_anchored_cut < cut_idx`, which only changes when the
  anchor found a real user turn inside the compressible region; the check
  that depended on them is documented where it is read.
- The latest-assistant anchor is no longer computed and discarded under the
  exception (it also logged an anchor it never applied).
- `_find_last_user_message_idx` early-exits instead of materialising every
  actionable user index on the per-attempt boundary path.
- The exception logs at debug, like the sibling anchor decisions, rather
  than at info from both `_compress_window` and `has_content_to_compress`.

Adds the missing guard test for the new ceiling check: a transcript that
fits the tail budget must still anchor the active request rather than
triggering the exception. Red when the ceiling conjunct is removed.
2026-09-19 21:12:46 +05:30
..
…