From 51753491db65ffec15cba34df1351e9b85837e1d Mon Sep 17 00:00:00 2001 From: Dillon Mulroy Date: Wed, 8 Apr 2026 18:28:56 -0400 Subject: [PATCH] fix(pi): strip planning-only tools on fresh idle sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #446 refactored the session_start handler to use applyPhaseConfig() but changed the idle branch to only call restoreSavedState(), which no-ops when savedState is null (i.e., fresh sessions that were never in planning mode). This left plannotator_submit_plan in the active tool set even though plan mode hadn't been activated — a regression from the fix in #387. Now the idle branch explicitly strips planning-only tools when there is no saved state to restore. --- apps/pi-extension/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/pi-extension/index.ts b/apps/pi-extension/index.ts index 938da018..a3c62040 100644 --- a/apps/pi-extension/index.ts +++ b/apps/pi-extension/index.ts @@ -979,8 +979,15 @@ Execute each step in order. After completing a step, include [DONE:n] in your re } if (phase === "idle") { - await restoreSavedState(ctx); - savedState = null; + if (savedState) { + await restoreSavedState(ctx); + savedState = null; + } else { + // Strip planning-only tools on fresh sessions where savedState is null. + // Without this, plannotator_submit_plan stays in the active tool set + // even though plan mode hasn't been activated. See #387. + pi.setActiveTools(stripPlanningOnlyTools(pi.getActiveTools())); + } } else if (phase === "planning" || phase === "executing") { await applyPhaseConfig(ctx, { restoreSavedState: true }); }