Repository navigation
Compaction: carry plugin text verbatim; the summariser reads the retained tail - #14
Merged
Merged
Conversation
experimental.session.compacting now receives the messages a compaction takes out of the model's view and may return `carry` texts. Once the summary succeeds, each is stored as a synthetic text part on the compaction's user message: the model reads it before the summary from the auto-continue turn on, and no later summariser is shown it. DocuMentor uses this to keep its project files (PROJECT.md, MEMORY.md, the knowledge-base index, WORKSPACE.md), injected once per chat, verbatim across compactions instead of paraphrased by the summary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148RPMT9kUkZ6BL4TtebZJe
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
…stays in view The summariser was shown only the head, so anything that happened in the retained tail - a background task finishing, an action retried - left the summary stating the older state, contradicting the messages that follow it. It now also reads the tail, in <retained>, with the instruction not to summarise it and to write Work State and Next Move as the state after it. The compacting hook's `messages` are now the messages created before the tail starts. A tail can reach back past an earlier compaction message, which then stays in view; handing it to the hook carried its text twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148RPMT9kUkZ6BL4TtebZJe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes to compaction, both from production bug reports of 2026-10-22 (21:09) where a compacted mentor chat lost its project files and got a summary that contradicted the messages after it.
1. Carry.
experimental.session.compactingnow receivesmessages— the messages created before the retained tail starts, i.e. those leaving the model's view, in model order — and may returncarry: string[]. Once the summary succeeds, each carried text is stored as a synthetic text part (metadata.compaction_carry) on the compaction's user message. The model reads it before the summary from the auto-continue turn on, andcompletedCompactionsalready hides that message from every later summariser, so it is never paraphrased. A tail can reach back past an earlier compaction message, which then stays in view; it is not handed to the hook, so nothing is carried twice. DocuMentor's plugin (TheFabFab/KPG) carries its PROJECT.md, MEMORY.md, knowledge-base index and WORKSPACE.md blocks.2. The summariser reads the retained tail. It was shown only the head, so two helper results and a retried action that landed in the tail left the summary saying "two background tasks running, archive move failed".
buildPrompttakesretained; the prompt shows the tail in<retained>after the conversation, with the instruction not to summarise it and to write Work State and Next Move as the state after it.Tests
documentor: carries plugin text verbatim …(compaction.test.ts): stored, seen by the model before the summary, absent from the second summariser's input, handed to the second compaction's hook. Fails without the change.<conversation>and appears in<retained>.<retained>, not in<conversation>. The same run against a binary without this change fails the six carry checks.🤖 Generated with Claude Code
https://claude.ai/code/session_0148RPMT9kUkZ6BL4TtebZJe