From 3d648003ecc6b69085ebc9498975983060970632 Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sat, 12 Sep 2026 18:10:40 -0700 Subject: [PATCH] perf: count chat tool calls without a filtered array (#20328) Co-authored-by: Orca Worker --- src/shared/native-chat-tool-summary.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shared/native-chat-tool-summary.ts b/src/shared/native-chat-tool-summary.ts index 60cd4ba9d53..38f02ee34f8 100644 --- a/src/shared/native-chat-tool-summary.ts +++ b/src/shared/native-chat-tool-summary.ts @@ -298,7 +298,13 @@ export function summarizeToolRun(blocks: readonly NativeChatBlock[]): string { } export function countToolCalls(blocks: readonly NativeChatBlock[]): number { - return blocks.filter(isToolCallBlock).length + let count = 0 + blocks.forEach((block) => { + if (isToolCallBlock(block)) { + count += 1 + } + }) + return count } function toRawPreview(input: unknown): string {