Repository navigation
feat(context): 压缩级联两级升级——micro-prune 本地微裁剪 + proactive 阈值压缩 - #399
Merged
Merged
Conversation
参考 deer-flow/ZCode/OpenHarness/dsh 四个成熟 harness 的压缩体系(全都有 阈值主动层 + 本地廉价层,Minis 原先只有溢出后 reactive 一层),把压缩升级 为级联: Tier-① micro-prune(ChatHistoryMicroPrune.kt,纯函数,请求时投影): - 触发:usage ≥ 0.60×window;低于触发点历史原样透传(字节稳定保前缀缓存) - 白名单工具(shell_execute/web_fetch/web_search/browser_use/execute_code/ grep_source,经 ToolAliases.canonical 匹配别名)的旧 ToolResult 文本瘦身为 head+标记+tail;file_read 刻意排除(锚定 edit 读态) - 保最近 4 个可裁剪载体 verbatim;tool_use/tool_result 配对与 part 结构不动 - 幂等:已裁内容带稳定标记直接透传(二次切片会把旧标记嚼进新头部) - 纯请求时投影——持久化历史字节不变 Tier-② proactive compact(maybeProactiveCompact,每轮 pre-step 检查): - usage ≥ 0.80×window 时在构建下一请求前跑全量压缩,不再为必然溢出的 整轮请求买单;reactive 溢出层保留作兜底 - 会话键控读数(lastKnownContextUsage pair)防跨会话误触发;压缩即清零 读数=天然防抖 cap;复用 awaitCompaction + 既有压缩中提示文案 顺带抽取:awaitCompaction 从 ChatViewModel 移至 ChatViewModelCompactExt (架构上限),ChatViewModel 基线随之下调。 验证:新增 ChatHistoryMicroPruneTest 7 用例(触发门控/白名单/别名/结构/ 幂等/短文本/阈值边界);全量 6716 测试 0 失败(2 个环境性回环失败单跑 复现即过);9 门禁全绿(ChatViewModel 基线按 ratchet 下调)。
tall-1997
force-pushed
the
fix/compaction-cascade
branch
from
November 18, 2026 18:03
bb2fba4 to
f985274
Compare
tall-1997
added a commit
that referenced
this pull request
Nov 19, 2026
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.
参考 deer-flow / ZCode / OpenHarness / deepseek-harness 四个成熟 harness 的压缩体系研究成果(四家都有「阈值主动层 + 本地廉价层」,本项目原先只有溢出后 reactive 一层),把上下文压缩升级为级联:
Tier-① micro-prune(本地微裁剪,纯请求时投影)
Tier-② proactive compact(阈值主动压缩)
顺带抽取
awaitCompaction 从 ChatViewModel 移至 ChatViewModelCompactExt(架构上限),ChatViewModel 基线按 ratchet 下调。
验证