File tree Expand file tree Collapse file tree
src/agents/embedded-agent-runner Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4183,7 +4183,7 @@ export async function runEmbeddedAttempt(
41834183 promptToolResultMaxChars * PROMPT_TOOL_RESULT_AGGREGATE_CAP_MULTIPLIER ,
41844184 toolResultPromptProjectionState ,
41854185 ) ;
4186- if ( promptToolResultTruncation . truncatedCount > 0 ) {
4186+ if ( promptToolResultTruncation . messages !== activeSession . messages ) {
41874187 promptHistoryMessages = promptToolResultTruncation . messages ;
41884188 log . info (
41894189 `[tool-result-truncation] Truncated ${ promptToolResultTruncation . truncatedCount } ` +
@@ -4725,7 +4725,7 @@ export async function runEmbeddedAttempt(
47254725 promptToolResultMaxChars * PROMPT_TOOL_RESULT_AGGREGATE_CAP_MULTIPLIER ,
47264726 toolResultPromptProjectionState ,
47274727 ) ;
4728- return providerPromptHistoryTruncation . truncatedCount > 0
4728+ return providerPromptHistoryTruncation . messages !== messages
47294729 ? providerPromptHistoryTruncation . messages
47304730 : messages ;
47314731 } ,
Original file line number Diff line number Diff line change @@ -366,8 +366,12 @@ export function truncateOversizedToolResultsInMessages(
366366 minKeepChars : RECOVERY_MIN_KEEP_CHARS ,
367367 } ) ;
368368 if ( plan . replacements . length === 0 ) {
369+ const projectedMessages = branch . map ( ( entry ) => entry . message as AgentMessage ) ;
370+ const hasProjectedChanges = projectedMessages . some (
371+ ( message , index ) => message !== messages [ index ] ,
372+ ) ;
369373 return {
370- messages : branch . map ( ( entry ) => entry . message as AgentMessage ) ,
374+ messages : hasProjectedChanges ? projectedMessages : messages ,
371375 truncatedCount : 0 ,
372376 } ;
373377 }
You can’t perform that action at this time.
0 commit comments