Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/telemetry/src/TelemetryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export class TelemetryService {
this.captureEvent(TelemetryEventName.MODE_SWITCH, { taskId, newMode })
}

public captureToolUsage(taskId: string, tool: string): void {
this.captureEvent(TelemetryEventName.TOOL_USED, { taskId, tool })
public captureToolUsage(taskId: string, tool: string, toolProtocol: string): void {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toolProtocol parameter uses string type instead of the more specific ToolProtocol type from @roo-code/types. Using the proper type would provide compile-time safety against typos or invalid values (e.g., "nativ" instead of "native"). The ToolProtocol type is already available since @roo-code/types is a dependency of this package.

Suggested change
public captureToolUsage(taskId: string, tool: string, toolProtocol: string): void {
public captureToolUsage(taskId: string, tool: string, toolProtocol: ToolProtocol): void {

Fix it with Roo Code or mention @roomote and request a fix.

this.captureEvent(TelemetryEventName.TOOL_USED, { taskId, tool, toolProtocol })
}

public captureCheckpointCreated(taskId: string): void {
Expand Down
10 changes: 5 additions & 5 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { fetchInstructionsTool } from "../tools/FetchInstructionsTool"
import { listFilesTool } from "../tools/ListFilesTool"
import { readFileTool } from "../tools/ReadFileTool"
import { getSimpleReadFileToolDescription, simpleReadFileTool } from "../tools/simpleReadFileTool"
import { shouldUseSingleFileRead } from "@roo-code/types"
import { shouldUseSingleFileRead, TOOL_PROTOCOL } from "@roo-code/types"
import { writeToFileTool } from "../tools/WriteToFileTool"
import { applyDiffTool } from "../tools/MultiApplyDiffTool"
import { insertContentTool } from "../tools/InsertContentTool"
Expand Down Expand Up @@ -284,10 +284,10 @@ export async function presentAssistantMessage(cline: Task) {
// Native protocol tool calls ALWAYS have an ID (set when parsed from tool_call chunks).
// XML protocol tool calls NEVER have an ID (parsed from XML text).
const toolCallId = (block as any).id
const isNative = !!toolCallId
const toolProtocol = toolCallId ? TOOL_PROTOCOL.NATIVE : TOOL_PROTOCOL.XML

const pushToolResult = (content: ToolResponse) => {
if (isNative && toolCallId) {
if (toolProtocol === TOOL_PROTOCOL.NATIVE) {
// For native protocol, only allow ONE tool_result per tool call
if (hasToolResult) {
console.warn(
Expand Down Expand Up @@ -430,7 +430,7 @@ export async function presentAssistantMessage(cline: Task) {

if (!block.partial) {
cline.recordToolUsage(block.name)
TelemetryService.instance.captureToolUsage(cline.taskId, block.name)
TelemetryService.instance.captureToolUsage(cline.taskId, block.name, toolProtocol)
}

// Validate tool use before execution.
Expand Down Expand Up @@ -514,7 +514,7 @@ export async function presentAssistantMessage(cline: Task) {

// Check if this tool call came from native protocol by checking for ID
// Native calls always have IDs, XML calls never do
if (isNative) {
if (toolProtocol === TOOL_PROTOCOL.NATIVE) {
await applyDiffToolClass.handle(cline, block as ToolUse<"apply_diff">, {
askApproval,
handleError,
Expand Down
Loading