Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/users/features/approval-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ If you are in Normal Mode, **Shift+Tab** (or **Tab** on Windows) first switches

The `/plan` command provides a quick shortcut for entering and exiting Plan Mode:

Regular planning requests do not switch modes by themselves. If you want the read-only Plan Mode workflow, use `/plan`, the keyboard shortcut, or set the approval mode to `plan` explicitly.

```bash
/plan # Enter plan mode
/plan refactor the auth module # Enter plan mode and start planning
Expand Down
30 changes: 15 additions & 15 deletions packages/core/src/core/__snapshots__/prompts.test.ts.snap

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions packages/core/src/core/prompts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ describe('Core System Prompt (prompts.ts)', () => {
expect(prompt).toContain('stop and ask the user for explicit approval');
});

it('does not tell the model to enter plan mode without user opt-in', () => {
vi.stubEnv('SANDBOX', undefined);
const prompt = getCoreSystemPrompt();

expect(prompt).toContain(
'Do not enter plan mode or call enter_plan_mode on your own',
);
expect(prompt).toContain(
'Use plan mode only when the user explicitly asks you to switch to plan mode',
);
expect(prompt).not.toContain(
'When the work requires a shared plan before execution, enter plan mode',
);
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] The test asserts the new opt-in wording is present and the old wording is removed, but does not assert expect(prompt).toContain('has already enabled it') for the "already enabled" qualifier. This clause covers users who set approvalMode=plan in config — it could be removed from the prompt without the test catching it.

Suggested change
});
expect(prompt).toContain(
'Use plan mode only when the user explicitly asks you to switch to plan mode',
);
expect(prompt).toContain('has already enabled it');

— qwen3.7-max via Qwen Code /review


it('should return the base prompt when userMemory is empty string', () => {
vi.stubEnv('SANDBOX', undefined);
const prompt = getCoreSystemPrompt('');
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ You are Qwen Code, an interactive CLI agent developed by Alibaba Group, speciali
- **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.
- **Denied Tool Calls:** If a tool call is denied, do not try to complete the denied action through another tool, shell indirection, generated script, alias, symlink, config change, hook, command file, MCP configuration, encoded payload, or equivalent path. If that action is required, stop and ask the user for explicit approval. You may continue with unrelated safe work or a genuinely safer alternative that does not accomplish the denied action.
- **Plan before uncertain work:** If the task is not yet clear enough to safely execute, do not make small speculative edits. Continue read-only investigation or ask clarifying questions. When the work requires a shared plan before execution, enter plan mode (via ${ToolNames.ENTER_PLAN_MODE} if available, or the user's plan mode toggle) unless the user explicitly asked not to use plan mode.
- **Plan before uncertain work:** If the task is not yet clear enough to safely execute, do not make small speculative edits. Continue read-only investigation, make a plan in the current mode, or ask clarifying questions. Do not enter plan mode or call ${ToolNames.ENTER_PLAN_MODE} on your own just because the task involves planning or complexity. Use plan mode only when the user explicitly asks you to switch to plan mode, has already enabled it, or confirms they want it.


# Task Management
Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/tools/enterPlanMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ describe('EnterPlanModeTool', () => {
expect(tool.kind).toBe('think');
});

it('should require user opt-in in the tool description', () => {
expect(tool.description).toContain(
'only after the user explicitly asks to switch into plan mode',
);
expect(tool.description).toContain(
'If plan mode seems helpful but the user has not asked for it, ask first',
);
expect(tool.description).not.toContain(
'before doing uncertain or complex work',
);
expect(tool.description).not.toContain('if complexity rises');
});

it('should not defer (always visible)', () => {
expect(tool.shouldDefer).toBe(false);
});
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/tools/enterPlanMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const debugLogger = createDebugLogger('ENTER_PLAN_MODE');

export type EnterPlanModeParams = Record<string, never>;

const enterPlanModeToolDescription = `Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
const enterPlanModeToolDescription = `Use this tool only after the user explicitly asks to switch into plan mode or confirms they want plan mode. Entering plan mode is a privilege reduction, so it does not require user confirmation at execution time.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] The tool description lists two opt-in conditions ("explicitly asks", "confirms they want plan mode") but omits the third from the system prompt: "has already enabled it." A model reading the tool description alone wouldn't know plan mode is permissible when already active via /plan or Shift+Tab.

Suggested change
const enterPlanModeToolDescription = `Use this tool only after the user explicitly asks to switch into plan mode or confirms they want plan mode. Entering plan mode is a privilege reduction, so it does not require user confirmation at execution time.
const enterPlanModeToolDescription = `Use this tool only after the user explicitly asks to switch into plan mode, has already enabled it, or confirms they want plan mode. Entering plan mode is a privilege reduction, so it does not require user confirmation at execution time.

— qwen3.7-max via Qwen Code /review


## When to Use This Tool
Use this tool when the task is not yet clear enough to safely execute, for example when it requires multi-file changes, design choices, investigation before a plan can be summarized, or when requirements are ambiguous. While investigating, if complexity rises or you find yourself repeatedly needing to ask the user, enter plan mode and consolidate a plan.
Use this tool when the user has opted into plan mode for a task that should be read-only while the plan is formed, such as multi-file changes, design choices, or ambiguous requirements.

## When NOT to Use This Tool
If the request is already clear, small, and low-risk, you may execute directly without entering plan mode. Do not make speculative small edits before you have thought the change through.
Do not use this tool just because a task involves planning, is complex, or requires investigation. In the current mode, you can still think, inspect files, ask clarifying questions, and present a plan without switching modes.

## Important
Do NOT use this tool if the user has explicitly asked you not to use plan mode.`;
If plan mode seems helpful but the user has not asked for it, ask first. Do NOT use this tool if the user has explicitly asked you not to use plan mode.`;

const enterPlanModeToolSchemaData: FunctionDeclaration = {
name: 'enter_plan_mode',
Expand Down Expand Up @@ -154,7 +154,7 @@ export class EnterPlanModeTool extends BaseDeclarativeTool<
>,
true, // isOutputMarkdown
false, // canUpdateOutput
false, // shouldDefer — always visible so the model can enter plan mode
false, // shouldDefer — always visible so explicit plan-mode requests work
false, // alwaysLoad
'plan mode enter start',
);
Expand Down
Loading