MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / collectTurnNudgeAnchors

Function collectTurnNudgeAnchors

lib/state/utils.ts:291–317  ·  view source on GitHub ↗
(messages: WithParts[])

Source from the content-addressed store, hash-verified

289}
290
291export function collectTurnNudgeAnchors(messages: WithParts[]): Set<string> {
292 const anchors = new Set<string>()
293 let pendingUserMessageId: string | null = null
294
295 for (let i = messages.length - 1; i >= 0; i--) {
296 const message = messages[i]
297
298 if (messageHasCompress(message)) {
299 break
300 }
301
302 if (message.info.role === "user") {
303 if (!isIgnoredUserMessage(message)) {
304 pendingUserMessageId = message.info.id
305 }
306 continue
307 }
308
309 if (message.info.role === "assistant" && pendingUserMessageId) {
310 anchors.add(message.info.id)
311 anchors.add(pendingUserMessageId)
312 pendingUserMessageId = null
313 }
314 }
315
316 return anchors
317}
318
319export function getActiveSummaryTokenUsage(state: SessionState): number {
320 let total = 0

Callers 1

ensureSessionInitializedFunction · 0.90

Calls 2

messageHasCompressFunction · 0.90
isIgnoredUserMessageFunction · 0.90

Tested by

no test coverage detected