Skip to content

Commit 0774f60

Browse files
authored
feat(plan): enable AskUser tool in Plan mode for clarifying questions (#17694)
1 parent 771ece0 commit 0774f60

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

packages/core/src/core/__snapshots__/prompts.test.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ The following read-only tools are available in Plan Mode:
185185
186186
### Phase 1: Requirements Understanding
187187
- Analyze the user's request to identify core requirements and constraints
188-
- If critical information is missing or ambiguous, ask ONE clarifying question at a time
188+
- If critical information is missing or ambiguous, ask clarifying questions using the \`ask_user\` tool
189+
- When using \`ask_user\`, prefer providing multiple-choice options for the user to select from when possible
189190
- Do NOT explore the project or create a plan yet
190191
191192
### Phase 2: Project Exploration

packages/core/src/core/prompts.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,19 @@ describe('Core System Prompt (prompts.ts)', () => {
274274

275275
it('should only list available tools in PLAN mode', () => {
276276
vi.mocked(mockConfig.getApprovalMode).mockReturnValue(ApprovalMode.PLAN);
277-
// Only enable glob and read_file, disable others (like web search)
277+
// Only enable a subset of tools, including ask_user
278278
vi.mocked(mockConfig.getToolRegistry().getAllToolNames).mockReturnValue([
279279
'glob',
280280
'read_file',
281+
'ask_user',
281282
]);
282283

283284
const prompt = getCoreSystemPrompt(mockConfig);
284285

285286
// Should include enabled tools
286287
expect(prompt).toContain('`glob`');
287288
expect(prompt).toContain('`read_file`');
289+
expect(prompt).toContain('`ask_user`');
288290

289291
// Should NOT include disabled tools
290292
expect(prompt).not.toContain('`google_web_search`');

packages/core/src/policy/policies/plan.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ decision = "allow"
6464
priority = 50
6565
modes = ["plan"]
6666

67+
[[rule]]
68+
toolName = "ask_user"
69+
decision = "allow"
70+
priority = 50
71+
modes = ["plan"]
72+
6773
# Allow write_file for .md files in plans directory
6874
[[rule]]
6975
toolName = "write_file"

packages/core/src/prompts/snippets.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import {
88
ACTIVATE_SKILL_TOOL_NAME,
9+
ASK_USER_TOOL_NAME,
910
EDIT_TOOL_NAME,
1011
GLOB_TOOL_NAME,
1112
GREP_TOOL_NAME,
@@ -312,7 +313,8 @@ ${options.planModeToolsList}
312313
313314
### Phase 1: Requirements Understanding
314315
- Analyze the user's request to identify core requirements and constraints
315-
- If critical information is missing or ambiguous, ask ONE clarifying question at a time
316+
- If critical information is missing or ambiguous, ask clarifying questions using the \`${ASK_USER_TOOL_NAME}\` tool
317+
- When using \`${ASK_USER_TOOL_NAME}\`, prefer providing multiple-choice options for the user to select from when possible
316318
- Do NOT explore the project or create a plan yet
317319
318320
### Phase 2: Project Exploration

packages/core/src/tools/tool-names.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const PLAN_MODE_TOOLS = [
6060
READ_FILE_TOOL_NAME,
6161
LS_TOOL_NAME,
6262
WEB_SEARCH_TOOL_NAME,
63+
ASK_USER_TOOL_NAME,
6364
] as const;
6465

6566
/**

0 commit comments

Comments
 (0)