Token phase 3: mask old tool results, compact inside one long tool loop #106

Merged
hermes merged 1 commits from token-mask into main 2026-10-01 21:49:25 +00:00
Collaborator

Measured on a real 39-request session: 96% cache hit, but context grew to 72.8k tokens and tool results were 430k+111k resent tokens (bash/read).

  • mask::mask_old_results (applied to the request only; session file keeps originals): tool results >= 4000 bytes older than the last 8 assistant turns become [elided old tool result: <tool> <args> (N bytes); run the tool again if you need it]. The boundary moves in steps of 8 turns, so the masked prefix is byte-stable between requests and the prompt cache breaks once per 8 turns, not every turn.
  • Agent::compact can now cut inside a tool loop (no user prompt to cut at): cuts before an assistant message, summary becomes its own leading user message, tool_use/tool_result pairs stay intact. Removes the old ponytail limitation.
  • Tests: masking steps/stability/small-result exemption; compaction inside a tool loop. tests/all.sh green. Compare with hx stats before/after on a comparable session.
Measured on a real 39-request session: 96% cache hit, but context grew to 72.8k tokens and tool results were 430k+111k resent tokens (bash/read). - `mask::mask_old_results` (applied to the request only; session file keeps originals): tool results >= 4000 bytes older than the last 8 assistant turns become `[elided old tool result: <tool> <args> (N bytes); run the tool again if you need it]`. The boundary moves in steps of 8 turns, so the masked prefix is byte-stable between requests and the prompt cache breaks once per 8 turns, not every turn. - `Agent::compact` can now cut inside a tool loop (no user prompt to cut at): cuts before an assistant message, summary becomes its own leading user message, tool_use/tool_result pairs stay intact. Removes the old ponytail limitation. - Tests: masking steps/stability/small-result exemption; compaction inside a tool loop. tests/all.sh green. Compare with `hx stats` before/after on a comparable session.
hermes added 1 commit 2026-10-01 21:45:23 +00:00
tokens: mask old large tool results in requests; compact inside a single long tool loop
ci / check (pull_request) Canceled after 0s
ci / check (push) Canceled after 0s
80c0f83a68
hermes merged commit fe308e0f36 into main 2026-10-01 21:49:25 +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#106