Repository navigation
fix(pi): keep the user's model on a /tree navigation within the same phase - #1723
Merged
Merged
Conversation
…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
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1722
Cause
The
session_treehandler callsresyncPhaseFromSession. That function re-derives plan-mode state from the new path. For a planning or executing path, it then calledapplyPhaseConfig(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 checkednavigateTreein 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
applyPhaseConfigtakes a newapplyModelSettingsoption (defaulttrue). When it isfalse, 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.resyncPhaseFromSessionrecords the phase before the resync. Thesession_treehandler passeskeepModelWhenPhaseUnchanged: 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.session_startand 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.tsrun against a host whose model and thinking level are real state:/treekeeps the model and thinking level, makes nosetModelorsetThinkingLevelcall, and still keeps the executing tools.phases.executing.modelandthinking: these are not re-applied over the user's pick./treefrom executing into a planning path still applies the planning model./treefrom 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-extensionpasses (419 tests) andbun run typecheckpasses.