Repository navigation
Keep compaction boundaries aligned with raw user text - #335
Merged
Merged
Conversation
strip_compaction_preambles used rfind on the orchestrator QUERY wrapper and then sliced at the first blank line after any leading '['. User turns that embed that delimiter or start with a bracket block stored a truncated boundary, so remap after reload failed open (full history plus summary). Strip only known OPEN TODOS / KNOWN PITFALLS / INTENT envelopes and take the first QUERY wrapper so the persisted boundary matches the SQLite row. Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
This was referenced Sep 13, 2026
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_71576940-fe63-41f0-9889-aaf1e1be5c92) |
tylerreckart
enabled auto-merge (squash)
September 21, 2026 13:30
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Problem
strip_compaction_preamblesstored the compaction cut boundary so remap after API/TUI reload can find the first kept turn in SQLite. Two strips were too greedy:rfind("\n\nQUERY: ")took the last orchestrator wrapper. A user turn that embeds that same delimiter (for example quoting docs) stored only the suffix. The DB row still has the full user text, sofind_compaction_boundarymisses andremap_compaction_onto_historyfail-opens (covered_until=0: summary plus the entire hydrated history).[+ first blank line was treated as a pitfalls/intent envelope. User text that starts with a bracket block ([NOTE]\n\n…) or a[KNOWN PITFALLS]lesson body that contains\n\nwas truncated the same way.Transcript replay already documents the user-typed
QUERY:case; compaction did not.Fix
Strip only known orchestrator envelopes:
[OPEN TODOS]…[END OPEN TODOS][KNOWN PITFALLS…[END KNOWN PITFALLS]\n\nQUERY:wrapper (index master)[INTENT]… through the following blank line (specialist ingress)Do not
rfindthe QUERY mark and do not treat arbitrary[+\n\nas a preamble.Tests
unit_context_compaction— embedded QUERY delimiter, user text starting with[plus an inner-blank pitfalls block, specialist INTENT-only strip, remap of the embedded-QUERY boundary. 30/30 passed locally.Independently mergeable against
main(0456350). Code hunks (context_compaction.cpp,test_context_compaction.cpp) do not overlap #321–#334. CHANGELOG[Unreleased]will need a rebase after whichever sibling merges first.Note
Medium Risk
Changes how compaction boundaries are derived from stored user messages; incorrect stripping would still fail-open to full history, but wrong cuts could affect context windows after session reload.
Overview
Fixes compaction boundary stripping so stored cut points still match SQLite after reload.
strip_compaction_preamblesno longer usesrfindon\n\nQUERY:(first wrapper only) and no longer treats any leading[block before a blank line as orchestrator junk. It now removes only known envelopes:[OPEN TODOS],[KNOWN PITFALLS], the index\n\nQUERY:prefix, and a leading[INTENT]block. User turns that quote\n\nQUERY:or start with[NOTE]-style text keep full content, soboundary_content_matches/remap_compaction_onto_historydo not fail-open tocovered_until=0.Unit tests cover embedded QUERY, bracket user text, INTENT-only strip, and remap with an embedded-QUERY boundary; CHANGELOG documents the fix.
Reviewed by Cursor Bugbot for commit b236841. Bugbot is set up for automated code reviews on this repo. Configure here.