MCPcopy Create free account
hub / github.com/Noumena-Network/code / countToolCallsSince

Function countToolCallsSince

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

Source from the content-addressed store, hash-verified

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

Callers 1

shouldExtractMemoryFunction · 0.85

Calls 1

countFunction · 0.85

Tested by

no test coverage detected