Skip to content

fix(agent): include the compaction boundary message in the summary - #102

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-5d10
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-5d10

Conversation

@cursor

@cursor cursor Bot commented Sep 25, 2026

Copy link
Copy Markdown

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_0 through msg_49) drops msg_10. The existing test only checked that msg_11 survived, so the hole stayed green.

Root cause

compact_session_via_llm summarizes msg_count - max_ctx messages, then keeps max_ctx - 1 messages starting at msg_count - (max_ctx - 1). Those ranges do not meet. Index msg_count - max_ctx is in neither, and session_save writes the gapped history.

Fix

Summarize msg_count - max_ctx + 1 messages so the summary window ends where the kept tail starts. The stored session is still one summary plus max_ctx - 1 recent messages.

Validation

make test_agent failed on the new assertion (summarizer source must contain msg_10) before the fix and passes after it (test_agent: all tests passed).

Open in Web聽View Automation聽

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant