pi-advisor-flow 0.15.2-dev.2 → 0.16.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ### Fixed
10
+
11
+ - Prevent `/model` and model cycling from changing the persisted Executor; update it only through `/advisor-models` or an explicit `/advisor executor=...` override.
12
+
13
+ ## 0.16.0 - 2026-11-16
14
+
9
15
  ### Added
10
16
 
11
17
  - Bundled the `pi-advisor-flow` Pi skill and added the `advisor_config` tool so agents can inspect and update settings after confirmation.
package/README.md CHANGED
@@ -78,7 +78,7 @@ Reload Pi after installing. The package also installs the `pi-advisor-flow` skil
78
78
  /advisor-stats # Show retained outcome adoption and validation stats
79
79
  ```
80
80
 
81
- The Executor is whichever model your Pi session is using; `/advisor` never switches it unless you pin one with `executor=` or `/advisor-models`. On first use, or whenever the saved Advisor is unavailable, `/advisor` opens the available-model picker; it never silently chooses an unconfigured Advisor. Pi virtual models can be selected as Advisors; Pi routes each request to a physical model and resolves that model's credentials. They require a Pi runtime with `modelRegistry.streamSimple`; on older runtimes, the request explains how to upgrade or select a physical Advisor model. If the active Executor and Advisor use the same provider/model, calls and automatic gates are skipped with a notice; switching either model resumes consultations. Turn off **Disable same-model Advisor** in `/advisor-settings` (or set `"advisorDisableSameModel": false` globally) if you intentionally want a higher-effort review from that same model. You can also enable the flow and select both models at once:
81
+ The Executor is whichever model your Pi session is using unless you pin one with `executor=` or `/advisor-models`. Changing the active model with `/model` or model cycling does not change the saved Executor; use `/advisor-models` or an explicit `/advisor executor=...` to change that configuration. On first use, or whenever the saved Advisor is unavailable, `/advisor` opens the available-model picker; it never silently chooses an unconfigured Advisor. Pi virtual models can be selected as Advisors; Pi routes each request to a physical model and resolves that model's credentials. They require a Pi runtime with `modelRegistry.streamSimple`; on older runtimes, the request explains how to upgrade or select a physical Advisor model. If the active Executor and Advisor use the same provider/model, calls and automatic gates are skipped with a notice; switching either model resumes consultations. Turn off **Disable same-model Advisor** in `/advisor-settings` (or set `"advisorDisableSameModel": false` globally) if you intentionally want a higher-effort review from that same model. You can also enable the flow and select both models at once:
82
82
 
83
83
  ```text
84
84
  /advisor executor=openai-codex/gpt-5.6-luna advisor=openai-codex/gpt-5.6-sol
package/dist/index.js CHANGED
@@ -1466,12 +1466,10 @@ var getExplicitModelError = (ctx, ref, label, overridden, availableRefs) => {
1466
1466
  }
1467
1467
  }
1468
1468
  };
1469
- var planActivationModels = (ctx, executor, advisor, pendingExecutorRef, persisted, executorOverride, advisorOverride, availableRefs) => {
1470
- const pendingExecutor = !executorOverride && persisted.executor && pendingExecutorRef && isSelectableModel(ctx, pendingExecutorRef, availableRefs) ? pendingExecutorRef : undefined;
1471
- const executorConfigured = executorOverride || Boolean(pendingExecutor) || !persisted.executor || isSelectableModel(ctx, executor, availableRefs);
1469
+ var planActivationModels = (ctx, executor, advisor, persisted, executorOverride, advisorOverride, availableRefs) => {
1470
+ const executorConfigured = executorOverride || !persisted.executor || isSelectableModel(ctx, executor, availableRefs);
1472
1471
  const advisorConfigured = advisorOverride || Boolean(persisted.advisor && isSelectableModel(ctx, advisor, availableRefs));
1473
1472
  return {
1474
- pendingExecutor,
1475
1473
  selectAdvisor: !advisorConfigured,
1476
1474
  selectExecutor: !executorConfigured
1477
1475
  };
@@ -5542,7 +5540,6 @@ class CommandRuntime {
5542
5540
  requestManualRender = requestManualRender;
5543
5541
  scoutStatus;
5544
5542
  manualProgressSequence = 0;
5545
- pendingExecutorModelRef;
5546
5543
  suppressModelSelectionSync = false;
5547
5544
  toolAvailabilityRevision = 0;
5548
5545
  lastSameModelDisabled;
@@ -5612,10 +5609,9 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
5612
5609
  notify(ctx, explicitError, "error");
5613
5610
  return;
5614
5611
  }
5615
- const plan = planActivationModels(ctx, executorRef, advisorRef, runtime.pendingExecutorModelRef, persisted, executorOverride, advisorOverride, availableRefSet);
5616
- setExecutorRef(plan.pendingExecutor ?? executorRef);
5612
+ const plan = planActivationModels(ctx, executorRef, advisorRef, persisted, executorOverride, advisorOverride, availableRefSet);
5617
5613
  if (!(plan.selectExecutor || plan.selectAdvisor)) {
5618
- return { pendingExecutor: plan.pendingExecutor, pickedModels: false };
5614
+ return { pickedModels: false };
5619
5615
  }
5620
5616
  if (!announce) {
5621
5617
  notify(ctx, t("notify.modelsNotConfigured.message", "Advisor models are not configured or available. Run /advisor to choose them."), "error");
@@ -5625,7 +5621,7 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
5625
5621
  advisor: advisorOverride || persisted.advisor ? advisorRef : "",
5626
5622
  advisorEffort: advisorEffortRef,
5627
5623
  advisorFallbackModel: advisorFallbackModelRef,
5628
- executor: executorOverride || plan.pendingExecutor || persisted.executor ? executorRef : "",
5624
+ executor: executorOverride || persisted.executor ? executorRef : "",
5629
5625
  executorEffort: executorEffortRef,
5630
5626
  selectAdvisor: plan.selectAdvisor,
5631
5627
  selectExecutor: plan.selectExecutor
@@ -5638,7 +5634,7 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
5638
5634
  setAdvisorEffortRef(selection.advisorEffort);
5639
5635
  setExecutorRef(selection.executor);
5640
5636
  setExecutorEffortRef(selection.executorEffort);
5641
- return { pendingExecutor: plan.pendingExecutor, pickedModels: true };
5637
+ return { pickedModels: true };
5642
5638
  };
5643
5639
 
5644
5640
  // src/commands/advisor-tools.ts
@@ -5783,11 +5779,10 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
5783
5779
  if (reenableTools) {
5784
5780
  setAdvisorToolsEnabledRef(true);
5785
5781
  }
5786
- const shouldSave = Boolean(args.trim() || prepared.pickedModels || prepared.pendingExecutor || reenableTools);
5782
+ const shouldSave = Boolean(args.trim() || prepared.pickedModels || reenableTools);
5787
5783
  if (!persistSuccessfulActivation(ctx, shouldSave, reenableTools, () => restoreRefs(liveRefSnapshot()))) {
5788
5784
  return;
5789
5785
  }
5790
- runtime.pendingExecutorModelRef = undefined;
5791
5786
  if (executorEffortRef && !isMarkedSubagent()) {
5792
5787
  runtime.pi.setThinkingLevel(executorEffortRef);
5793
5788
  }
@@ -6312,7 +6307,6 @@ var registerAdvisorConfigurationTool = (runtime, dependencies = {}) => {
6312
6307
  // src/commands/lifecycle.ts
6313
6308
  var registerCommandLifecycle = (runtime, activateAdvisor) => {
6314
6309
  runtime.pi.on("session_start", async (_event, ctx) => {
6315
- runtime.pendingExecutorModelRef = undefined;
6316
6310
  runtime.resetSameModelNotice();
6317
6311
  try {
6318
6312
  loadConfig(ctx);
@@ -6337,27 +6331,6 @@ var registerCommandLifecycle = (runtime, activateAdvisor) => {
6337
6331
  if (!runtime.suppressModelSelectionSync) {
6338
6332
  runtime.updateSameModelNotice(ctx, event.model);
6339
6333
  }
6340
- if (event.source !== "set" || runtime.suppressModelSelectionSync || isMarkedSubagent()) {
6341
- return;
6342
- }
6343
- const selected = `${event.model.provider}/${event.model.id}`;
6344
- if (!getPersistedModelRefs().executor) {
6345
- return;
6346
- }
6347
- if (!runtime.flowEnabled()) {
6348
- runtime.pendingExecutorModelRef = selected;
6349
- return;
6350
- }
6351
- runtime.pendingExecutorModelRef = undefined;
6352
- if (selected === executorRef) {
6353
- return;
6354
- }
6355
- const persisted = getPersistedModelRefs();
6356
- setExecutorRef(selected);
6357
- saveConfig(ctx, {
6358
- persistAdvisor: Boolean(persisted.advisor),
6359
- persistExecutor: true
6360
- });
6361
6334
  });
6362
6335
  runtime.pi.on("session_shutdown", (_event, ctx) => {
6363
6336
  if (ctx.hasUI) {
@@ -7475,7 +7448,7 @@ var registerModelCommands = (runtime) => {
7475
7448
  advisor: persisted.advisor ? advisorRef : "",
7476
7449
  advisorEffort: advisorEffortRef,
7477
7450
  advisorFallbackModel: advisorFallbackModelRef,
7478
- executor: runtime.pendingExecutorModelRef ?? (persisted.executor ? executorRef : ""),
7451
+ executor: persisted.executor ? executorRef : "",
7479
7452
  executorEffort: executorEffortRef,
7480
7453
  selectAdvisor: true,
7481
7454
  selectExecutor: true
@@ -7492,7 +7465,6 @@ var registerModelCommands = (runtime) => {
7492
7465
  persistAdvisor: true,
7493
7466
  persistExecutor: true
7494
7467
  });
7495
- runtime.pendingExecutorModelRef = undefined;
7496
7468
  runtime.updateSameModelNotice(ctx);
7497
7469
  ctx.ui.notify(`${t("notify.modelsSaved.prefix", "Saved Executor + Advisor configurations to")} ${path}`, "info");
7498
7470
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-advisor-flow",
3
- "version": "0.15.2-dev.2",
3
+ "version": "0.16.1-dev.1",
4
4
  "description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
5
5
  "keywords": [
6
6
  "advisor",
@@ -25,7 +25,6 @@ import { notify } from "./runtime.ts";
25
25
  import type { CommandRuntime } from "./types.ts";
26
26
 
27
27
  export interface PreparedActivationModels {
28
- pendingExecutor?: string;
29
28
  pickedModels: boolean;
30
29
  }
31
30
 
@@ -86,17 +85,14 @@ export const prepareActivationModels = async (
86
85
  ctx,
87
86
  executorRef,
88
87
  advisorRef,
89
- runtime.pendingExecutorModelRef,
90
88
  persisted,
91
89
  executorOverride,
92
90
  advisorOverride,
93
91
  availableRefSet
94
92
  );
95
93
 
96
- setExecutorRef(plan.pendingExecutor ?? executorRef);
97
-
98
94
  if (!(plan.selectExecutor || plan.selectAdvisor)) {
99
- return { pendingExecutor: plan.pendingExecutor, pickedModels: false };
95
+ return { pickedModels: false };
100
96
  }
101
97
 
102
98
  // Always-on startup cannot open an interactive picker, so it leaves the
@@ -118,10 +114,7 @@ export const prepareActivationModels = async (
118
114
  advisor: advisorOverride || persisted.advisor ? advisorRef : "",
119
115
  advisorEffort: advisorEffortRef,
120
116
  advisorFallbackModel: advisorFallbackModelRef,
121
- executor:
122
- executorOverride || plan.pendingExecutor || persisted.executor
123
- ? executorRef
124
- : "",
117
+ executor: executorOverride || persisted.executor ? executorRef : "",
125
118
  executorEffort: executorEffortRef,
126
119
  selectAdvisor: plan.selectAdvisor,
127
120
  selectExecutor: plan.selectExecutor,
@@ -137,5 +130,5 @@ export const prepareActivationModels = async (
137
130
  setExecutorRef(selection.executor);
138
131
  setExecutorEffortRef(selection.executorEffort);
139
132
 
140
- return { pendingExecutor: plan.pendingExecutor, pickedModels: true };
133
+ return { pickedModels: true };
141
134
  };
@@ -253,10 +253,7 @@ export const activateAdvisor = async (
253
253
  }
254
254
 
255
255
  const shouldSave = Boolean(
256
- args.trim() ||
257
- prepared.pickedModels ||
258
- prepared.pendingExecutor ||
259
- reenableTools
256
+ args.trim() || prepared.pickedModels || reenableTools
260
257
  );
261
258
 
262
259
  if (
@@ -267,11 +264,6 @@ export const activateAdvisor = async (
267
264
  return;
268
265
  }
269
266
 
270
- // A successful activation has committed the effective Executor. Do not let
271
- // an older inactive selection override an explicit activation argument on a
272
- // later attempt.
273
- runtime.pendingExecutorModelRef = undefined;
274
-
275
267
  if (executorEffortRef && !isMarkedSubagent()) {
276
268
  // SAFETY: executorEffortRef is operator-configured and trusted to name a ThinkingLevel.
277
269
  runtime.pi.setThinkingLevel(executorEffortRef as ThinkingLevel);
@@ -1,14 +1,7 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
 
3
- import { isMarkedSubagent } from "../child-session.ts";
4
- import {
5
- advisorToolsEnabledRef,
6
- alwaysOnRef,
7
- executorRef,
8
- getPersistedModelRefs,
9
- setExecutorRef,
10
- } from "../config/state.ts";
11
- import { loadConfig, saveConfig } from "../config/storage.ts";
3
+ import { advisorToolsEnabledRef, alwaysOnRef } from "../config/state.ts";
4
+ import { loadConfig } from "../config/storage.ts";
12
5
  import { t } from "../i18n.ts";
13
6
  import { setAdvisorToolsActive } from "./advisor-tools.ts";
14
7
  import { notify } from "./runtime.ts";
@@ -25,7 +18,6 @@ export const registerCommandLifecycle = (
25
18
  activateAdvisor: ActivateAdvisor
26
19
  ) => {
27
20
  runtime.pi.on("session_start", async (_event, ctx) => {
28
- runtime.pendingExecutorModelRef = undefined;
29
21
  runtime.resetSameModelNotice();
30
22
 
31
23
  // A malformed advisor.json or a provider auth failure must not reject a
@@ -62,43 +54,8 @@ export const registerCommandLifecycle = (
62
54
  runtime.updateSameModelNotice(ctx, event.model);
63
55
  }
64
56
 
65
- // "restore" replays a stored session model and "cycle" changes the active
66
- // model without an explicit `/model` choice. Neither should redefine the
67
- // configured Executor.
68
- if (
69
- event.source !== "set" ||
70
- runtime.suppressModelSelectionSync ||
71
- isMarkedSubagent()
72
- ) {
73
- return;
74
- }
75
-
76
- const selected = `${event.model.provider}/${event.model.id}`;
77
-
78
- if (!getPersistedModelRefs().executor) {
79
- return;
80
- }
81
-
82
- if (!runtime.flowEnabled()) {
83
- // Defer persistence until `/advisor` succeeds. This keeps ordinary model
84
- // selection global defaults untouched when the flow is not enabled.
85
- runtime.pendingExecutorModelRef = selected;
86
-
87
- return;
88
- }
89
-
90
- runtime.pendingExecutorModelRef = undefined;
91
-
92
- if (selected === executorRef) {
93
- return;
94
- }
95
-
96
- const persisted = getPersistedModelRefs();
97
- setExecutorRef(selected);
98
- saveConfig(ctx, {
99
- persistAdvisor: Boolean(persisted.advisor),
100
- persistExecutor: true,
101
- });
57
+ // Model selection changes the active Pi session model only. Persisted
58
+ // Executor settings are changed explicitly through `/advisor-models`.
102
59
  });
103
60
 
104
61
  runtime.pi.on("session_shutdown", (_event, ctx) => {
@@ -42,9 +42,7 @@ export const registerModelCommands = (runtime: CommandRuntime) => {
42
42
  advisor: persisted.advisor ? advisorRef : "",
43
43
  advisorEffort: advisorEffortRef,
44
44
  advisorFallbackModel: advisorFallbackModelRef,
45
- executor:
46
- runtime.pendingExecutorModelRef ??
47
- (persisted.executor ? executorRef : ""),
45
+ executor: persisted.executor ? executorRef : "",
48
46
  executorEffort: executorEffortRef,
49
47
  selectAdvisor: true,
50
48
  selectExecutor: true,
@@ -65,7 +63,6 @@ export const registerModelCommands = (runtime: CommandRuntime) => {
65
63
  persistExecutor: true,
66
64
  });
67
65
 
68
- runtime.pendingExecutorModelRef = undefined;
69
66
  runtime.updateSameModelNotice(ctx);
70
67
  ctx.ui.notify(
71
68
  `${t("notify.modelsSaved.prefix", "Saved Executor + Advisor configurations to")} ${path}`,
@@ -165,7 +165,6 @@ export const getExplicitModelError = (
165
165
  };
166
166
 
167
167
  export interface ActivationModelPlan {
168
- pendingExecutor: string | undefined;
169
168
  selectAdvisor: boolean;
170
169
  selectExecutor: boolean;
171
170
  }
@@ -174,23 +173,13 @@ export const planActivationModels = (
174
173
  ctx: ExtensionContext,
175
174
  executor: string | undefined,
176
175
  advisor: string | undefined,
177
- pendingExecutorRef: string | undefined,
178
176
  persisted: ReturnType<typeof getPersistedModelRefs>,
179
177
  executorOverride: boolean,
180
178
  advisorOverride: boolean,
181
179
  availableRefs: Set<string> | undefined
182
180
  ): ActivationModelPlan => {
183
- const pendingExecutor =
184
- !executorOverride &&
185
- persisted.executor &&
186
- pendingExecutorRef &&
187
- isSelectableModel(ctx, pendingExecutorRef, availableRefs)
188
- ? pendingExecutorRef
189
- : undefined;
190
-
191
181
  const executorConfigured =
192
182
  executorOverride ||
193
- Boolean(pendingExecutor) ||
194
183
  !persisted.executor ||
195
184
  isSelectableModel(ctx, executor, availableRefs);
196
185
 
@@ -201,7 +190,6 @@ export const planActivationModels = (
201
190
  );
202
191
 
203
192
  return {
204
- pendingExecutor,
205
193
  selectAdvisor: !advisorConfigured,
206
194
  selectExecutor: !executorConfigured,
207
195
  };
@@ -64,7 +64,6 @@ class CommandRuntime implements CommandRuntimeContract {
64
64
  readonly requestManualRender = requestManualRender;
65
65
  readonly scoutStatus: ScoutStatusManager;
66
66
  manualProgressSequence = 0;
67
- pendingExecutorModelRef: string | undefined;
68
67
  suppressModelSelectionSync = false;
69
68
  toolAvailabilityRevision = 0;
70
69
  private lastSameModelDisabled: boolean | undefined;
@@ -62,7 +62,6 @@ export interface CommandRuntime {
62
62
  ReturnType<typeof setInterval>
63
63
  >;
64
64
  nextManualProgressId: () => string;
65
- pendingExecutorModelRef: string | undefined;
66
65
  readonly pi: ExtensionAPI;
67
66
  reportManualBudgetExhausted: (ctx: ExtensionContext) => void;
68
67
  readonly requestAdvisor: ManualConsult;