mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 20:31:37 -05:00
Reset consecutive mistake count if claude uses tool correctly
This commit is contained in:
@@ -267,7 +267,7 @@ export class ClaudeDev {
|
|||||||
private askResponseImages?: string[]
|
private askResponseImages?: string[]
|
||||||
private lastMessageTs?: number
|
private lastMessageTs?: number
|
||||||
private executeCommandRunningProcess?: ResultPromise
|
private executeCommandRunningProcess?: ResultPromise
|
||||||
private mistakeCount: number = 0
|
private consecutiveMistakeCount: number = 0
|
||||||
private shouldSkipNextApiReqStartedMessage = false
|
private shouldSkipNextApiReqStartedMessage = false
|
||||||
private providerRef: WeakRef<ClaudeDevProvider>
|
private providerRef: WeakRef<ClaudeDevProvider>
|
||||||
private abort: boolean = false
|
private abort: boolean = false
|
||||||
@@ -715,7 +715,7 @@ export class ClaudeDev {
|
|||||||
text: "If you have completed the user's task, use the attempt_completion tool. If you require additional information from the user, use the ask_followup_question tool. Otherwise, if you have not completed the task and do not need additional information, then proceed with the next step of the task. (This is an automated message, so do not respond to it conversationally.)",
|
text: "If you have completed the user's task, use the attempt_completion tool. If you require additional information from the user, use the ask_followup_question tool. Otherwise, if you have not completed the task and do not need additional information, then proceed with the next step of the task. (This is an automated message, so do not respond to it conversationally.)",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -779,7 +779,7 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use write_to_file without value for required parameter 'path'. Retrying..."
|
"Claude tried to use write_to_file without value for required parameter 'path'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,10 +789,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
`Claude tried to use write_to_file for '${relPath}' without value for required parameter 'content'. This is likely due to output token limits. Retrying...`
|
`Claude tried to use write_to_file for '${relPath}' without value for required parameter 'content'. This is likely due to output token limits. Retrying...`
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'content'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'content'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
try {
|
try {
|
||||||
const absolutePath = path.resolve(cwd, relPath)
|
const absolutePath = path.resolve(cwd, relPath)
|
||||||
const fileExists = await fs
|
const fileExists = await fs
|
||||||
@@ -954,9 +954,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use read_file without value for required parameter 'path'. Retrying..."
|
"Claude tried to use read_file without value for required parameter 'path'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
try {
|
try {
|
||||||
const absolutePath = path.resolve(cwd, relPath)
|
const absolutePath = path.resolve(cwd, relPath)
|
||||||
const content = await extractTextFromFile(absolutePath)
|
const content = await extractTextFromFile(absolutePath)
|
||||||
@@ -996,9 +997,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use list_files without value for required parameter 'path'. Retrying..."
|
"Claude tried to use list_files without value for required parameter 'path'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
try {
|
try {
|
||||||
const recursive = recursiveRaw?.toLowerCase() === "true"
|
const recursive = recursiveRaw?.toLowerCase() === "true"
|
||||||
const absolutePath = path.resolve(cwd, relDirPath)
|
const absolutePath = path.resolve(cwd, relDirPath)
|
||||||
@@ -1101,9 +1103,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use list_code_definition_names without value for required parameter 'path'. Retrying..."
|
"Claude tried to use list_code_definition_names without value for required parameter 'path'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
try {
|
try {
|
||||||
const absolutePath = path.resolve(cwd, relDirPath)
|
const absolutePath = path.resolve(cwd, relDirPath)
|
||||||
const result = await parseSourceCodeForDefinitionsTopLevel(absolutePath)
|
const result = await parseSourceCodeForDefinitionsTopLevel(absolutePath)
|
||||||
@@ -1145,19 +1148,18 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use search_files without value for required parameter 'path'. Retrying..."
|
"Claude tried to use search_files without value for required parameter 'path'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'path'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regex === undefined) {
|
if (regex === undefined) {
|
||||||
await this.say(
|
await this.say(
|
||||||
"error",
|
"error",
|
||||||
`Claude tried to use search_files without value for required parameter 'regex'. Retrying...`
|
`Claude tried to use search_files without value for required parameter 'regex'. Retrying...`
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'regex'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'regex'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
try {
|
try {
|
||||||
const absolutePath = path.resolve(cwd, relDirPath)
|
const absolutePath = path.resolve(cwd, relDirPath)
|
||||||
const results = await regexSearchFiles(cwd, absolutePath, regex, filePattern)
|
const results = await regexSearchFiles(cwd, absolutePath, regex, filePattern)
|
||||||
@@ -1200,9 +1202,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use execute_command without value for required parameter 'command'. Retrying..."
|
"Claude tried to use execute_command without value for required parameter 'command'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'command'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'command'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
const { response, text, images } = await this.ask("command", command)
|
const { response, text, images } = await this.ask("command", command)
|
||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "messageResponse") {
|
if (response === "messageResponse") {
|
||||||
@@ -1330,9 +1333,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use ask_followup_question without value for required parameter 'question'. Retrying..."
|
"Claude tried to use ask_followup_question without value for required parameter 'question'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'question'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'question'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
const { text, images } = await this.ask("followup", question)
|
const { text, images } = await this.ask("followup", question)
|
||||||
await this.say("user_feedback", text ?? "", images)
|
await this.say("user_feedback", text ?? "", images)
|
||||||
return this.formatIntoToolResponse(`<answer>\n${text}\n</answer>`, images)
|
return this.formatIntoToolResponse(`<answer>\n${text}\n</answer>`, images)
|
||||||
@@ -1345,9 +1349,10 @@ export class ClaudeDev {
|
|||||||
"error",
|
"error",
|
||||||
"Claude tried to use attempt_completion without value for required parameter 'result'. Retrying..."
|
"Claude tried to use attempt_completion without value for required parameter 'result'. Retrying..."
|
||||||
)
|
)
|
||||||
this.mistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
return "Error: Missing value for required parameter 'result'. Please retry with complete response."
|
return "Error: Missing value for required parameter 'result'. Please retry with complete response."
|
||||||
}
|
}
|
||||||
|
this.consecutiveMistakeCount = 0
|
||||||
let resultToSend = result
|
let resultToSend = result
|
||||||
if (command) {
|
if (command) {
|
||||||
await this.say("completion_result", resultToSend)
|
await this.say("completion_result", resultToSend)
|
||||||
@@ -1434,14 +1439,14 @@ ${this.customInstructions.trim()}
|
|||||||
throw new Error("ClaudeDev instance aborted")
|
throw new Error("ClaudeDev instance aborted")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mistakeCount >= 3) {
|
if (this.consecutiveMistakeCount >= 3) {
|
||||||
const { response, text, images } = await this.ask(
|
const { response, text, images } = await this.ask(
|
||||||
"mistake_limit_reached",
|
"mistake_limit_reached",
|
||||||
`This may indicate a failure in his thought process or inability to use a tool properly, which can be alleviated with some user direction (e.g. "let's try breaking this large file down into smaller files").`
|
`This may indicate a failure in his thought process or inability to use a tool properly, which can be alleviated with some user direction (e.g. "let's try breaking this large file down into smaller files").`
|
||||||
)
|
)
|
||||||
if (response === "yesButtonTapped") {
|
if (response === "yesButtonTapped") {
|
||||||
// proceed anyways
|
// proceed anyways
|
||||||
this.mistakeCount = 0
|
this.consecutiveMistakeCount = 0
|
||||||
} else {
|
} else {
|
||||||
userContent.push(
|
userContent.push(
|
||||||
...[
|
...[
|
||||||
|
|||||||
Reference in New Issue
Block a user