Skip to content

Commit 9da3d6a

Browse files
committed
fix(telemetry): report accurate reason and count on consecutive mistake event
1 parent d6f7666 commit 9da3d6a

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎src/core/assistant-message/__tests__/presentAssistantMessage-tool-repetition.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ describe("presentAssistantMessage - Tool Repetition Detection", () => {
300300
expect(captureConsecutiveMistakeError).toHaveBeenCalledWith(
301301
"test-task-id",
302302
"tool_repetition",
303-
mockTask.consecutiveMistakeCount,
303+
HARD_LIMIT,
304304
HARD_LIMIT,
305305
)
306306
expect(findToolResult(nextToolCallId)).toBeDefined()
@@ -369,7 +369,7 @@ describe("presentAssistantMessage - Tool Repetition Detection", () => {
369369
expect(captureConsecutiveMistakeError).toHaveBeenCalledWith(
370370
"test-task-id",
371371
"tool_repetition",
372-
mockTask.consecutiveMistakeCount,
372+
HARD_LIMIT,
373373
HARD_LIMIT,
374374
)
375375
// The named event is the single capture: no duplicate exception.

‎src/core/assistant-message/presentAssistantMessage.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,13 @@ async function presentAssistantMessageBlock(cline: Task): Promise<void> {
836836
}
837837

838838
// Track tool repetition in telemetry via a named event.
839+
// The detector's hard limit is consecutiveMistakeLimit and it blocks when the
840+
// identical-call count reaches it, so that count equals the limit here.
841+
// consecutiveMistakeCount is unrelated and can be zero.
839842
TelemetryService.instance.captureConsecutiveMistakeError(
840843
cline.taskId,
841844
"tool_repetition",
842-
cline.consecutiveMistakeCount,
845+
cline.consecutiveMistakeLimit,
843846
cline.consecutiveMistakeLimit,
844847
)
845848

‎src/core/task/Task.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,11 +3782,11 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
37823782

37833783
if (this.consecutiveMistakeLimit > 0 && this.consecutiveMistakeCount >= this.consecutiveMistakeLimit) {
37843784
// Track consecutive mistake errors in telemetry via a named event.
3785-
// The reason is "no_tools_used" because this limit is reached via initiateTaskLoop
3786-
// which increments consecutiveMistakeCount when the model doesn't use any tools.
3785+
// The reason is "unknown" because many paths increment consecutiveMistakeCount
3786+
// (no tool use, tool validation and tool execution failures) and none records its cause.
37873787
TelemetryService.instance.captureConsecutiveMistakeError(
37883788
this.taskId,
3789-
"no_tools_used",
3789+
"unknown",
37903790
this.consecutiveMistakeCount,
37913791
this.consecutiveMistakeLimit,
37923792
)

0 commit comments

Comments
 (0)