Skip to content

Commit 3684485

Browse files
committed
cleanup: remove unused nudgeCounter
1 parent 43497b1 commit 3684485

File tree

5 files changed

+1
-14
lines changed

5 files changed

+1
-14
lines changed

lib/state/state.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export function createSessionState(): SessionState {
7676
},
7777
toolParameters: new Map<string, ToolParameterEntry>(),
7878
toolIdList: [],
79-
nudgeCounter: 0,
8079
lastToolPrune: false,
8180
lastCompaction: 0,
8281
currentTurn: 0,
@@ -103,7 +102,6 @@ export function resetSessionState(state: SessionState): void {
103102
}
104103
state.toolParameters.clear()
105104
state.toolIdList = []
106-
state.nudgeCounter = 0
107105
state.lastToolPrune = false
108106
state.lastCompaction = 0
109107
state.currentTurn = 0

lib/state/tool-cache.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export function syncToolCache(
1818
try {
1919
logger.info("Syncing tool parameters from OpenCode messages")
2020

21-
state.nudgeCounter = 0
2221
let turnCounter = 0
2322

2423
for (const msg of messages) {
@@ -45,14 +44,9 @@ export function syncToolCache(
4544
state.currentTurn - turnCounter < turnProtectionTurns
4645

4746
if (part.tool === "compress") {
48-
state.nudgeCounter = 0
4947
state.lastToolPrune = true
5048
} else {
5149
state.lastToolPrune = false
52-
const allProtectedTools = config.tools.settings.protectedTools
53-
if (!allProtectedTools.includes(part.tool) && !isProtectedByTurn) {
54-
state.nudgeCounter++
55-
}
5650
}
5751

5852
if (state.toolParameters.has(part.callID)) {
@@ -82,7 +76,7 @@ export function syncToolCache(
8276
}
8377

8478
logger.info(
85-
`Synced cache - size: ${state.toolParameters.size}, currentTurn: ${state.currentTurn}, nudgeCounter: ${state.nudgeCounter}`,
79+
`Synced cache - size: ${state.toolParameters.size}, currentTurn: ${state.currentTurn}`,
8680
)
8781
trimToolParametersCache(state)
8882
} catch (error) {

lib/state/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export interface SessionState {
4747
stats: SessionStats
4848
toolParameters: Map<string, ToolParameterEntry>
4949
toolIdList: string[]
50-
nudgeCounter: number
5150
lastToolPrune: boolean
5251
lastCompaction: number
5352
currentTurn: number

lib/state/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,5 @@ export function resetOnCompaction(state: SessionState): void {
5151
state.prune.messages = new Map<string, number>()
5252
state.compressSummaries = []
5353
state.contextLimitAnchors = new Set<string>()
54-
state.nudgeCounter = 0
5554
state.lastToolPrune = false
5655
}

lib/tools/compress.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {
122122
},
123123
toolParameters: state.toolParameters.size,
124124
turn: state.currentTurn,
125-
nudgeCounter: state.nudgeCounter,
126125
})
127126

128127
const transformedMessages = structuredClone(messages) as WithParts[]
@@ -442,12 +441,10 @@ export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {
442441

443442
state.stats.totalPruneTokens += state.stats.pruneTokenCounter
444443
state.stats.pruneTokenCounter = 0
445-
state.nudgeCounter = 0
446444
state.contextLimitAnchors = new Set<string>()
447445

448446
clog.info(C.COMPRESS, `Final Stats`, {
449447
totalPruneTokens: state.stats.totalPruneTokens,
450-
nudgeCounter: state.nudgeCounter,
451448
})
452449

453450
saveSessionState(state, logger).catch((err) => {

0 commit comments

Comments
 (0)