fix: add hysteresis to message-count compaction - #582
Open
JiangYuxin-Jim wants to merge 1 commit into
Open
JiangYuxin-Jim wants to merge 1 commit into
JiangYuxin-Jim wants to merge 1 commit into
Conversation
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.
Closes #581.
When
snip_compacttrims a history back to the same 50-message threshold that triggers it, each subsequent exchange can cause another full transcript write before the next model call. Separate the trigger and target so normal compaction leaves room for new messages.Changes
trigger_messages=50andtarget_messages=30; trigger when the history reaches 50 messages, including when a batch overshoots it.5 <= target_messages < trigger_messagesso the target includes at least one recent message and leaves headroom.Tradeoffs
This keeps fewer recent messages directly in context (26 instead of 46), with older content available from the transcript. The defaults are a proposal for maintainer review. The existing active-request retention concern in #577 remains relevant when trimming more history; this PR does not attempt to solve that separate issue. Callers using the old
max_messageskeyword should now passtrigger_messagesandtarget_messages; the in-repository call sites and tests are updated.Validation
py311environment:python -m pytest tests -q— 485 passed, 112 subtests passed.npx tsc --noEmit— passed.npm run build— passed; 118 static pages generated.git diff --check— passed.AI assistance: OpenAI Codex assisted with the implementation, regression tests, documentation, verification, and PR preparation, based on the contributor's observation of repeated compaction at the message threshold.