Skip to content

Commit 7269671

Browse files
committed
fix: make new_task tool definition dynamic based on experimental setting
- Tool description now changes based on newTaskRequireTodos setting - When disabled: shows todos as (optional) - When enabled: shows todos as (required) with no mention of configuration - Added tests to verify dynamic behavior - Ensures AI models get unambiguous instructions based on current settings
1 parent cfd3cac commit 7269671

File tree

2 files changed

+104
-4
lines changed

2 files changed

+104
-4
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { describe, it, expect } from "vitest"
2+
import { getNewTaskDescription } from "../new-task"
3+
import { ToolArgs } from "../types"
4+
5+
describe("getNewTaskDescription", () => {
6+
it("should show todos as optional when experiment is disabled", () => {
7+
const args: ToolArgs = {
8+
cwd: "/test",
9+
supportsComputerUse: false,
10+
experiments: {
11+
newTaskRequireTodos: false,
12+
},
13+
}
14+
15+
const description = getNewTaskDescription(args)
16+
17+
// Check that todos is marked as optional
18+
expect(description).toContain("todos: (optional)")
19+
expect(description).toContain("optional initial todo list")
20+
21+
// Should not contain any mention of required
22+
expect(description).not.toContain("todos: (required)")
23+
})
24+
25+
it("should show todos as required when experiment is enabled", () => {
26+
const args: ToolArgs = {
27+
cwd: "/test",
28+
supportsComputerUse: false,
29+
experiments: {
30+
newTaskRequireTodos: true,
31+
},
32+
}
33+
34+
const description = getNewTaskDescription(args)
35+
36+
// Check that todos is marked as required
37+
expect(description).toContain("todos: (required)")
38+
expect(description).toContain("and initial todo list")
39+
40+
// Should not contain any mention of optional for todos
41+
expect(description).not.toContain("todos: (optional)")
42+
expect(description).not.toContain("optional initial todo list")
43+
})
44+
45+
it("should default to optional when experiments is undefined", () => {
46+
const args: ToolArgs = {
47+
cwd: "/test",
48+
supportsComputerUse: false,
49+
experiments: undefined,
50+
}
51+
52+
const description = getNewTaskDescription(args)
53+
54+
// Check that todos is marked as optional by default
55+
expect(description).toContain("todos: (optional)")
56+
expect(description).toContain("optional initial todo list")
57+
})
58+
59+
it("should default to optional when newTaskRequireTodos is undefined", () => {
60+
const args: ToolArgs = {
61+
cwd: "/test",
62+
supportsComputerUse: false,
63+
experiments: {},
64+
}
65+
66+
const description = getNewTaskDescription(args)
67+
68+
// Check that todos is marked as optional by default
69+
expect(description).toContain("todos: (optional)")
70+
expect(description).toContain("optional initial todo list")
71+
})
72+
73+
it("should always include the example with todos", () => {
74+
const argsWithExperimentOff: ToolArgs = {
75+
cwd: "/test",
76+
supportsComputerUse: false,
77+
experiments: {
78+
newTaskRequireTodos: false,
79+
},
80+
}
81+
82+
const argsWithExperimentOn: ToolArgs = {
83+
cwd: "/test",
84+
supportsComputerUse: false,
85+
experiments: {
86+
newTaskRequireTodos: true,
87+
},
88+
}
89+
90+
const descriptionOff = getNewTaskDescription(argsWithExperimentOff)
91+
const descriptionOn = getNewTaskDescription(argsWithExperimentOn)
92+
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)
97+
})
98+
})

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

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

3-
export function getNewTaskDescription(_args: ToolArgs): string {
3+
export function getNewTaskDescription(args: ToolArgs): string {
4+
const todosRequired = args.experiments?.newTaskRequireTodos === true
5+
const todosStatus = todosRequired ? "(required)" : "(optional)"
6+
47
return `## new_task
5-
Description: This will let you create a new task instance in the chosen mode using your provided message and optional initial todo list.
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"}.
69
710
Parameters:
811
- mode: (required) The slug of the mode to start the new task in (e.g., "code", "debug", "architect").
912
- message: (required) The initial user message or instructions for this new task.
10-
- todos: (optional by default, can be required via experimental setting) The initial todo list in markdown checklist format for the new task.
11-
Note: The 'todos' parameter can be configured to be required through the experimental setting 'newTaskRequireTodos'.
13+
- todos: ${todosStatus} The initial todo list in markdown checklist format for the new task.
1214
1315
Usage:
1416
<new_task>

0 commit comments

Comments
 (0)