fix(context): 细化 micro compact 保留策略#611
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
| "source_path": {}, | ||
| "status_code": {}, | ||
| "destination_path": {}, |
There was a problem hiding this comment.
medium Adding source_path / destination_path to the projected metadata allowlist makes copy/move tool messages send absolute local filesystem paths back to the provider. filesystem_copy_file and filesystem_move_file currently persist src/dst as absolute paths, so this change leaks workspace layout and usernames into recent-window / memo-extraction context. Please normalize these fields to workspace-relative paths before allowlisting them, or keep them out of model-visible metadata.
|
|
||
| func (t *ReadTool) MicroCompactPolicy() tools.MicroCompactPolicy { | ||
| return tools.MicroCompactPolicyPreserveHistory | ||
| return tools.MicroCompactPolicyCompact |
There was a problem hiding this comment.
medium Switching codebase_read from PreserveHistory to Compact is a behavior change that drops previously-read source bodies down to path/line-count summaries. That is at odds with the current repository design contract (docs/repository-design.md, acceptance criterion 28), which explicitly relies on codebase_read being the implementation-bearing tool that stays available across compact while codebase_search_* can be summarized. If this policy change is intentional, the surrounding docs/prompt contract should be updated in the same PR; otherwise this weakens the "must verify via codebase_read" workflow.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
@
概要
本 PR 修复并细化了上下文微压缩(micro compact)的保留策略,解决三个问题:
1. 缺少专用摘要器的工具结果被静默清空
summarizeOrClear在遇到未注册摘要器的工具时直接返回清空消息,导致历史信息丢失。现在会退化为最小可读摘要[summary] toolName lines=N chars=M,保证工具执行历史始终有可见痕迹。2. 文件操作 pin 判定覆盖不足
CopyFile/MoveFile到默认 pin 工具列表relative_path → path → source_path → destination_path,防止复制/移动操作的文件被过早回收3. 工具输出截断丢弃尾部关键信息
原来的单点截断(仅保留前 600 字符)可能导致错误日志、堆栈信息等尾部关键内容丢失。改为头尾窗口保留(各 300 字符),中间用
...[truncated]...标记,确保 memo 提取时兼顾上下文与错误定位。附带变更
ReadTool/SpawnSubagent的 MicroCompactPolicy 调整为Compact,避免其历史被无条件保留projectedToolMetadataAllowlist新增source_path/destination_path字段测试
go build ./...通过go test ./internal/context/...全部通过