Skip to content

fix(pi): strip planning-only tools on fresh idle sessions#525

Merged
backnotprop merged 1 commit intobacknotprop:mainfrom
dmmulroy:fix/idle-phase-tool-scoping
Apr 8, 2026
Merged

fix(pi): strip planning-only tools on fresh idle sessions#525
backnotprop merged 1 commit intobacknotprop:mainfrom
dmmulroy:fix/idle-phase-tool-scoping

Conversation

@dmmulroy
Copy link
Copy Markdown
Contributor

@dmmulroy dmmulroy commented Apr 8, 2026

Problem

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.

Root Cause

In the session_start handler, the idle branch was:

if (phase === "idle") {
    await restoreSavedState(ctx);  // ← no-ops when savedState is null
    savedState = null;
}

When savedState is null (fresh session, never entered planning), restoreSavedState() returns immediately at line 204 without calling setActiveTools(), so plannotator_submit_plan is never stripped.

Fix

The idle branch now explicitly strips planning-only tools when there is no saved state to restore:

if (phase === "idle") {
    if (savedState) {
        await restoreSavedState(ctx);
        savedState = null;
    } else {
        pi.setActiveTools(stripPlanningOnlyTools(pi.getActiveTools()));
    }
}

This restores the guarantee from #387 that plannotator_submit_plan is always removed from the active tool set when not in planning mode.

PR backnotprop#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 backnotprop#387.

Now the idle branch explicitly strips planning-only tools when there
is no saved state to restore.
@backnotprop backnotprop merged commit 3c0e35a into backnotprop:main Apr 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants