Skip to content

fix(agent): keep prior digests verbatim across compaction; document the limit#4082

Merged
esengine merged 1 commit into
main-v2from
fix/compaction-keep-summaries
Jun 12, 2026
Merged

fix(agent): keep prior digests verbatim across compaction; document the limit#4082
esengine merged 1 commit into
main-v2from
fix/compaction-keep-summaries

Conversation

@esengine

Copy link
Copy Markdown
Owner

Follow-up to #4048/#4052. Two parts: a robustness fix and an honest doc of the limit.

Keep prior digests verbatim

A compaction digest was eligible to be re-summarized by the next fold (partitionFold only kept user turns; digests went into the foldable set, and the summary was built from the whole region). So a fact a digest had already captured could be dropped to summary-of-summary drift on the next fold.

Now partitionFold keeps prior digests verbatim too, and the new digest summarizes only the foldable work (summarize(fold), not the whole region). Digests accumulate (each small) instead of collapsing into one lossy rolling summary, so a fact that reached a digest once is not lost to re-folding.

TestCompactKeepsPriorDigests covers it (verified it fails without the change).

Document the limit (SPEC 3.6)

We chased "facts the user said get forgotten" to ground. The guarantees, now written down:

  • a fact stated in a normal-sized turn is kept verbatim, never summarized away, across any number of folds;
  • a fact a digest captured is likewise kept (this PR);
  • best-effort only for a fact buried inside a single oversized message (a large paste over the per-turn pin budget) — it folds with the rest, so survival depends on the summarizer catching it while compressing bulk.

There is no reliable way to auto-detect an arbitrary fact in bulk (keyword matching is fragile intent-detection; the summarizer drops needles; full-verbatim doesn't fit the window with multiple large pastes), so the doc tells users to state durable facts in their own turn. The raw oversized content is archived and recoverable either way.

go test ./internal/agent/... green.

…he limit

A compaction digest was eligible to be re-summarized by the next fold, so a
fact it had captured could be dropped to summary-of-summary drift. Keep prior
digests verbatim alongside the kept user turns and summarize only the new
foldable work; digests accumulate (small) instead of collapsing into one lossy
rolling summary.

Document the guarantee in SPEC 3.6: a fact stated in a normal turn, and a fact a
digest captured, survive any number of folds; a fact buried inside a single
oversized message stays best-effort — there is no reliable way to auto-detect an
arbitrary fact in bulk, so durable facts belong in their own turn.
@esengine esengine requested a review from SivanCola as a code owner June 12, 2026 01:13
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development agent Core agent loop (internal/agent, internal/control) labels Jun 12, 2026
@esengine esengine merged commit 1930008 into main-v2 Jun 12, 2026
14 checks passed
@esengine esengine deleted the fix/compaction-keep-summaries branch June 12, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant