fix(agent): include the compaction boundary message in the summary - #102
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
The kept tail starts at max_ctx-1, but the summary window stopped one message earlier, so that turn was deleted from the session and never summarized. Co-authored-by: esadrianno <esadrianno@gmail.com>
This branch has not been deployed
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.
Bug and impact
When a session grows past
max_context_messages, compaction deletes one persisted turn. That message is not included in the summary and is not kept in the tail, so a later load never sees it.With the default cap of 40, a session of 50 messages (
msg_0throughmsg_49) dropsmsg_10. The existing test only checked thatmsg_11survived, so the hole stayed green.Root cause
compact_session_via_llmsummarizesmsg_count - max_ctxmessages, then keepsmax_ctx - 1messages starting atmsg_count - (max_ctx - 1). Those ranges do not meet. Indexmsg_count - max_ctxis in neither, andsession_savewrites the gapped history.Fix
Summarize
msg_count - max_ctx + 1messages so the summary window ends where the kept tail starts. The stored session is still one summary plusmax_ctx - 1recent messages.Validation
make test_agentfailed on the new assertion (summarizer source must containmsg_10) before the fix and passes after it (test_agent: all tests passed).