- [Claude Cowork Deep Compaction, Adaptive Desktop Patching & Zero-Diff Token Estimation] Break Context Window Exhaustion Bottlenecks, Implement Adaptive Recursive Patching, and Strictly Align with Official Tokenizer (PR #3580, PR #3582, Fixes #3576, Thanks to @cubelikeplayDaniel):
- Adaptive Recursive Traversal & Version Priority: Introduced
find_claude_apps_recursivelyto automatically penetrate nested random-hash subdirectories in newer Claude Desktop builds (e.g.2.1.286/f2326db61802/claude.app); coupled withparse_semverto prioritize official production instances over sandbox builds. - macOS System-Level Integrity & Safe Isolation: Resolved folder-permission crash issues after patching by verifying valid Bundle metadata (
Info.plist), preventing kernel crashes (tccd/syspolicyd); backups are strictly isolated in.deep_compact_backups/outside the App Bundle to preserve Gatekeeper seals; appliedchmod 0o755and recursive ad-hoc re-signing viacodesign --force --deep --sign -. - Alarm State Machine & 35k Active Context Diet: Eliminated hardcoded
num_msgs <= 10deadlocks, setting error target caps to 20k tokens to guide clients in trimming history while returning 200 OK; prioritized manual./compactdispatch with strict mutual locking against auto gates. - Token Estimation Canon Aligned with Official Specification: Reverse-engineered client-side token counting routines, pinning high-res images to 2000 tokens (small images 258); intercepted Base64 media inside
tool_resultto prevent inflated token counts; eliminated redundant safety margins, matching official/contextreadings. - Cross-Platform Parity & Type Safety (PR #3582): Hardened conditional compilation and type signatures for non-macOS platforms (Windows / Linux), eradicating platform isolation warnings and guaranteeing uniform cross-platform builds.
- Frontend UX & Progressive Decoupling (
AgentSettings.tsx): Replaced high-risk warnings with an elegant "Experimental" badge; introduced a two-step standard ModalDialog clarifying the boundary between switch-only mode and full patch mode, plus./compactguidance; kept fully opt-in with zero intrusion for default users. - Long-Term Architectural Specification (PR #3582): Shipped
docs/CLAUDE_COWORK_DEEP_COMPACT_SPEC.mdbased on official 50% thresholds (100k) and measured latency gains, covering end-to-end sequence flows, decompiler AST comparisons, physical offset and padding formulas, and obfuscation tracking scripts.
- Adaptive Recursive Traversal & Version Priority: Introduced
- [Claude Cowork 深度归档闭环、客户端自适应补丁与官方 Token 估算绝对对齐] 突破 Claude 桌面端上下文膨胀瓶颈,实现自适应版本穿透微创补丁与官方 0-diff 计词对齐 (PR #3580, PR #3582, Fixes #3576, Thanks to @cubelikeplayDaniel):
- 自适应递归穿透与版本优先探测: 引入
find_claude_apps_recursively,自动穿透新版 Claude 桌面端嵌套的随机 Hash 子目录(如2.1.286/f2326db61802/claude.app);结合parse_semver进行语义数值比较,确保正式生产环境实例优先于本地沙盒测试版本。 - macOS 系统级完整性与安全隔离机制: 彻底解决打补丁后请求文件夹权限闪退问题,严格校验合法 Bundle 元数据(防止沙盒缺失
Info.plist时请求权限导致tccd/syspolicyd内核强退);备份文件统一部署在 App Bundle 外部隔离目录.deep_compact_backups/,杜绝破坏 Gatekeeper 密封性;写入补丁后强制赋予chmod 0o755并执行codesign --force --deep --sign -递归重签名。 - 假报警状态机与 35k 活跃上下文瘦身: 废除硬编码
num_msgs <= 10判定死锁,将报错目标上限设定为 20k tokens,驱动客户端足额削减历史并回显 200;手动./compact穿透优先调度并与自动门禁机制绝对互锁。 - Token 算力法典与官方 0-diff 绝对对齐: 逆向对齐官方客户端底层计词调用链,多模态高分辨率图片统一固定折算为 2000 tokens(小图 258);在
tool_result中精准识别 Base64 媒体拦截,防止图片被误当纯文本虚增数万 tokens;剔除虚高安全余量,文本与紧凑工具 Schema 估算与官方/context完美拟合。 - 跨平台兼容与类型安全强化 (PR #3582): 针对非 macOS 平台(Windows / Linux),完善补丁扫描与路径探测的条件编译与类型标注,彻底消除平台隔离警告,确保全平台构建一致性。
- 前端交互与渐进式解耦架构 (
AgentSettings.tsx): 移除高危警告标签并标注为“实验性功能 (Experimental)”;引入双步标准 ModalDialog(说明“仅开开关原生折半”与“配合补丁深度瘦身至 35k 以下”的安全边界,并提供./compact极简使用指南);默认 Opt-in,保障全平台用户无感与零侵入。 - 长效架构规范白皮书 (PR #3582): 随版本沉淀永久技术架构文档
docs/CLAUDE_COWORK_DEEP_COMPACT_SPEC.md,基于官方 50% 门限(100k)与实测延迟优势全面阐释深度瘦身原理,涵盖完整时序图、反编译 AST 源码对比、物理偏移与等长填充公式及混淆定位脚本。
- 自适应递归穿透与版本优先探测: 引入
What's Changed
- fix(cowork): 健全深度归档链路、自适应客户端版本探测与官方 Token 估算对齐 by @cubelikeplayDaniel in #3580
- docs(cowork): 补充 Deep Compact 核心架构 RFC 与深度开发细节规范 by @cubelikeplayDaniel in #3582
New Contributors
- @cubelikeplayDaniel made their first contribution in #3580
Full Changelog: v4.9.1...v4.9.2-beta.1