Skip to content

Commit 1781044

Browse files
author
Merge Resolver
committed
fix: make new_task tool description dynamically reflect VSCode setting
- Updated new-task.ts to check args.settings instead of args.experiments - Added newTaskRequireTodos to SystemPromptSettings interface - Pass newTaskRequireTodos setting through Task.ts and generateSystemPrompt.ts - Updated all related tests to use settings instead of experiments - Fixed TypeScript errors in test files by adding newTaskRequireTodos property This ensures the tool description correctly shows todos parameter as required/optional based on the VSCode setting value, fixing the issue where Roo would try to use new_task without the todos parameter when it was required.
1 parent bbf71de commit 1781044

File tree

7 files changed

+93
-27
lines changed

7 files changed

+93
-27
lines changed

src/core/prompts/__tests__/system-prompt.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ describe("SYSTEM_PROMPT", () => {
580580
maxConcurrentFileReads: 5,
581581
todoListEnabled: false,
582582
useAgentRules: true,
583+
newTaskRequireTodos: false,
583584
}
584585

585586
const prompt = await SYSTEM_PROMPT(
@@ -612,6 +613,7 @@ describe("SYSTEM_PROMPT", () => {
612613
maxConcurrentFileReads: 5,
613614
todoListEnabled: true,
614615
useAgentRules: true,
616+
newTaskRequireTodos: false,
615617
}
616618

617619
const prompt = await SYSTEM_PROMPT(
@@ -643,6 +645,7 @@ describe("SYSTEM_PROMPT", () => {
643645
maxConcurrentFileReads: 5,
644646
todoListEnabled: true,
645647
useAgentRules: true,
648+
newTaskRequireTodos: false,
646649
}
647650

648651
const prompt = await SYSTEM_PROMPT(

src/core/prompts/sections/__tests__/custom-instructions.spec.ts

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,14 @@ describe("addCustomInstructions", () => {
535535
"global instructions",
536536
"/fake/path",
537537
"test-mode",
538-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
538+
{
539+
settings: {
540+
maxConcurrentFileReads: 5,
541+
todoListEnabled: true,
542+
useAgentRules: true,
543+
newTaskRequireTodos: false,
544+
},
545+
},
539546
)
540547

541548
expect(result).toContain("# Agent Rules Standard (AGENTS.md):")
@@ -560,7 +567,14 @@ describe("addCustomInstructions", () => {
560567
"global instructions",
561568
"/fake/path",
562569
"test-mode",
563-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: false } },
570+
{
571+
settings: {
572+
maxConcurrentFileReads: 5,
573+
todoListEnabled: true,
574+
useAgentRules: false,
575+
newTaskRequireTodos: false,
576+
},
577+
},
564578
)
565579

566580
expect(result).not.toContain("# Agent Rules Standard (AGENTS.md):")
@@ -614,7 +628,14 @@ describe("addCustomInstructions", () => {
614628
"global instructions",
615629
"/fake/path",
616630
"test-mode",
617-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
631+
{
632+
settings: {
633+
maxConcurrentFileReads: 5,
634+
todoListEnabled: true,
635+
useAgentRules: true,
636+
newTaskRequireTodos: false,
637+
},
638+
},
618639
)
619640

620641
expect(result).toContain("Global Instructions:\nglobal instructions")
@@ -653,7 +674,14 @@ describe("addCustomInstructions", () => {
653674
"global instructions",
654675
"/fake/path",
655676
"test-mode",
656-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
677+
{
678+
settings: {
679+
maxConcurrentFileReads: 5,
680+
todoListEnabled: true,
681+
useAgentRules: true,
682+
newTaskRequireTodos: false,
683+
},
684+
},
657685
)
658686

659687
// Should contain both AGENTS.md and .roorules content
@@ -714,7 +742,14 @@ describe("addCustomInstructions", () => {
714742
"global instructions",
715743
"/fake/path",
716744
"test-mode",
717-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
745+
{
746+
settings: {
747+
maxConcurrentFileReads: 5,
748+
todoListEnabled: true,
749+
useAgentRules: true,
750+
newTaskRequireTodos: false,
751+
},
752+
},
718753
)
719754

720755
expect(result).toContain("# Agent Rules Standard (AGENTS.md):")
@@ -759,7 +794,14 @@ describe("addCustomInstructions", () => {
759794
"global instructions",
760795
"/fake/path",
761796
"test-mode",
762-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
797+
{
798+
settings: {
799+
maxConcurrentFileReads: 5,
800+
todoListEnabled: true,
801+
useAgentRules: true,
802+
newTaskRequireTodos: false,
803+
},
804+
},
763805
)
764806

765807
expect(result).toContain("# Agent Rules Standard (AGENTS.md):")
@@ -806,7 +848,14 @@ describe("addCustomInstructions", () => {
806848
"global instructions",
807849
"/fake/path",
808850
"test-mode",
809-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
851+
{
852+
settings: {
853+
maxConcurrentFileReads: 5,
854+
todoListEnabled: true,
855+
useAgentRules: true,
856+
newTaskRequireTodos: false,
857+
},
858+
},
810859
)
811860

812861
expect(result).toContain("# Agent Rules Standard (AGENT.md):")
@@ -845,7 +894,14 @@ describe("addCustomInstructions", () => {
845894
"global instructions",
846895
"/fake/path",
847896
"test-mode",
848-
{ settings: { maxConcurrentFileReads: 5, todoListEnabled: true, useAgentRules: true } },
897+
{
898+
settings: {
899+
maxConcurrentFileReads: 5,
900+
todoListEnabled: true,
901+
useAgentRules: true,
902+
newTaskRequireTodos: false,
903+
},
904+
},
849905
)
850906

851907
// Should contain AGENTS.md content (preferred) and not AGENT.md

src/core/prompts/tools/__tests__/new-task.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { getNewTaskDescription } from "../new-task"
33
import { ToolArgs } from "../types"
44

55
describe("getNewTaskDescription", () => {
6-
it("should not show todos parameter at all when experiment is disabled", () => {
6+
it("should not show todos parameter at all when setting is disabled", () => {
77
const args: ToolArgs = {
88
cwd: "/test",
99
supportsComputerUse: false,
10-
experiments: {
10+
settings: {
1111
newTaskRequireTodos: false,
1212
},
1313
}
@@ -28,11 +28,11 @@ describe("getNewTaskDescription", () => {
2828
expect(description).toContain("message: (required)")
2929
})
3030

31-
it("should show todos as required when experiment is enabled", () => {
31+
it("should show todos as required when setting is enabled", () => {
3232
const args: ToolArgs = {
3333
cwd: "/test",
3434
supportsComputerUse: false,
35-
experiments: {
35+
settings: {
3636
newTaskRequireTodos: true,
3737
},
3838
}
@@ -53,11 +53,11 @@ describe("getNewTaskDescription", () => {
5353
expect(description).toContain("Set up auth middleware")
5454
})
5555

56-
it("should not show todos parameter when experiments is undefined", () => {
56+
it("should not show todos parameter when settings is undefined", () => {
5757
const args: ToolArgs = {
5858
cwd: "/test",
5959
supportsComputerUse: false,
60-
experiments: undefined,
60+
settings: undefined,
6161
}
6262

6363
const description = getNewTaskDescription(args)
@@ -73,7 +73,7 @@ describe("getNewTaskDescription", () => {
7373
const args: ToolArgs = {
7474
cwd: "/test",
7575
supportsComputerUse: false,
76-
experiments: {},
76+
settings: {},
7777
}
7878

7979
const description = getNewTaskDescription(args)
@@ -85,32 +85,32 @@ describe("getNewTaskDescription", () => {
8585
expect(description).not.toContain("</todos>")
8686
})
8787

88-
it("should only include todos in example when experiment is enabled", () => {
89-
const argsWithExperimentOff: ToolArgs = {
88+
it("should only include todos in example when setting is enabled", () => {
89+
const argsWithSettingOff: ToolArgs = {
9090
cwd: "/test",
9191
supportsComputerUse: false,
92-
experiments: {
92+
settings: {
9393
newTaskRequireTodos: false,
9494
},
9595
}
9696

97-
const argsWithExperimentOn: ToolArgs = {
97+
const argsWithSettingOn: ToolArgs = {
9898
cwd: "/test",
9999
supportsComputerUse: false,
100-
experiments: {
100+
settings: {
101101
newTaskRequireTodos: true,
102102
},
103103
}
104104

105-
const descriptionOff = getNewTaskDescription(argsWithExperimentOff)
106-
const descriptionOn = getNewTaskDescription(argsWithExperimentOn)
105+
const descriptionOff = getNewTaskDescription(argsWithSettingOff)
106+
const descriptionOn = getNewTaskDescription(argsWithSettingOn)
107107

108-
// When experiment is off, should NOT include todos in example
108+
// When setting is off, should NOT include todos in example
109109
const todosPattern = /<todos>\s*\[\s*\]\s*Set up auth middleware/s
110110
expect(descriptionOff).not.toMatch(todosPattern)
111111
expect(descriptionOff).not.toContain("<todos>")
112112

113-
// When experiment is on, should include todos in example
113+
// When setting is on, should include todos in example
114114
expect(descriptionOn).toMatch(todosPattern)
115115
expect(descriptionOn).toContain("<todos>")
116116
})

src/core/prompts/tools/new-task.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ToolArgs } from "./types"
22

33
export function getNewTaskDescription(args: ToolArgs): string {
4-
const todosRequired = args.experiments?.newTaskRequireTodos === true
4+
const todosRequired = args.settings?.newTaskRequireTodos === true
55

6-
// When experiment is disabled, don't show todos parameter at all
6+
// When setting is disabled, don't show todos parameter at all
77
if (!todosRequired) {
88
return `## new_task
99
Description: This will let you create a new task instance in the chosen mode using your provided message.
@@ -26,7 +26,7 @@ Example:
2626
`
2727
}
2828

29-
// When experiment is enabled, show todos as required
29+
// When setting is enabled, show todos as required
3030
return `## new_task
3131
Description: This will let you create a new task instance in the chosen mode using your provided message and initial todo list.
3232

src/core/prompts/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export interface SystemPromptSettings {
55
maxConcurrentFileReads: number
66
todoListEnabled: boolean
77
useAgentRules: boolean
8+
newTaskRequireTodos: boolean
89
}

src/core/task/Task.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
22362236
maxConcurrentFileReads: maxConcurrentFileReads ?? 5,
22372237
todoListEnabled: apiConfiguration?.todoListEnabled ?? true,
22382238
useAgentRules: vscode.workspace.getConfiguration("roo-cline").get<boolean>("useAgentRules") ?? true,
2239+
newTaskRequireTodos: vscode.workspace
2240+
.getConfiguration("roo-cline")
2241+
.get<boolean>("newTaskRequireTodos", false),
22392242
},
22402243
undefined, // todoList
22412244
this.api.getModel().id,

src/core/webview/generateSystemPrompt.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export const generateSystemPrompt = async (provider: ClineProvider, message: Web
8585
maxConcurrentFileReads: maxConcurrentFileReads ?? 5,
8686
todoListEnabled: apiConfiguration?.todoListEnabled ?? true,
8787
useAgentRules: vscode.workspace.getConfiguration("roo-cline").get<boolean>("useAgentRules") ?? true,
88+
newTaskRequireTodos: vscode.workspace
89+
.getConfiguration("roo-cline")
90+
.get<boolean>("newTaskRequireTodos", false),
8891
},
8992
)
9093

0 commit comments

Comments
 (0)