@@ -7,6 +7,7 @@ import { selectModel, ModelInfo } from "../model-selector"
77import { saveSessionState } from "../state/persistence"
88import { sendUnifiedNotification } from "../ui/notification"
99import { calculateTokensSaved , getCurrentParams } from "./utils"
10+ import { isMessageCompacted } from "../shared-utils"
1011
1112export interface OnIdleResult {
1213 prunedCount : number
@@ -18,6 +19,7 @@ export interface OnIdleResult {
1819 * Parse messages to extract tool information.
1920 */
2021function parseMessages (
22+ state : SessionState ,
2123 messages : WithParts [ ] ,
2224 toolParametersCache : Map < string , ToolParameterEntry >
2325) : {
@@ -28,6 +30,9 @@ function parseMessages(
2830 const toolMetadata = new Map < string , ToolParameterEntry > ( )
2931
3032 for ( const msg of messages ) {
33+ if ( isMessageCompacted ( state , msg ) ) {
34+ continue
35+ }
3136 if ( msg . parts ) {
3237 for ( const part of msg . parts ) {
3338 if ( part . type === "tool" && part . callID ) {
@@ -224,7 +229,7 @@ export async function runOnIdle(
224229 }
225230
226231 const currentParams = getCurrentParams ( messages , logger )
227- const { toolCallIds, toolMetadata } = parseMessages ( messages , state . toolParameters )
232+ const { toolCallIds, toolMetadata } = parseMessages ( state , messages , state . toolParameters )
228233
229234 const alreadyPrunedIds = state . prune . toolIds
230235 const unprunedToolCallIds = toolCallIds . filter ( id => ! alreadyPrunedIds . includes ( id ) )
0 commit comments