Skip to content

fix(pi): keep the user's model on a /tree navigation within the same phase - #1723

Merged
backnotprop merged 1 commit into
mainfrom
fix/pi-tree-keeps-model
Oct 6, 2026
Merged

backnotprop merged 1 commit into
mainfrom
fix/pi-tree-keeps-model

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Fixes #1722

Cause

The session_tree handler calls resyncPhaseFromSession. That function re-derives plan-mode state from the new path. For a planning or executing path, it then called applyPhaseConfig(ctx, { restoreSavedState: true }), and it did this every time. That call restores the pre-plan model and thinking level (savedState) and then re-applies the phase profile's model and thinking. So when an oh-my-pi user re-answered an earlier Ask through /tree, the session stayed in the executing phase but its model went back from the one picked during execution (gpt-6-luna) to the pre-plan model (gpt-6-sol). Pi takes the same path, so it had the same problem.

Neither host changes the model on /tree. I checked navigateTree in Pi and in oh-my-pi 18.x. This means the model that is active at navigation time is the one the user chose.

Fix

  • applyPhaseConfig takes a new applyModelSettings option (default true). When it is false, the function re-applies only the phase tools. It does not restore the saved model or thinking level, and it does not apply the profile's model or thinking.
  • resyncPhaseFromSession records the phase before the resync. The session_tree handler passes keepModelWhenPhaseUnchanged: true, so a navigation that stays in the same phase (executing to executing, or planning to planning) keeps the current model and thinking level. The tools are still re-derived from the path.
  • A navigation that changes the phase behaves as before. Going into planning applies the planning model. Going to a path with no plan mode restores the pre-plan model.
  • session_start and approval are not changed. The restore when the plan ends is also not changed.

No prompt or history change: the system prompt and appended messages are not affected.

Tests

New tests in apps/pi-extension/phase-tools-runtime.test.ts run against a host whose model and thinking level are real state:

  • An executing path with a model the user picked during execution: /tree keeps the model and thinking level, makes no setModel or setThinkingLevel call, and still keeps the executing tools.
  • The same with a configured phases.executing.model and thinking: these are not re-applied over the user's pick.
  • /tree from executing into a planning path still applies the planning model.
  • /tree from executing to a path with no plan mode still restores the pre-plan model.

With the fix disabled, the first two tests fail. bun test apps/pi-extension passes (419 tests) and bun run typecheck passes.

…phase

A /tree navigation re-derives plan-mode state from the new path and used to
re-apply the full phase config: it restored the pre-plan model and thinking
level and re-applied the phase profile, even when the navigation stayed in
the executing phase. A model picked during execution was therefore undone
by re-answering an earlier Ask (oh-my-pi) or any other in-phase branch move.

The session_tree resync now leaves the model and thinking level alone when
the phase does not change, and still re-derives the tools. A navigation
that changes phase (into planning, or out of plan mode) applies that
phase's model or restores the pre-plan one as before.

Fixes #1722
@backnotprop
backnotprop merged commit a65c0b8 into main Oct 6, 2026
28 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.

Oh My Pi (OMP) + Plannotator Pi extension: model resets on /tree Ask re-answer

1 participant