fix: include tool descriptions in custom system prompts for code-supernova

- Modified system prompt generation to always include tool descriptions even when using custom system prompt files
- This fixes the issue where code-supernova model would fail to parse read_file tool parameters when using custom prompts
- Updated tests to reflect the new behavior
- Ensures models like code-supernova that require simplified tool formats get the proper tool descriptions

Fixes #8307
This commit is contained in:
Roo Code 2025-09-25 14:24:48 +00:00
parent 37a175c4ed
commit 1569b469c7
3 changed files with 95 additions and 7 deletions

1
.tmp/Roo-Code Submodule

@ -0,0 +1 @@
Subproject commit 86debeef43acbea9bdc1aa4b38d514541e164c91

View file

@ -154,9 +154,9 @@ describe("File-Based Custom System Prompt", () => {
expect(prompt).toContain(modes[0].roleDefinition)
expect(prompt).toContain(fileCustomSystemPrompt)
// Should not contain any of the default sections
expect(prompt).not.toContain("CAPABILITIES")
expect(prompt).not.toContain("MODES")
// After the fix, should now contain tool sections for proper tool usage
expect(prompt).toContain("TOOL USE")
expect(prompt).toContain("# Tools")
})
it("should combine file-based system prompt with role definition and custom instructions", async () => {
@ -200,8 +200,57 @@ describe("File-Based Custom System Prompt", () => {
expect(prompt).toContain(customRoleDefinition)
expect(prompt).toContain(fileCustomSystemPrompt)
// Should not contain any of the default sections
expect(prompt).not.toContain("CAPABILITIES")
expect(prompt).not.toContain("MODES")
// After the fix, should now contain tool sections for proper tool usage
expect(prompt).toContain("TOOL USE")
expect(prompt).toContain("# Tools")
})
it("should include simplified read_file tool for code-supernova model with custom prompt", async () => {
// Mock the readFile to return content from a file
const fileCustomSystemPrompt = "Custom system prompt for code-supernova"
mockedFs.readFile.mockImplementation((filePath, options) => {
if (toPosix(filePath).includes(`.roo/system-prompt-${defaultModeSlug}`) && options === "utf-8") {
return Promise.resolve(fileCustomSystemPrompt)
}
return Promise.reject({ code: "ENOENT" })
})
const prompt = await SYSTEM_PROMPT(
mockContext,
"test/path",
false, // supportsComputerUse
undefined, // mcpHub
undefined, // diffStrategy
undefined, // browserViewportSize
defaultModeSlug, // mode
undefined, // customModePrompts
undefined, // customModes
undefined, // globalCustomInstructions
undefined, // diffEnabled
undefined, // experiments
true, // enableMcpServerCreation
undefined, // language
undefined, // rooIgnoreInstructions
undefined, // partialReadsEnabled
undefined, // settings
undefined, // todoList
"roo/code-supernova", // modelId - this is the key for this test
)
// Should contain the custom system prompt
expect(prompt).toContain(fileCustomSystemPrompt)
// Should contain tool descriptions
expect(prompt).toContain("# Tools")
expect(prompt).toContain("## read_file")
// Should contain the simplified read_file format for code-supernova
expect(prompt).toContain("<read_file>")
expect(prompt).toContain("<path>path/to/file</path>")
expect(prompt).toContain("</read_file>")
// Should NOT contain the complex multi-file read format
expect(prompt).not.toContain("<args>")
expect(prompt).not.toContain("You can read a maximum of 5 files")
})
})

View file

@ -194,9 +194,47 @@ export const SYSTEM_PROMPT = async (
},
)
// For file-based prompts, don't include the tool sections
// Get the full mode config to ensure we have the role definition (used for groups, etc.)
const modeConfig = getModeBySlug(mode, customModes) || modes.find((m) => m.slug === mode) || modes[0]
// Check if MCP functionality should be included
const hasMcpGroup = modeConfig.groups.some((groupEntry) => getGroupName(groupEntry) === "mcp")
const hasMcpServers = mcpHub && mcpHub.getServers().length > 0
const shouldIncludeMcp = hasMcpGroup && hasMcpServers
// If diff is disabled, don't pass the diffStrategy
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
const codeIndexManager = CodeIndexManager.getInstance(context, cwd)
// Always include tool descriptions for file-based custom prompts
// This ensures models like code-supernova get the proper tool format
const toolDescriptions = getToolDescriptionsForMode(
mode,
cwd,
supportsComputerUse,
codeIndexManager,
effectiveDiffStrategy,
browserViewportSize,
shouldIncludeMcp ? mcpHub : undefined,
customModes,
experiments,
partialReadsEnabled,
settings,
enableMcpServerCreation,
modelId,
)
return `${roleDefinition}
${markdownFormattingSection()}
${getSharedToolUseSection()}
${toolDescriptions}
${getToolUseGuidelinesSection(codeIndexManager)}
${fileCustomSystemPrompt}
${customInstructions}`