Add deterministic snip compact for middle-history context reduction#22
Open
GateJustice wants to merge 1 commit intoLiuMengxuan04:mainfrom
Open
Add deterministic snip compact for middle-history context reduction#22GateJustice wants to merge 1 commit intoLiuMengxuan04:mainfrom
GateJustice wants to merge 1 commit intoLiuMengxuan04:mainfrom
Conversation
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.
Summary
为 MiniCode 新增 deterministic snip compact。Snip 会在 tool result storage / budget 处理之后、microcompact 之前运行,删除一段安全的旧中间历史区间,并在当前对话中插入
snip_boundary标记。Motivation
长会话中会积累较早的中间历史上下文,这些内容会持续占用 token budget,并可能导致系统过早进入 full compact。Snip compact 提供了一个保守的本地上下文清理步骤,可以在不调用模型的情况下缓解 context 压力。
Implementation
snip_boundarymetadata,用于记录被移除的 message ids、数量和大致释放的 tokens。removedMessageIds过滤被 snip 的消息,避免 reload 后旧消息重新出现。/snip命令支持。snip_boundary的兼容。Testing
npm run checknpm testnpm run lint --if-presentRisks / Notes
snip_boundary是内部上下文标记,不代表真实用户请求。part of #1