From fafe930c777b894e1d80373d805e0d7994af1ebb Mon Sep 17 00:00:00 2001 From: David Blass Date: Thu, 5 Mar 2026 23:06:05 +0000 Subject: [PATCH] enforce single mode selection per run (#413) Prevents the agent from calling select_mode multiple times, which caused it to chain modes (e.g. Plan then Build) when the user only asked for a plan. Also removes the Plan orchestrator guidance that explicitly encouraged switching to Build after planning. Closes #394 Made-with: Cursor --- entry | 9 +++++++-- mcp/selectMode.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/entry b/entry index 9b4a0ac..cdeee5f 100755 --- a/entry +++ b/entry @@ -144064,7 +144064,7 @@ Use max effort for thorough reviews.`, ### Effort -Use mini or auto effort. After receiving the plan, you may delegate a Build subagent to implement it.`, +Use mini or auto effort.`, Fix: `### Checklist 1. Before delegating, checkout the PR branch yourself via \`${ghPullfrogMcpName}/checkout_pr\` \u2014 subagents have no git/checkout tools. @@ -144114,9 +144114,14 @@ function buildOrchestratorGuidance(mode) { function SelectModeTool(ctx) { return tool({ name: "select_mode", - description: "Select a mode and receive orchestrator-level guidance on how to handle it, including suggested delegation flows and prompt-crafting tips. Call this before delegating to understand the best approach for the task.", + description: "Select a mode and receive orchestrator-level guidance on how to handle it, including suggested delegation flows and prompt-crafting tips. Call this ONCE before delegating. Mode selection is final \u2014 you cannot switch modes after selecting.", parameters: SelectModeParams, execute: execute(async (params) => { + if (ctx.toolState.selectedMode) { + return { + error: `mode already selected: "${ctx.toolState.selectedMode}". mode selection is final and cannot be changed. complete your current workflow within this mode.` + }; + } const selectedMode = resolveMode(ctx.modes, params.mode); if (!selectedMode) { const availableModes = ctx.modes.map((m) => m.name).join(", "); diff --git a/mcp/selectMode.ts b/mcp/selectMode.ts index 9fa93e9..2f66b2c 100644 --- a/mcp/selectMode.ts +++ b/mcp/selectMode.ts @@ -135,7 +135,7 @@ Use max effort for thorough reviews.`, ### Effort -Use mini or auto effort. After receiving the plan, you may delegate a Build subagent to implement it.`, +Use mini or auto effort.`, Fix: `### Checklist @@ -196,9 +196,15 @@ export function SelectModeTool(ctx: ToolContext) { return tool({ name: "select_mode", description: - "Select a mode and receive orchestrator-level guidance on how to handle it, including suggested delegation flows and prompt-crafting tips. Call this before delegating to understand the best approach for the task.", + "Select a mode and receive orchestrator-level guidance on how to handle it, including suggested delegation flows and prompt-crafting tips. Call this ONCE before delegating. Mode selection is final — you cannot switch modes after selecting.", parameters: SelectModeParams, execute: execute(async (params) => { + if (ctx.toolState.selectedMode) { + return { + error: `mode already selected: "${ctx.toolState.selectedMode}". mode selection is final and cannot be changed. complete your current workflow within this mode.`, + }; + } + const selectedMode = resolveMode(ctx.modes, params.mode); if (!selectedMode) {