Skip to content

Commit 7f50ce1

Browse files
committed
onidle
1 parent 817c826 commit 7f50ce1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/strategies/on-idle.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { selectModel, ModelInfo } from "../model-selector"
77
import { saveSessionState } from "../state/persistence"
88
import { sendUnifiedNotification } from "../ui/notification"
99
import { calculateTokensSaved, getCurrentParams } from "./utils"
10+
import { isMessageCompacted } from "../shared-utils"
1011

1112
export interface OnIdleResult {
1213
prunedCount: number
@@ -18,6 +19,7 @@ export interface OnIdleResult {
1819
* Parse messages to extract tool information.
1920
*/
2021
function 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

Comments
 (0)