mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
feat: 尝试深度拷贝数据以分离引用
This commit is contained in:
16
src/query.ts
16
src/query.ts
@@ -479,6 +479,22 @@ async function* queryLoop(
|
||||
|
||||
let messagesForQuery = getMessagesAfterCompactBoundary(messages)
|
||||
|
||||
// Release toolUseResult payloads from previous turns. By this point the
|
||||
// UI has already rendered those results and the next API call only needs
|
||||
// message.message.content (tool_result blocks), not the raw output object.
|
||||
// This prevents unbounded memory growth in long sessions before compact
|
||||
// triggers — a single FileRead of a 400KB file would otherwise stay in
|
||||
// mutableMessages forever.
|
||||
for (const msg of messagesForQuery) {
|
||||
if (
|
||||
msg.type === 'user' &&
|
||||
'toolUseResult' in msg &&
|
||||
msg.toolUseResult !== undefined
|
||||
) {
|
||||
delete (msg as Message & { toolUseResult?: unknown }).toolUseResult
|
||||
}
|
||||
}
|
||||
|
||||
let tracking = autoCompactTracking
|
||||
|
||||
// Enforce per-message budget on aggregate tool result size. Runs BEFORE
|
||||
|
||||
Reference in New Issue
Block a user