- [Cowork Auto-Compaction Decoupling, Binary Pruning Trap Bypass & Context Residual Cleanup] (PR #3615, Fixes #3614, Thanks to @cubelikeplayDaniel):
- Precise Cowork vs Code Mode Decoupling: Removed false-veto rules on generic CLI headers (
x-app: cli,x-claude-code-session-id) and wrapper host headers (claude-desktop-3p), resolving missed Cowork compactions in Claude Desktop; tightened Code mode detection strictly tomcp__ccd_*tools and"You are Claude Code"prompt markers. (Thanks to @cubelikeplayDaniel) - Bypass Client Binary Halving Fallback Trap: Identified the decompiled client
CHtfallback where large token gaps triggerMath.floor(n / 2)(preserving 277 turns / 145.7k tokens); introducedcalculate_cowork_pruning_targetwith a calibrated positive gap (+500 tokens) to bypass halving and compel full history summary down to baseline. (Thanks to @cubelikeplayDaniel) - Remove Lifetime Continuation Exemption Deadlock: Eliminated hardcoded
!is_continuation_detectedgate exemption, fixing the issue where a session remained exempt forever once"This session is being continued..."was injected, swelling to 320k+. (Thanks to @cubelikeplayDaniel) - 180s Streaming Timeout Guard: Extended summary distillation timeouts to 180s to prevent network disconnects during heavy context compression. (Thanks to @cubelikeplayDaniel)
- Precise Cowork vs Code Mode Decoupling: Removed false-veto rules on generic CLI headers (
- [Full-Chain Compaction Signature Stripping, Experimental Global Strip & Tri-Scheme Anti-Resurrection Shield] (PR #3615, Fixes #3614, Thanks to @cubelikeplayDaniel):
- Physical Cache Invalidation on Compaction: Connected
clear_session_for_compactionacross Claude handler lifecycles to physically flush RAMThinkingStore, SQLiteproxy_db, andSignatureCache, eliminating pre-compaction stale signature leaks. (Thanks to @cubelikeplayDaniel) - Protocol-Differentiated Sentinel Isolation: Compaction history locks Gemini tool calls with official bypass sentinels (
skip_thought_signature_validator), while strictly stripping signatures for Claude targets (downgrading thoughts to<think>text) without inventing sentinels, eliminating 400 validation failures. (Thanks to @cubelikeplayDaniel) - New Experimental Toggle for Global Compaction Stripping: Added
enable_global_compaction_stripin Thinking Budget settings, default disabled for 100% normal user non-interference; when enabled, applies client-agnostic and protocol-agnostic protection. - Tri-Scheme Coordinated Anti-Resurrection Architecture: Coordinates macro watermark drop detection (purges caches and defines boundary on context collapse), micro folding detection (flags
[Output truncated],[Result omitted]in-place prunings), and anti-resurrection shields (suppressesinitial_session_sigand blocks Phase 3/4 fuzzy text matching).
- Physical Cache Invalidation on Compaction: Connected
- [Cowork 自动压缩触发与判定解耦、规避二分修剪保底并封堵上下文残留] (PR #3615, Fixes #3614, Thanks to @cubelikeplayDaniel):
- 精确解耦 Cowork 与 Code 模式判定: 消除对通用 CLI 标头(
x-app: cli/x-claude-code-session-id)及第三方宿主外壳标头(claude-desktop-3p)的一票否决,彻底解决 Claude Desktop 原生 Cowork 请求被误杀为 Code 模式导致漏拦截的问题;严格收敛 Code 模式判定为mcp__ccd_*专属工具或"You are Claude Code"声明。 (Thanks to @cubelikeplayDaniel) - 规避客户端二分保底与深度压缩调优: 针对客户端
CHt倒算算法中大 Gap 触发Math.floor(n / 2)导致保留 277 条历史残留 145.7k tokens 的问题,新增calculate_cowork_pruning_target抛出微小正向差额(500 tokens),跳过客户端折半保底陷阱,促使客户端将历史轮次深度打包摘要压缩至基线水位。 (Thanks to @cubelikeplayDaniel) - 移除静态接续标记终身免死租约: 移除门禁硬编码的
!is_continuation_detected,解决 Cowork 会话在首次压缩后因首条消息永久留存"This session is being continued..."导致后续轮次获得终身免死、暴涨至 320k 均不再被拦截的严重缺陷。 (Thanks to @cubelikeplayDaniel) - 长流摘要 180s 超时保护: 为摘要生成请求配置 180s 延长超时保护,防止复杂工程长上下文摘要提炼时因网络波动异常断流。 (Thanks to @cubelikeplayDaniel)
- 精确解耦 Cowork 与 Code 模式判定: 消除对通用 CLI 标头(
- [压缩全链路签名治理、试验性全局压缩剥离与三案联动防复活机制] (PR #3615, Fixes #3614, Thanks to @cubelikeplayDaniel):
- 全链路物理清库调用与生命周期回收: 在 Claude 消息流生命周期与摘要生成处补齐
clear_session_for_compaction物理调用,确保会话压缩时 RAMThinkingStore、SQLiteproxy_db与SignatureCache真正被级联清空,杜绝失效旧签名穿透残留。 (Thanks to @cubelikeplayDaniel) - 协议差异化出站哨兵隔离: 针对压缩历史轮次,Gemini 缺失签名的工具调用统一以官方哨兵
skip_thought_signature_validator锁定防止 400 校验报错;Claude 目标彻底剥离签名(思考正文降级为<think>纯文本出站),严禁向 Claude 发明 Gemini 哨兵,保证多模型全协议兼容。 (Thanks to @cubelikeplayDaniel) - 新增「全局压缩剥离签名」试验性开关: 在思维预算设置中新增
enable_global_compaction_strip开关,默认保持关闭(100% 保持既有行为与普通用户零干扰);开启后全局生效,扩展为协议无关、客户端无关的通用压缩防护。 - 三案联动防复活架构: 开启后联动执行宏观高水位线检测(字符量/轮次断崖暴跌时物理清库并划定治理边界)、微观就地折叠检测(识别
[Output truncated]、[Result omitted]等定向隔离受污染历史)与防复活屏障(在finalize中彻底压制initial_session_sig回填,并在restore中先划定边界再加载记录,杜绝 Phase 3/4 模糊前缀匹配复活)。
- 全链路物理清库调用与生命周期回收: 在 Claude 消息流生命周期与摘要生成处补齐
What's Changed
- fix(proxy): 修复 Cowork 自动压缩触发与判定解耦,排查压缩后上下文残留 (Ref #3614) by @cubelikeplayDaniel in #3615
Full Changelog: v4.9.7-beta.0...v4.9.7-beta.1