Skip to content

fix(agent): keep history that does not fit the summary - #108

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-104f
Closed

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

Conversation

@cursor

@cursor cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bug and impact

Session compaction deleted history that the summarizer never saw. After a long chat, a large earlier message (for example a pasted log) followed by a short one in the summarize window was removed from the session, and the summary was built only from the short line. That history is gone from sessions.messages.

Root cause

compact_session_via_llm walks the oldest messages into a 64 KiB summary source, but it still drops every message before the kept tail. When a line does not fit, snprintf leaves a partial line and the used length does not advance, so the next shorter line overwrites it. The long message is neither summarized nor kept.

Fix

Append a line only when the whole line fits, and roll back a partial write. If the summary source stops early, keep that message and everything after it. If nothing fits, leave the session unchanged.

Validation

make test_agent passes. The new regression builds a session whose second summarize-window message is 65 KiB and checks that BIG_MARKER_END!! remains after compaction while the short prefix is still summarized. Before the fix that test failed with compacted session dropped the message that did not fit the summary.

Open in Web聽View Automation聽

Compaction deleted every message before the kept tail even when the
summary source filled up first. A later short line replaced the
truncated long line, so that history was removed without being
summarized.

Co-authored-by: esadrianno <esadrianno@gmail.com>
@adriannoes

Copy link
Copy Markdown
Collaborator

Superseded by #121: consolidated with #102 into the operator-authored branch fix/agent-summary-compaction (same fixes, re-validated with make test_agent, CI=true make test, make static). Closing in favor of the consolidation.

@adriannoes adriannoes closed this Oct 16, 2026
@adriannoes
adriannoes deleted the cursor/high-severity-issues-104f branch October 16, 2026 03:00
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.

2 participants