Skip to content

Commit 7d8a05f

Browse files
committed
fix: remove conditional language about tool availability in architect mode instructions
- Created getArchitectModeInstructions() function to generate different instructions based on enableTodoList setting - When enabled: "Create a todo list using the update_todo_list tool" - When disabled: "Document your plan in a clear, structured format" - Updated getModeSelection() to conditionally apply these instructions for architect mode - Modified system prompt generation to pass settings to mode selection - Addresses issue where conditional language about tool availability created confusion when feature is disabled Fixes inconsistency raised in PR #5624 comment by @daniel-lxs
1 parent fb92feb commit 7d8a05f

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

src/core/prompts/system.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function generatePrompt(
6868

6969
// Get the full mode config to ensure we have the role definition (used for groups, etc.)
7070
const modeConfig = getModeBySlug(mode, customModeConfigs) || modes.find((m) => m.slug === mode) || modes[0]
71-
const { roleDefinition, baseInstructions } = getModeSelection(mode, promptComponent, customModeConfigs)
71+
const { roleDefinition, baseInstructions } = getModeSelection(mode, promptComponent, customModeConfigs, settings)
7272

7373
const [modesSection, mcpServersSection] = await Promise.all([
7474
getModesSection(context),
@@ -163,6 +163,7 @@ export const SYSTEM_PROMPT = async (
163163
mode,
164164
promptComponent,
165165
customModes,
166+
settings,
166167
)
167168

168169
const customInstructions = await addCustomInstructions(

src/shared/modes.ts

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const modes: readonly ModeConfig[] = [
7272
description: "Plan and design before implementation",
7373
groups: ["read", ["edit", { fileRegex: "\\.md$", description: "Markdown files only" }], "browser", "mcp"],
7474
customInstructions:
75-
"1. Do some information gathering (using provided tools) to get more context about the task.\n\n2. You should also ask the user clarifying questions to get a better understanding of the task.\n\n3. Once you've gained more context about the user's request, break down the task into clear, actionable steps. If the `update_todo_list` tool is available, create a todo list using it. Each todo item should be:\n - Specific and actionable\n - Listed in logical execution order\n - Focused on a single, well-defined outcome\n - Clear enough that another mode could execute it independently\n\n4. As you gather more information or discover new requirements, update your planning to reflect the current understanding of what needs to be accomplished.\n\n5. Ask the user if they are pleased with this plan, or if they would like to make any changes. Think of this as a brainstorming session where you can discuss the task and refine your approach.\n\n6. Include Mermaid diagrams if they help clarify complex workflows or system architecture. Please avoid using double quotes (\"\") and parentheses () inside square brackets ([]) in Mermaid diagrams, as this can cause parsing errors.\n\n7. Use the switch_mode tool to request that the user switch to another mode to implement the solution.\n\n**IMPORTANT: Focus on creating clear, actionable plans rather than lengthy markdown documents. Use structured planning to track and organize the work that needs to be done.**",
75+
"1. Do some information gathering (using provided tools) to get more context about the task.\n\n2. You should also ask the user clarifying questions to get a better understanding of the task.\n\n3. Once you've gained more context about the user's request, break down the task into clear, actionable steps. Create a todo list using the update_todo_list tool. Each todo item should be:\n - Specific and actionable\n - Listed in logical execution order\n - Focused on a single, well-defined outcome\n - Clear enough that another mode could execute it independently\n\n4. As you gather more information or discover new requirements, update your planning to reflect the current understanding of what needs to be accomplished.\n\n5. Ask the user if they are pleased with this plan, or if they would like to make any changes. Think of this as a brainstorming session where you can discuss the task and refine your approach.\n\n6. Include Mermaid diagrams if they help clarify complex workflows or system architecture. Please avoid using double quotes (\"\") and parentheses () inside square brackets ([]) in Mermaid diagrams, as this can cause parsing errors.\n\n7. Use the switch_mode tool to request that the user switch to another mode to implement the solution.\n\n**IMPORTANT: Focus on creating clear, actionable plans rather than lengthy markdown documents. Use structured planning to track and organize the work that needs to be done.**",
7676
},
7777
{
7878
slug: "code",
@@ -186,7 +186,12 @@ export function findModeBySlug(slug: string, modes: readonly ModeConfig[] | unde
186186
* If no custom mode is found, the built-in mode is used with partial merging from promptComponent.
187187
* If neither is found, the default mode is used.
188188
*/
189-
export function getModeSelection(mode: string, promptComponent?: PromptComponent, customModes?: ModeConfig[]) {
189+
export function getModeSelection(
190+
mode: string,
191+
promptComponent?: PromptComponent,
192+
customModes?: ModeConfig[],
193+
settings?: Record<string, any>,
194+
) {
190195
const customMode = findModeBySlug(mode, customModes)
191196
const builtInMode = findModeBySlug(mode, modes)
192197

@@ -202,13 +207,59 @@ export function getModeSelection(mode: string, promptComponent?: PromptComponent
202207
// Otherwise, use built-in mode as base and merge with promptComponent
203208
const baseMode = builtInMode || modes[0] // fallback to default mode
204209

210+
// Get base instructions, applying conditional logic for architect mode
211+
let baseInstructions = promptComponent?.customInstructions || baseMode.customInstructions || ""
212+
213+
// Apply conditional instructions for architect mode based on enableTodoList setting
214+
// Only apply this if there's no promptComponent override for customInstructions
215+
if (mode === "architect" && !promptComponent?.customInstructions) {
216+
baseInstructions = getArchitectModeInstructions(settings?.enableTodoList !== false)
217+
}
218+
205219
return {
206220
roleDefinition: promptComponent?.roleDefinition || baseMode.roleDefinition || "",
207-
baseInstructions: promptComponent?.customInstructions || baseMode.customInstructions || "",
221+
baseInstructions,
208222
description: baseMode.description || "",
209223
}
210224
}
211225

226+
/**
227+
* Get architect mode instructions based on whether todo list feature is enabled
228+
*/
229+
function getArchitectModeInstructions(enableTodoList: boolean): string {
230+
const baseInstructions = `1. Do some information gathering (using provided tools) to get more context about the task.
231+
232+
2. You should also ask the user clarifying questions to get a better understanding of the task.
233+
234+
3. Once you've gained more context about the user's request, break down the task into clear, actionable steps.`
235+
236+
const todoListInstructions = enableTodoList
237+
? ` Create a todo list using the update_todo_list tool. Each todo item should be:
238+
- Specific and actionable
239+
- Listed in logical execution order
240+
- Focused on a single, well-defined outcome
241+
- Clear enough that another mode could execute it independently`
242+
: ` Document your plan in a clear, structured format. Each step should be:
243+
- Specific and actionable
244+
- Listed in logical execution order
245+
- Focused on a single, well-defined outcome
246+
- Clear enough that another mode could execute it independently`
247+
248+
const remainingInstructions = `
249+
250+
4. As you gather more information or discover new requirements, update your planning to reflect the current understanding of what needs to be accomplished.
251+
252+
5. Ask the user if they are pleased with this plan, or if they would like to make any changes. Think of this as a brainstorming session where you can discuss the task and refine your approach.
253+
254+
6. Include Mermaid diagrams if they help clarify complex workflows or system architecture. Please avoid using double quotes ("") and parentheses () inside square brackets ([]) in Mermaid diagrams, as this can cause parsing errors.
255+
256+
7. Use the switch_mode tool to request that the user switch to another mode to implement the solution.
257+
258+
**IMPORTANT: Focus on creating clear, actionable plans rather than lengthy markdown documents. Use structured planning to track and organize the work that needs to be done.**`
259+
260+
return baseInstructions + todoListInstructions + remainingInstructions
261+
}
262+
212263
// Edit operation parameters that indicate an actual edit operation
213264
const EDIT_OPERATION_PARAMS = ["diff", "content", "operations", "search", "replace", "args", "line"] as const
214265

0 commit comments

Comments
 (0)