|
|
@@ -310,6 +310,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|
|
consecutiveMistakeCount: number = 0
|
|
|
consecutiveMistakeLimit: number
|
|
|
consecutiveMistakeCountForApplyDiff: Map<string, number> = new Map()
|
|
|
+ consecutiveNoToolUseCount: number = 0
|
|
|
toolUsage: ToolUsage = {}
|
|
|
|
|
|
// Checkpoints
|
|
|
@@ -1982,6 +1983,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|
|
|
|
|
this.abort = true
|
|
|
|
|
|
+ // Reset consecutive error counters on abort (manual intervention)
|
|
|
+ this.consecutiveNoToolUseCount = 0
|
|
|
+
|
|
|
// Force final token usage update before abort event
|
|
|
this.emitFinalTokenUsageUpdate()
|
|
|
|
|
|
@@ -2236,7 +2240,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|
|
} else {
|
|
|
// Use the task's locked protocol, NOT the current settings (fallback to xml if not set)
|
|
|
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed(this._taskToolProtocol ?? "xml") }]
|
|
|
- this.consecutiveMistakeCount++
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3250,12 +3253,24 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|
|
)
|
|
|
|
|
|
if (!didToolUse) {
|
|
|
+ // Increment consecutive no-tool-use counter
|
|
|
+ this.consecutiveNoToolUseCount++
|
|
|
+
|
|
|
+ // Only show error and count toward mistake limit after 2 consecutive failures
|
|
|
+ if (this.consecutiveNoToolUseCount >= 2) {
|
|
|
+ await this.say("error", "MODEL_NO_TOOLS_USED")
|
|
|
+ // Only count toward mistake limit after second consecutive failure
|
|
|
+ this.consecutiveMistakeCount++
|
|
|
+ }
|
|
|
+
|
|
|
// Use the task's locked protocol for consistent behavior
|
|
|
this.userMessageContent.push({
|
|
|
type: "text",
|
|
|
text: formatResponse.noToolsUsed(this._taskToolProtocol ?? "xml"),
|
|
|
})
|
|
|
- this.consecutiveMistakeCount++
|
|
|
+ } else {
|
|
|
+ // Reset counter when tools are used successfully
|
|
|
+ this.consecutiveNoToolUseCount = 0
|
|
|
}
|
|
|
|
|
|
// Push to stack if there's content OR if we're paused waiting for a subtask.
|