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

@@ -337,9 +337,10 @@ export type Output = z.infer<OutputSchema>
export const FileReadTool = buildTool({
name: FILE_READ_TOOL_NAME,
searchHint: 'read files, images, PDFs, notebooks',
// Output is bounded by maxTokens (validateContentTokens). Persisting to a
// file the model reads back with Read is circular — never persist.
maxResultSizeChars: Infinity,
// Output is bounded by maxTokens (validateContentTokens). Results exceeding
// 100KB are persisted to disk (reducing memory pressure in long sessions)
// rather than kept in the message array indefinitely.
maxResultSizeChars: 100_000,
strict: true,
async description() {
return DESCRIPTION