Skip to content

Commit f7012c7

Browse files
roomoteMerge Resolver
authored andcommitted
fix: hide todos parameter from new_task tool prompt when experiment is disabled
- Modified getNewTaskDescription to completely omit todos parameter when experiment is off - Updated tests to verify todos parameter is not shown at all when disabled - Ensures tool prompt remains unchanged when experimental setting is disabled - Maintains backward compatibility while providing cleaner prompt interface
1 parent ed0abcd commit f7012c7

File tree

2 files changed

+64
-22
lines changed

2 files changed

+64
-22
lines changed

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

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

55
describe("getNewTaskDescription", () => {
6-
it("should show todos as optional when experiment is disabled", () => {
6+
it("should not show todos parameter at all when experiment is disabled", () => {
77
const args: ToolArgs = {
88
cwd: "/test",
99
supportsComputerUse: false,
@@ -14,12 +14,18 @@ describe("getNewTaskDescription", () => {
1414

1515
const description = getNewTaskDescription(args)
1616

17-
// Check that todos is marked as optional
18-
expect(description).toContain("todos: (optional)")
19-
expect(description).toContain("optional initial todo list")
17+
// Check that todos parameter is not mentioned at all
18+
expect(description).not.toContain("todos:")
19+
expect(description).not.toContain("todo list")
20+
expect(description).not.toContain("<todos>")
21+
expect(description).not.toContain("</todos>")
2022

21-
// Should not contain any mention of required
22-
expect(description).not.toContain("todos: (required)")
23+
// Should have a simple example without todos
24+
expect(description).toContain("Implement a new feature for the application")
25+
26+
// Should still have mode and message as required
27+
expect(description).toContain("mode: (required)")
28+
expect(description).toContain("message: (required)")
2329
})
2430

2531
it("should show todos as required when experiment is enabled", () => {
@@ -40,9 +46,14 @@ describe("getNewTaskDescription", () => {
4046
// Should not contain any mention of optional for todos
4147
expect(description).not.toContain("todos: (optional)")
4248
expect(description).not.toContain("optional initial todo list")
49+
50+
// Should include todos in the example
51+
expect(description).toContain("<todos>")
52+
expect(description).toContain("</todos>")
53+
expect(description).toContain("Set up auth middleware")
4354
})
4455

45-
it("should default to optional when experiments is undefined", () => {
56+
it("should not show todos parameter when experiments is undefined", () => {
4657
const args: ToolArgs = {
4758
cwd: "/test",
4859
supportsComputerUse: false,
@@ -51,12 +62,14 @@ describe("getNewTaskDescription", () => {
5162

5263
const description = getNewTaskDescription(args)
5364

54-
// Check that todos is marked as optional by default
55-
expect(description).toContain("todos: (optional)")
56-
expect(description).toContain("optional initial todo list")
65+
// Check that todos parameter is not shown by default
66+
expect(description).not.toContain("todos:")
67+
expect(description).not.toContain("todo list")
68+
expect(description).not.toContain("<todos>")
69+
expect(description).not.toContain("</todos>")
5770
})
5871

59-
it("should default to optional when newTaskRequireTodos is undefined", () => {
72+
it("should not show todos parameter when newTaskRequireTodos is undefined", () => {
6073
const args: ToolArgs = {
6174
cwd: "/test",
6275
supportsComputerUse: false,
@@ -65,12 +78,14 @@ describe("getNewTaskDescription", () => {
6578

6679
const description = getNewTaskDescription(args)
6780

68-
// Check that todos is marked as optional by default
69-
expect(description).toContain("todos: (optional)")
70-
expect(description).toContain("optional initial todo list")
81+
// Check that todos parameter is not shown by default
82+
expect(description).not.toContain("todos:")
83+
expect(description).not.toContain("todo list")
84+
expect(description).not.toContain("<todos>")
85+
expect(description).not.toContain("</todos>")
7186
})
7287

73-
it("should always include the example with todos", () => {
88+
it("should only include todos in example when experiment is enabled", () => {
7489
const argsWithExperimentOff: ToolArgs = {
7590
cwd: "/test",
7691
supportsComputerUse: false,
@@ -90,9 +105,13 @@ describe("getNewTaskDescription", () => {
90105
const descriptionOff = getNewTaskDescription(argsWithExperimentOff)
91106
const descriptionOn = getNewTaskDescription(argsWithExperimentOn)
92107

93-
// Both should include the example with todos
94-
const examplePattern = /<todos>\s*\[\s*\]\s*Set up auth middleware/s
95-
expect(descriptionOff).toMatch(examplePattern)
96-
expect(descriptionOn).toMatch(examplePattern)
108+
// When experiment is off, should NOT include todos in example
109+
const todosPattern = /<todos>\s*\[\s*\]\s*Set up auth middleware/s
110+
expect(descriptionOff).not.toMatch(todosPattern)
111+
expect(descriptionOff).not.toContain("<todos>")
112+
113+
// When experiment is on, should include todos in example
114+
expect(descriptionOn).toMatch(todosPattern)
115+
expect(descriptionOn).toContain("<todos>")
97116
})
98117
})

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,38 @@ import { ToolArgs } from "./types"
22

33
export function getNewTaskDescription(args: ToolArgs): string {
44
const todosRequired = args.experiments?.newTaskRequireTodos === true
5-
const todosStatus = todosRequired ? "(required)" : "(optional)"
65

6+
// When experiment is disabled, don't show todos parameter at all
7+
if (!todosRequired) {
8+
return `## new_task
9+
Description: This will let you create a new task instance in the chosen mode using your provided message.
10+
11+
Parameters:
12+
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
13+
- message: (required) The initial user message or instructions for this new task.
14+
15+
Usage:
16+
<new_task>
17+
<mode>your-mode-slug-here</mode>
18+
<message>Your initial instructions here</message>
19+
</new_task>
20+
21+
Example:
22+
<new_task>
23+
<mode>code</mode>
24+
<message>Implement a new feature for the application.</message>
25+
</new_task>
26+
`
27+
}
28+
29+
// When experiment is enabled, show todos as required
730
return `## new_task
8-
Description: This will let you create a new task instance in the chosen mode using your provided message${todosRequired ? " and initial todo list" : " and optional initial todo list"}.
31+
Description: This will let you create a new task instance in the chosen mode using your provided message and initial todo list.
932
1033
Parameters:
1134
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
1235
- message: (required) The initial user message or instructions for this new task.
13-
- todos: ${todosStatus} The initial todo list in markdown checklist format for the new task.
36+
- todos: (required) The initial todo list in markdown checklist format for the new task.
1437
1538
Usage:
1639
<new_task>

0 commit comments

Comments
 (0)