mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Trying more stuff
This commit is contained in:
parent
fc5479e823
commit
4f0a8accc5
5 changed files with 68 additions and 29 deletions
|
|
@ -18,25 +18,30 @@ export const formatResponse = {
|
|||
rooIgnoreError: (path: string) =>
|
||||
`Access to ${path} is blocked by the .rooignore file settings. You must try to continue in the task without using this file, or ask the user to update the .rooignore file.`,
|
||||
|
||||
noToolsUsed: () =>
|
||||
noToolsUsed: (useNativeTools: boolean = false) =>
|
||||
`[ERROR] You did not use a tool in your previous response! Please retry with a tool use.
|
||||
|
||||
${toolUseInstructionsReminder}
|
||||
${getToolUseInstructionsReminder(useNativeTools)}
|
||||
|
||||
# Next Steps
|
||||
|
||||
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.
|
||||
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.)`,
|
||||
|
||||
tooManyMistakes: (feedback?: string) =>
|
||||
`You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n<feedback>\n${feedback}\n</feedback>`,
|
||||
|
||||
missingToolParameterError: (paramName: string) =>
|
||||
`Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${toolUseInstructionsReminder}`,
|
||||
missingToolParameterError: (paramName: string, useNativeTools: boolean = false) =>
|
||||
`Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${getToolUseInstructionsReminder(useNativeTools)}`,
|
||||
|
||||
lineCountTruncationError: (actualLineCount: number, isNewFile: boolean, diffStrategyEnabled: boolean = false) => {
|
||||
lineCountTruncationError: (
|
||||
actualLineCount: number,
|
||||
isNewFile: boolean,
|
||||
diffStrategyEnabled: boolean = false,
|
||||
useNativeTools: boolean = false,
|
||||
) => {
|
||||
const truncationMessage = `Note: Your response may have been truncated because it exceeded your output limit. You wrote ${actualLineCount} lines of content, but the line_count parameter was either missing or not included in your response.`
|
||||
|
||||
const newFileGuidance =
|
||||
|
|
@ -66,7 +71,7 @@ Otherwise, if you have not completed the task and do not need additional informa
|
|||
`RECOMMENDED APPROACH:\n` +
|
||||
`${existingFileApproaches.join("\n")}\n`
|
||||
|
||||
return `${isNewFile ? newFileGuidance : existingFileGuidance}\n${toolUseInstructionsReminder}`
|
||||
return `${isNewFile ? newFileGuidance : existingFileGuidance}\n${getToolUseInstructionsReminder(useNativeTools)}`
|
||||
},
|
||||
|
||||
invalidMcpToolArgumentError: (serverName: string, toolName: string) =>
|
||||
|
|
@ -200,7 +205,14 @@ const formatImagesIntoBlocks = (images?: string[]): Anthropic.ImageBlockParam[]
|
|||
: []
|
||||
}
|
||||
|
||||
const toolUseInstructionsReminder = `# Reminder: Instructions for Tool Use
|
||||
export function getToolUseInstructionsReminder(useNativeTools: boolean = false): string {
|
||||
if (useNativeTools) {
|
||||
return `# Reminder: Instructions for Tool Use
|
||||
|
||||
When using tools, ensure you provide all required parameters as specified in the tool's schema. The system will validate your tool calls and return errors if required parameters are missing or incorrectly formatted.`
|
||||
}
|
||||
|
||||
return `# Reminder: Instructions for Tool Use
|
||||
|
||||
Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure:
|
||||
|
||||
|
|
@ -219,3 +231,7 @@ I have completed the task...
|
|||
</attempt_completion>
|
||||
|
||||
Always use the actual tool name as the XML tag name for proper parsing and execution.`
|
||||
}
|
||||
|
||||
// Default reminder for backward compatibility (XML mode)
|
||||
const toolUseInstructionsReminder = getToolUseInstructionsReminder()
|
||||
|
|
|
|||
|
|
@ -13,17 +13,29 @@ export function getReadFileToolSpec(settings?: SystemPromptSettings): ToolSpec {
|
|||
description: `Request to read the contents of one or more files. The tool outputs line-numbered content (e.g. "1 | const x = 1") for easy reference when creating diffs or discussing code. Supports text extraction from PDF and DOCX files, but may not handle other binary files properly.\n\n**IMPORTANT: You can read a maximum of ${maxConcurrentFileReads} files in a single request.** If you need to read more files, use multiple sequential read_file requests.`,
|
||||
parameters: [
|
||||
{
|
||||
name: "paths",
|
||||
type: "array",
|
||||
name: "args",
|
||||
type: "object",
|
||||
required: true,
|
||||
description: `Array of file paths to read (maximum ${maxConcurrentFileReads} files, relative to workspace directory)`,
|
||||
items: {
|
||||
type: "string",
|
||||
description: "Contains one or more file elements, where each file contains a path",
|
||||
properties: {
|
||||
file: {
|
||||
type: "array",
|
||||
description: `Array of file objects to read (maximum ${maxConcurrentFileReads} files)`,
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
path: {
|
||||
type: "string",
|
||||
description: "File path (relative to workspace directory)",
|
||||
},
|
||||
},
|
||||
required: ["path"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
// Export a default spec for backward compatibility
|
||||
export const readFileToolSpec = getReadFileToolSpec()
|
||||
|
|
|
|||
|
|
@ -586,6 +586,15 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
return this._taskMode
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether native tool calling is enabled for this task
|
||||
* @returns True if using native tool calls, false for XML-based tools
|
||||
* @public
|
||||
*/
|
||||
public get isUsingNativeToolCalls(): boolean {
|
||||
return this.useNativeToolCalls
|
||||
}
|
||||
|
||||
static create(options: TaskOptions): [Task, Promise<void>] {
|
||||
const instance = new Task({ ...options, startTask: false })
|
||||
const { images, task, historyItem } = options
|
||||
|
|
@ -1218,7 +1227,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
relPath ? ` for '${relPath.toPosix()}'` : ""
|
||||
} without value for required parameter '${paramName}'. Retrying...`,
|
||||
)
|
||||
return formatResponse.toolError(formatResponse.missingToolParameterError(paramName))
|
||||
return formatResponse.toolError(
|
||||
formatResponse.missingToolParameterError(paramName, this.isUsingNativeToolCalls),
|
||||
)
|
||||
}
|
||||
|
||||
// Lifecycle
|
||||
|
|
@ -1746,7 +1757,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
// the user hits max requests and denies resetting the count.
|
||||
break
|
||||
} else {
|
||||
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }]
|
||||
nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed(this.isUsingNativeToolCalls) }]
|
||||
this.consecutiveMistakeCount++
|
||||
}
|
||||
}
|
||||
|
|
@ -2464,7 +2475,10 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
const didToolUse = this.assistantMessageContent.some((block) => block.type === "tool_use")
|
||||
|
||||
if (!didToolUse) {
|
||||
this.userMessageContent.push({ type: "text", text: formatResponse.noToolsUsed() })
|
||||
this.userMessageContent.push({
|
||||
type: "text",
|
||||
text: formatResponse.noToolsUsed(this.isUsingNativeToolCalls),
|
||||
})
|
||||
this.consecutiveMistakeCount++
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,12 @@ export async function writeToFileTool(
|
|||
|
||||
pushToolResult(
|
||||
formatResponse.toolError(
|
||||
formatResponse.lineCountTruncationError(actualLineCount, isNewFile, diffStrategyEnabled),
|
||||
formatResponse.lineCountTruncationError(
|
||||
actualLineCount,
|
||||
isNewFile,
|
||||
diffStrategyEnabled,
|
||||
cline.isUsingNativeToolCalls,
|
||||
),
|
||||
),
|
||||
)
|
||||
await cline.diffViewProvider.revertChanges()
|
||||
|
|
|
|||
|
|
@ -48,15 +48,7 @@ export function formatContentBlockToMarkdown(block: Anthropic.Messages.ContentBl
|
|||
case "image":
|
||||
return `[Image]`
|
||||
case "tool_use": {
|
||||
let input: string
|
||||
if (typeof block.input === "object" && block.input !== null) {
|
||||
input = Object.entries(block.input)
|
||||
.map(([key, value]) => `${key.charAt(0).toUpperCase() + key.slice(1)}: ${value}`)
|
||||
.join("\n")
|
||||
} else {
|
||||
input = String(block.input)
|
||||
}
|
||||
return `[Tool Use: ${block.name}]\n${input}`
|
||||
return `[Tool Use: ${block.name}]\n${JSON.stringify(block.input, null, 2)}`
|
||||
}
|
||||
case "tool_result": {
|
||||
// For now we're not doing tool name lookup since we don't use tools anymore
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue