countToolCallsSince function
Count tool calls since a given message UUID.
Implementation
int countToolCallsSince(List<SessionMessage> messages, String? sinceUuid) {
var toolCallCount = 0;
var foundStart = sinceUuid == null;
for (final message in messages) {
if (!foundStart) {
if (message.uuid == sinceUuid) foundStart = true;
continue;
}
if (message.type == 'assistant') {
toolCallCount += message.content
.where((b) => b.type == 'tool_use')
.length;
}
}
return toolCallCount;
}