This commit is contained in:
roomote-v0[bot] 2026-04-06 23:41:18 +00:00 committed by GitHub
commit 4494781dc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 4 deletions

View file

@ -2542,10 +2542,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
),
)
const { response, text, images } = await this.ask(
"mistake_limit_reached",
t("common:errors.mistake_limit_guidance"),
)
// Build error message with operation context for better user understanding
const operationContext = this.getLastAttemptedOperationContext()
let errorMessage = t("common:errors.mistake_limit_guidance")
if (operationContext) {
errorMessage = `${t("common:errors.mistake_limit_operation_context", { operation: operationContext })}\n\n${errorMessage}`
}
const { response, text, images } = await this.ask("mistake_limit_reached", errorMessage)
if (response === "messageResponse") {
currentUserContent.push(
@ -4727,4 +4731,43 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
console.error(`[Task] Queue processing error:`, e)
}
}
/**
* Get a human-readable description of the last attempted operation.
* This is used to provide context in the mistake_limit_reached error message
* so users can understand what operation Roo was attempting when it failed.
*
* @returns A descriptive string like "write_to_file for 'path/to/file'" or undefined if no operation found
*/
public getLastAttemptedOperationContext(): string | undefined {
// Look for the last tool_use or mcp_tool_use block in assistantMessageContent
for (let i = this.assistantMessageContent.length - 1; i >= 0; i--) {
const block = this.assistantMessageContent[i]
if (block.type === "tool_use" || block.type === "mcp_tool_use") {
const toolUse = block as import("../../shared/tools").ToolUse | import("../../shared/tools").McpToolUse
const toolName = toolUse.name
// Try to extract a file path from common tool parameters
let filePath: string | undefined
if ("params" in toolUse && toolUse.params) {
// Cast to allow accessing any parameter name
const params = toolUse.params as Record<string, string | undefined>
// Common parameter names for file paths across different tools
filePath = params.path || params.file_path
} else if ("arguments" in toolUse && toolUse.arguments) {
// MCP tools use 'arguments' instead of 'params'
const args = toolUse.arguments as Record<string, unknown>
filePath = (args.path as string) || (args.file_path as string)
}
// Format the operation context string
if (filePath) {
return `${toolName} for '${filePath}'`
}
return toolName
}
}
return undefined
}
}

View file

@ -57,6 +57,7 @@
"cannot_access_path": "Cannot access path {{path}}: {{error}}",
"settings_import_failed": "Settings import failed: {{error}}.",
"mistake_limit_guidance": "This may indicate a failure in the model's thought process or inability to use a tool properly, which can be mitigated with some user guidance (e.g. \"Try breaking down the task into smaller steps\").",
"mistake_limit_operation_context": "While attempting: {{operation}}",
"violated_organization_allowlist": "Failed to run task: the current profile isn't compatible with your organization settings",
"condense_failed": "Failed to condense context",
"condense_not_enough_messages": "Not enough messages to condense context",