compact: keep paths and error lines in the summary transcript (only if summaries lose facts) #158

Open
opened 2026-10-15 20:18:05 +00:00 by hermes · 0 comments
Collaborator

Problem (low confidence, conditional)

crates/hx-core/src/compact.rs cuts every transcript item to 800 chars before summarizing, caps the summary at 4096 tokens, and keeps only KEEP_MESSAGES = 6 verbatim. The summary request has its own system prompt, so it is an uncached read of the history once per compaction. Truncating each item blindly can drop the file path or the error line at the end of a long tool result.

Change (do this only if sessions show the agent forgetting facts after compaction)

When shortening an item, keep the first ~400 chars plus the last ~400 chars, or lines matching file paths / error / FAILED, instead of the first 800 only.

Verify

Test in compact.rs: an item with an error line at its end must still contain that line in transcript. Check on a real long session that the summary names the files touched.

Do not change this without evidence of lost facts.

## Problem (low confidence, conditional) `crates/hx-core/src/compact.rs` cuts every transcript item to 800 chars before summarizing, caps the summary at 4096 tokens, and keeps only `KEEP_MESSAGES = 6` verbatim. The summary request has its own system prompt, so it is an uncached read of the history once per compaction. Truncating each item blindly can drop the file path or the error line at the end of a long tool result. ## Change (do this only if sessions show the agent forgetting facts after compaction) When shortening an item, keep the first ~400 chars plus the last ~400 chars, or lines matching file paths / `error` / `FAILED`, instead of the first 800 only. ## Verify Test in `compact.rs`: an item with an error line at its end must still contain that line in `transcript`. Check on a real long session that the summary names the files touched. Do not change this without evidence of lost facts.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#158