fix(core): preserve managed memory during microcompaction - #6733
fix(core): preserve managed memory during microcompaction#6733destire-mio wants to merge 3 commits into
Conversation
|
Thanks for the PR! Template looks good ✓ Problem: This is a well-documented, observed bug. Linked issue #6713 provides clear reproduction steps (create managed memory → read it → trigger microcompaction → marker disappears), and our own triage confirmed the root cause in Direction: Aligned. Managed memory is a durable context mechanism — if its content gets silently cleared by microcompaction, the feature is broken. This fix directly addresses the identified gap. CHANGELOG doesn't have a direct entry for this, but the memory system is a core product feature and preserving it across compaction is clearly necessary. Size: 53 production lines + 130 test lines across 5 files (client.ts: 2 prod, geminiChat.ts: 2 prod, memoryPressureMonitor.ts: 19 prod, microcompact.ts: 35 prod, microcompact.test.ts: 130 test). Small, focused change. Core paths touched — well within the safe zone. Approach: The scope feels exactly right. The fix is what our triage suggested as option 1: exempt memory-path reads from microcompaction by checking file paths with the existing Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 问题:这是一个有详细记录的已观测 bug。关联 issue #6713 提供了清晰的复现步骤(创建受管理记忆 → 读取 → 触发微压缩 → 标记消失),我们自己的 triage 也确认了 方向:对齐。受管理记忆是可持续上下文机制——如果其内容被微压缩悄悄清除,该功能就失效了。此修复直接解决了已识别的缺口。CHANGELOG 中没有直接对应条目,但记忆系统是核心产品功能,在压缩过程中保留它是明确必要的。 规模:53 行生产代码 + 130 行测试代码,跨 5 个文件(client.ts: 2 行生产, geminiChat.ts: 2 行生产, memoryPressureMonitor.ts: 19 行生产, microcompact.ts: 35 行生产, microcompact.test.ts: 130 行测试)。小而聚焦的改动。触及核心路径——在安全范围内。 方案:范围恰到好处。修复方案与我们 triage 建议的选项 1 一致:通过已有的 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewThe core logic is clean and correct. The fix threads However, there's a regression: 3 existing tests in Fix is straightforward — add Test Resultsmicrocompact.test.ts — 59/59 passed ✅All 3 new managed-memory tests pass: memoryPressureMonitor.test.ts — 3 failed / 69 passed ❌Root cause: TypeCheck — passed ✅Real-scenario testingMicrocompaction of managed memory is inherently a multi-turn behavior — it cannot be meaningfully triggered in 中文说明代码审查核心逻辑干净且正确。修复通过 但是存在一个回归: 修复很简单——在 测试结果microcompact.test.ts — 59/59 通过 ✅3 个新的受管理记忆测试全部通过。 memoryPressureMonitor.test.ts — 3 个失败 / 69 个通过 ❌根因: 类型检查 — 通过 ✅真实场景测试受管理记忆的微压缩本质上是多轮行为—— — Qwen Code · qwen3.7-max |
|
This is a well-targeted fix for a confirmed bug. The approach is exactly what I'd have done — thread The logic is sound and I'm confident in the correctness of the core fix. The one issue blocking merge is the 3 failing tests in 中文说明这是一个针对已确认 bug 的精准修复。方案和我会做的完全一致——通过选项传递 逻辑正确,我对核心修复的正确性有信心。阻止合并的唯一问题是 — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Core logic is solid and well-tested, but 3 existing tests in memoryPressureMonitor.test.ts fail because createMockConfig() doesn't include getTargetDir. Once that mock is patched, this looks ready to ship. 🙏
|
Closing as superseded by #6714, which has now merged a more comprehensive fix for the same managed-memory microcompaction issue (including project, user, and team memory handling). Thank you for the review and feedback. |
What this PR does
Prevents managed auto-memory reads from being cleared by microcompaction. Project-level and user-level managed memory remain available after both idle-triggered and size-triggered compaction, while ordinary old tool results continue to be compacted.
Why it's needed
Managed memory can be intentionally loaded into a conversation for durable context. Previously, microcompaction treated these reads like ordinary file output and replaced their content with a placeholder, which made the memory unavailable later in the session.
Reviewer Test Plan
How to verify
read_fileresponse for a managed-memory path, followed by ordinary file reads.Evidence (Before & After)
Before: managed-memory
read_fileresponses were cleared with ordinary tool output.After: the focused regression coverage confirms project-level and user-level managed memory is retained for idle compaction, and project-level memory is retained for size compaction.
Tested on
Environment (optional)
macOS, Node.js v24.14.0.
Risk & Scope
Linked Issues
Fixes #6713
AI-assisted contribution
This contribution was implemented with Codex and independently reviewed before submission.
中文说明
本 PR 做了什么
防止受管理的自动记忆读取结果被微压缩清除。项目级和用户级的受管理记忆在空闲触发和大小触发的压缩后仍可使用,而普通的旧工具结果仍会被压缩。
为什么需要它
受管理记忆会被有意加载到对话中,作为可持续使用的上下文。此前,微压缩会把这些读取结果当作普通文件输出,并用占位符替换其内容,导致记忆在同一会话后续阶段不可用。
审查者测试计划
如何验证
read_file响应,随后加入普通文件读取。证据(修改前与修改后)
修改前:受管理记忆的
read_file响应会和普通工具输出一起被清除。修改后:聚焦的回归测试确认项目级和用户级受管理记忆在空闲压缩中会被保留,项目级受管理记忆在大小压缩中也会被保留。
测试平台
环境(可选)
macOS,Node.js v24.14.0。
风险与范围
关联 Issue
修复 #6713
AI 辅助贡献
本贡献由 Codex 协助实现,并在提交前进行了独立审查。