MCPcopy Index your code
hub / github.com/codeaashu/claude-code / countToolCallsSince

Function countToolCallsSince

src/services/SessionMemory/sessionMemory.ts:108–132  ·  view source on GitHub ↗
(
  messages: Message[],
  sinceUuid: string | undefined,
)

Source from the content-addressed store, hash-verified

106}
107
108function countToolCallsSince(
109 messages: Message[],
110 sinceUuid: string | undefined,
111): number {
112 let toolCallCount = 0
113 let foundStart = sinceUuid === null || sinceUuid === undefined
114
115 for (const message of messages) {
116 if (!foundStart) {
117 if (message.uuid === sinceUuid) {
118 foundStart = true
119 }
120 continue
121 }
122
123 if (message.type === 'assistant') {
124 const content = message.message.content
125 if (Array.isArray(content)) {
126 toolCallCount += count(content, block => block.type === 'tool_use')
127 }
128 }
129 }
130
131 return toolCallCount
132}
133
134export function shouldExtractMemory(messages: Message[]): boolean {
135 // Check if we've met the initialization threshold

Callers 1

shouldExtractMemoryFunction · 0.85

Calls 1

countFunction · 0.85

Tested by

no test coverage detected