fix: 内存优化 — FileReadTool 100KB 上限、lookups 缓存、microcompact 替换清理

- FileReadTool maxResultSizeChars 从 Infinity 改为 100KB,大文件持久化到磁盘
- Messages.tsx 新增 computeMessageStructureKey 缓存,流式 delta 时跳过 8 个 Map/Set 重建
- microcompact 返回 clearedToolUseIds,query.ts 消费后清理 replacements Map 释放原始字符串
- 更新内存分析报告 Round 5 和 file-operations 文档

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-05-02 11:21:22 +08:00
parent 3eba5ade1a
commit f724300079
8 changed files with 205 additions and 32 deletions

View File

@@ -529,6 +529,16 @@ async function* queryLoop(
querySource,
)
messagesForQuery = microcompactResult.messages
// Release original strings from contentReplacementState.replacements for
// tool results whose content was replaced with the cleared message.
if (microcompactResult.clearedToolUseIds?.length) {
const replacements = toolUseContext?.contentReplacementState?.replacements
if (replacements) {
for (const id of microcompactResult.clearedToolUseIds) {
replacements.delete(id)
}
}
}
// For cached microcompact (cache editing), defer boundary message until after
// the API response so we can use actual cache_deleted_input_tokens.
// Gated behind feature() so the string is eliminated from external builds.