Compare commits

...
Author SHA1 Message Date
pashpashpash eeafba0fb0 added modelId to tool call events 2025-05-31 18:18:26 -07:00
2 changed files with 106 additions and 20 deletions
+97 -19
View File
@@ -2370,7 +2370,7 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("ask", "tool")
await this.say("tool", completeMessage, undefined, undefined, false)
this.consecutiveAutoApprovedRequestsCount++
telemetryService.captureToolUsage(this.taskId, block.name, true, true)
telemetryService.captureToolUsage(this.taskId, block.name, this.api.getModel().id, true, true)
// we need an artificial delay to let the diagnostics catch up to the changes
await setTimeoutPromise(3_500)
@@ -2408,7 +2408,13 @@ export class Task {
}
this.didRejectTool = true
didApprove = false
telemetryService.captureToolUsage(this.taskId, block.name, false, false)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
false,
)
} else {
// User hit the approve button, and may have provided feedback
if (text || (images && images.length > 0) || (askFiles && askFiles.length > 0)) {
@@ -2421,7 +2427,13 @@ export class Task {
await this.say("user_feedback", text, images, askFiles)
await this.saveCheckpoint()
}
telemetryService.captureToolUsage(this.taskId, block.name, false, true)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
true,
)
}
if (!didApprove) {
@@ -2539,7 +2551,7 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("ask", "tool")
await this.say("tool", completeMessage, undefined, undefined, false) // need to be sending partialValue bool, since undefined has its own purpose in that the message is treated neither as a partial or completion of a partial, but as a single complete message
this.consecutiveAutoApprovedRequestsCount++
telemetryService.captureToolUsage(this.taskId, block.name, true, true)
telemetryService.captureToolUsage(this.taskId, block.name, this.api.getModel().id, true, true)
} else {
showNotificationForApprovalIfAutoApprovalEnabled(
`Cline wants to read ${path.basename(absolutePath)}`,
@@ -2548,10 +2560,22 @@ export class Task {
const didApprove = await askApproval("tool", completeMessage)
if (!didApprove) {
await this.saveCheckpoint()
telemetryService.captureToolUsage(this.taskId, block.name, false, false)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
false,
)
break
}
telemetryService.captureToolUsage(this.taskId, block.name, false, true)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
true,
)
}
// now execute the tool like normal
const content = await extractTextFromFile(absolutePath)
@@ -2624,7 +2648,7 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("ask", "tool")
await this.say("tool", completeMessage, undefined, undefined, false)
this.consecutiveAutoApprovedRequestsCount++
telemetryService.captureToolUsage(this.taskId, block.name, true, true)
telemetryService.captureToolUsage(this.taskId, block.name, this.api.getModel().id, true, true)
} else {
showNotificationForApprovalIfAutoApprovalEnabled(
`Cline wants to view directory ${path.basename(absolutePath)}/`,
@@ -2632,11 +2656,23 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("say", "tool")
const didApprove = await askApproval("tool", completeMessage)
if (!didApprove) {
telemetryService.captureToolUsage(this.taskId, block.name, false, false)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
false,
)
await this.saveCheckpoint()
break
}
telemetryService.captureToolUsage(this.taskId, block.name, false, true)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
true,
)
}
pushToolResult(result, isClaude4ModelFamily)
await this.saveCheckpoint()
@@ -2694,7 +2730,7 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("ask", "tool")
await this.say("tool", completeMessage, undefined, undefined, false)
this.consecutiveAutoApprovedRequestsCount++
telemetryService.captureToolUsage(this.taskId, block.name, true, true)
telemetryService.captureToolUsage(this.taskId, block.name, this.api.getModel().id, true, true)
} else {
showNotificationForApprovalIfAutoApprovalEnabled(
`Cline wants to view source code definitions in ${path.basename(absolutePath)}/`,
@@ -2702,11 +2738,23 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("say", "tool")
const didApprove = await askApproval("tool", completeMessage)
if (!didApprove) {
telemetryService.captureToolUsage(this.taskId, block.name, false, false)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
false,
)
await this.saveCheckpoint()
break
}
telemetryService.captureToolUsage(this.taskId, block.name, false, true)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
true,
)
}
pushToolResult(result)
await this.saveCheckpoint()
@@ -2783,7 +2831,7 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("ask", "tool")
await this.say("tool", completeMessage, undefined, undefined, false)
this.consecutiveAutoApprovedRequestsCount++
telemetryService.captureToolUsage(this.taskId, block.name, true, true)
telemetryService.captureToolUsage(this.taskId, block.name, this.api.getModel().id, true, true)
} else {
showNotificationForApprovalIfAutoApprovalEnabled(
`Cline wants to search files in ${path.basename(absolutePath)}/`,
@@ -2791,11 +2839,23 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("say", "tool")
const didApprove = await askApproval("tool", completeMessage)
if (!didApprove) {
telemetryService.captureToolUsage(this.taskId, block.name, false, false)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
false,
)
await this.saveCheckpoint()
break
}
telemetryService.captureToolUsage(this.taskId, block.name, false, true)
telemetryService.captureToolUsage(
this.taskId,
block.name,
this.api.getModel().id,
false,
true,
)
}
pushToolResult(results, isClaude4ModelFamily)
await this.saveCheckpoint()
@@ -3700,20 +3760,38 @@ export class Task {
this.removeLastPartialMessageIfExistsWithType("ask", "tool")
await this.say("tool", completeMessage, undefined, undefined, false)
this.consecutiveAutoApprovedRequestsCount++
telemetryService.captureToolUsage(this.taskId, "web_fetch" as ToolUseName, true, true)
telemetryService.captureToolUsage(
this.taskId,
"web_fetch" as ToolUseName,
this.api.getModel().id,
true,
true,
)
} else {
showNotificationForApprovalIfAutoApprovalEnabled(`Cline wants to fetch content from ${url}`)
this.removeLastPartialMessageIfExistsWithType("say", "tool")
const didApprove = await askApproval("tool", completeMessage)
if (!didApprove) {
telemetryService.captureToolUsage(this.taskId, "web_fetch" as ToolUseName, false, false)
telemetryService.captureToolUsage(
this.taskId,
"web_fetch" as ToolUseName,
this.api.getModel().id,
false,
false,
)
await this.saveCheckpoint()
break
}
telemetryService.captureToolUsage(this.taskId, "web_fetch" as ToolUseName, false, true)
telemetryService.captureToolUsage(
this.taskId,
"web_fetch" as ToolUseName,
this.api.getModel().id,
false,
true,
)
}
// Fetch Markdown content
// Fetch Markdown contentcc
await this.urlContentFetcher.launchBrowser()
const markdownContent = await this.urlContentFetcher.urlToMarkdown(url)
await this.urlContentFetcher.closeBrowser()
@@ -383,7 +383,14 @@ class TelemetryService {
* @param autoApproved Whether the tool was auto-approved based on settings
* @param success Whether the tool execution was successful
*/
public captureToolUsage(taskId: string, tool: string, autoApproved: boolean, success: boolean, collect: boolean = false) {
public captureToolUsage(
taskId: string,
tool: string,
modelId: string,
autoApproved: boolean,
success: boolean,
collect: boolean = false,
) {
this.capture(
{
event: TelemetryService.EVENTS.TASK.TOOL_USED,
@@ -392,6 +399,7 @@ class TelemetryService {
tool,
autoApproved,
success,
modelId,
},
},
collect,