Make system prompt conditional on native tool calls

This commit is contained in:
Matt Rubens 2025-10-29 23:32:26 -04:00
parent 34c39c8f70
commit fc5479e823
6 changed files with 24 additions and 20 deletions

View file

@ -63,7 +63,6 @@ describe("SYSTEM_PROMPT with native tools", () => {
false,
{ ...defaultSettings, todoListEnabled: false },
undefined,
undefined,
true, // useNativeTools
)
@ -99,7 +98,6 @@ describe("SYSTEM_PROMPT with native tools", () => {
false,
{ ...defaultSettings, todoListEnabled: true },
undefined,
undefined,
true, // useNativeTools
)
@ -135,7 +133,6 @@ describe("SYSTEM_PROMPT with native tools", () => {
false,
undefined,
undefined,
undefined,
true, // useNativeTools
)
@ -171,7 +168,6 @@ describe("SYSTEM_PROMPT with native tools", () => {
false,
undefined,
undefined,
undefined,
true, // useNativeTools
)
@ -207,7 +203,6 @@ describe("SYSTEM_PROMPT with native tools", () => {
false,
undefined,
undefined,
undefined,
true, // useNativeTools
)

View file

@ -1,6 +1,9 @@
import { CodeIndexManager } from "../../../services/code-index/manager"
export function getToolUseGuidelinesSection(codeIndexManager?: CodeIndexManager): string {
export function getToolUseGuidelinesSection(
codeIndexManager?: CodeIndexManager,
useNativeTools: boolean = false,
): string {
const isCodebaseSearchAvailable =
codeIndexManager &&
codeIndexManager.isFeatureEnabled &&
@ -34,7 +37,12 @@ export function getToolUseGuidelinesSection(codeIndexManager?: CodeIndexManager)
guidelinesList.push(
`${itemNumber++}. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.`,
)
guidelinesList.push(`${itemNumber++}. Formulate your tool use using the XML format specified for each tool.`)
// Only include XML format guideline for XML-based tools
if (!useNativeTools) {
guidelinesList.push(`${itemNumber++}. Formulate your tool use using the XML format specified for each tool.`)
}
guidelinesList.push(`${itemNumber++}. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
- Information about whether the tool succeeded or failed, along with any reasons for failure.
- Linter errors that may have arisen due to the changes you made, which you'll need to address.

View file

@ -1,9 +1,7 @@
export function getSharedToolUseSection(): string {
return `====
TOOL USE
You have access to a set of tools that are executed upon the user's approval. You must use exactly one tool per message, and every assistant message must include a tool call. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
export function getSharedToolUseSection(useNativeTools: boolean = false): string {
const xmlFormatting = useNativeTools
? ""
: `
# Tool Use Formatting
@ -16,4 +14,10 @@ Tool uses are formatted using XML-style tags. The tool name itself becomes the X
</actual_tool_name>
Always use the actual tool name as the XML tag name for proper parsing and execution.`
return `====
TOOL USE
You have access to a set of tools that are executed upon the user's approval. You must use exactly one tool per message, and every assistant message must include a tool call. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.${xmlFormatting}`
}

View file

@ -62,8 +62,8 @@ async function generatePrompt(
rooIgnoreInstructions?: string,
partialReadsEnabled?: boolean,
settings?: SystemPromptSettings,
todoList?: TodoItem[],
modelId?: string,
useNativeTools?: boolean,
): Promise<string> {
if (!context) {
throw new Error("Extension context is required for generating system prompt")
@ -94,7 +94,7 @@ async function generatePrompt(
${markdownFormattingSection()}
${getSharedToolUseSection()}
${getSharedToolUseSection(useNativeTools)}
${getToolDescriptionsForMode(
mode,
@ -112,7 +112,7 @@ ${getToolDescriptionsForMode(
modelId,
)}
${getToolUseGuidelinesSection(codeIndexManager)}
${getToolUseGuidelinesSection(codeIndexManager, useNativeTools)}
${mcpServersSection}
@ -153,7 +153,6 @@ export const SYSTEM_PROMPT = async (
rooIgnoreInstructions?: string,
partialReadsEnabled?: boolean,
settings?: SystemPromptSettings,
todoList?: TodoItem[],
modelId?: string,
useNativeTools?: boolean,
): Promise<{ systemPrompt: string; tools?: ToolSpec[] }> => {
@ -228,8 +227,8 @@ ${customInstructions}`,
rooIgnoreInstructions,
partialReadsEnabled,
settings,
todoList,
modelId,
useNativeTools,
)
// If native tools are enabled, build tool specifications and return them with the prompt

View file

@ -2598,7 +2598,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
.getConfiguration("roo-cline")
.get<boolean>("newTaskRequireTodos", false),
},
undefined, // todoList
this.api.getModel().id,
useNativeTools,
)

View file

@ -101,7 +101,6 @@ export const generateSystemPrompt = async (provider: ClineProvider, message: Web
.getConfiguration("roo-cline")
.get<boolean>("newTaskRequireTodos", false),
},
undefined, // todoList
undefined, // modelId
useNativeTools,
)