Repository navigation
fix(agent): stub oversized history only on an empty summary - #132
Closed
cursor[bot] wants to merge 1 commit into
Closed
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Compaction treated a truncated stub as the whole message. When earlier lines had already filled the 64 KiB summary source, a later message that cannot fit was cut to the leftover sliver and then dropped. Stub that line only on an empty source so this pass summarizes the prefix and the next pass keeps about 64 KiB of the oversized line. Co-authored-by: esadrianno <esadrianno@gmail.com>
Collaborator
|
Superseded by #133: consolidated into the operator-authored branch fix/agent-compaction-empty-stub (same fix, re-validated with make test_agent, CI=true make test, make static). Closing in favor of the consolidation. |
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.
Session compaction deleted most of an oversized message when earlier lines had already filled the 64 KiB summary source.
Bug and impact
compact_session_via_llmsummarizes the oldest turns once a session grows pastmax_context_messages. A single message larger than the 64 KiB summary source cannot be copied whole. The recent stub path still accepted that line when only a sliver of the buffer was free, then dropped it from the kept tail.Concrete trigger: an ASAP
task.requestwhoseinputis about 50 KiB, a short reply, then another task whose input is about 65 KiB, then enough short turns to exceed the default 40-message window. Both pastes fit in the 128 KiB session blob. Compaction summarized the first paste, cut the second to the leftover few kilobytes, andagent_persist_sessionwrote that result back. The rest of the second task was gone from the transcript and was never shown to the summarizer.Root cause
summary_source_append_truncatedreturns success whenever the role wrapper and the[truncated]marker fit in the remaining bytes. The caller treated that success as "this message is fully consumed." A later line that can never fit a fresh source was therefore deleted after the model had seen only the leftover sliver.Fix
Stub a never-fit line only when the summary source is still empty. Otherwise leave it in the session. This pass summarizes the prefix, and the next pass stubs the line against a full 64 KiB buffer. A never-fit first line is still stubbed, so compaction cannot stall with an empty source. Lines that would fit a fresh source keep the existing prefer-keep path.
Validation
make test_agentpasses. The updated later-line regression uses a 50 KiB predecessor and a 65 KiB message: after the first turn the oversized end marker is still in the session and the predecessor is not, and a later turn still brings the session back down to the context cap. The existing first-line oversized test still requires the empty-source stub.