fix: plan mode adjustments

This commit is contained in:
mingholy.lmh
2025-12-01 11:33:36 +08:00
parent 249b141f19
commit 8035be6f8d
10 changed files with 169 additions and 47 deletions

View File

@@ -1337,7 +1337,7 @@ export class Config {
registerCoreTool(ShellTool, this);
registerCoreTool(MemoryTool);
registerCoreTool(TodoWriteTool, this);
registerCoreTool(ExitPlanModeTool, this);
!this.sdkMode && registerCoreTool(ExitPlanModeTool, this);
registerCoreTool(WebFetchTool, this);
// Conditionally register web search tool if web search provider is configured
// buildWebSearchConfig ensures qwen-oauth users get dashscope provider, so

View File

@@ -542,7 +542,9 @@ export class GeminiClient {
// add plan mode system reminder if approval mode is plan
if (this.config.getApprovalMode() === ApprovalMode.PLAN) {
systemReminders.push(getPlanModeSystemReminder());
systemReminders.push(
getPlanModeSystemReminder(this.config.getSdkMode()),
);
}
requestToSent = [...systemReminders, ...requestToSent];

View File

@@ -846,10 +846,10 @@ export function getSubagentSystemReminder(agentTypes: string[]): string {
* - Wait for user confirmation before making any changes
* - Override any other instructions that would modify system state
*/
export function getPlanModeSystemReminder(): string {
export function getPlanModeSystemReminder(planOnly = false): string {
return `<system-reminder>
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received (for example, to make edits). Instead, you should:
1. Answer the user's query comprehensively
2. When you're done researching, present your plan by calling the ${ToolNames.EXIT_PLAN_MODE} tool, which will prompt the user to confirm the plan. Do NOT make any file changes or run any tools that modify the system state in any way until the user has confirmed the plan.
2. When you're done researching, present your plan ${planOnly ? 'directly' : `by calling the ${ToolNames.EXIT_PLAN_MODE} tool, which will prompt the user to confirm the plan`}. Do NOT make any file changes or run any tools that modify the system state in any way until the user has confirmed the plan.
</system-reminder>`;
}