fix: trim persisted tool results and sanitize MCP schemas

This commit is contained in:
sooth
2026-04-02 07:49:58 -04:00
parent 9f48bb4431
commit 5c4469fe81
10 changed files with 449 additions and 26 deletions

View File

@@ -376,7 +376,7 @@ async function* queryLoop(
const persistReplacements =
querySource.startsWith('agent:') ||
querySource.startsWith('repl_main_thread')
messagesForQuery = await applyToolResultBudget(
const toolResultBudgetResult = await applyToolResultBudget(
messagesForQuery,
toolUseContext.contentReplacementState,
persistReplacements
@@ -392,6 +392,12 @@ async function* queryLoop(
.map(t => t.name),
),
)
messagesForQuery = toolResultBudgetResult.messages
if (toolResultBudgetResult.newlyReplaced.length > 0) {
toolUseContext.syncToolResultReplacements?.(
toolUseContext.contentReplacementState?.replacements ?? new Map(),
)
}
// Apply snip before microcompact (both may run — they are not mutually exclusive).
// snipTokensFreed is plumbed to autocompact so its threshold check reflects