Skip to content

Commit 97fab75

Browse files
committed
refactor: eliminate duplicate toolProtocol detection logic and make parameter required
- Extract toolProtocol variable once at protocol detection point (line 288) - Remove duplicate detection logic at telemetry capture point (line 434) - Make toolProtocol parameter required (not optional) in TelemetryService.captureToolUsage() - Ensures consistent protocol detection and required telemetry data
1 parent 218eb81 commit 97fab75

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

packages/telemetry/src/TelemetryService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class TelemetryService {
9898
this.captureEvent(TelemetryEventName.MODE_SWITCH, { taskId, newMode })
9999
}
100100

101-
public captureToolUsage(taskId: string, tool: string, toolProtocol?: string): void {
101+
public captureToolUsage(taskId: string, tool: string, toolProtocol: string): void {
102102
this.captureEvent(TelemetryEventName.TOOL_USED, { taskId, tool, toolProtocol })
103103
}
104104

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export async function presentAssistantMessage(cline: Task) {
285285
// XML protocol tool calls NEVER have an ID (parsed from XML text).
286286
const toolCallId = (block as any).id
287287
const isNative = !!toolCallId
288+
const toolProtocol = toolCallId ? "native" : "xml"
288289

289290
const pushToolResult = (content: ToolResponse) => {
290291
if (isNative && toolCallId) {
@@ -430,9 +431,6 @@ export async function presentAssistantMessage(cline: Task) {
430431

431432
if (!block.partial) {
432433
cline.recordToolUsage(block.name)
433-
// Determine protocol: native if tool has an ID, otherwise XML
434-
const toolCallId = (block as any).id
435-
const toolProtocol = toolCallId ? "native" : "xml"
436434
TelemetryService.instance.captureToolUsage(cline.taskId, block.name, toolProtocol)
437435
}
438436

0 commit comments

Comments
 (0)