@juicesharp/rpiv-advisor 2.13.6 → 2.13.7

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.
@@ -2,7 +2,8 @@
2
2
  * context — branch-message massaging for the advisor side-call. Strips the
3
3
  * executor's in-flight advisor() toolCall from the tail (orphan toolCalls are
4
4
  * rejected by providers) and guarantees a user-role tail (some providers reject
5
- * an assistant-prefill tail).
5
+ * an assistant-prefill tail), and drops the executor's callable tool
6
+ * declarations from copied system messages.
6
7
  */
7
8
 
8
9
  import type { Message } from "@earendil-works/pi-ai";
@@ -38,3 +39,18 @@ export function ensureUserTailForAdvisor(messages: Message[]): Message[] {
38
39
  };
39
40
  return [...messages, nudge];
40
41
  }
42
+
43
+ // Pi >= 1.0 records the executor's system prompt and tool loadout in the
44
+ // transcript as `system` messages, and every provider resolves the request's
45
+ // tools from those `toolsAdded`/`toolsRemoved` deltas — so `tools: []` alone
46
+ // leaves the executor's tools callable and the advisor can stop on `toolUse`
47
+ // with no text (#295). Drop the deltas, keep the prompt text; the inventory
48
+ // message already tells the advisor what the executor's tools are.
49
+ export function stripToolDeclarations(messages: Message[]): Message[] {
50
+ if (!messages.some((m) => m.role === "system" && (m.toolsAdded || m.toolsRemoved))) return messages;
51
+ return messages.map((m) => {
52
+ if (m.role !== "system" || (!m.toolsAdded && !m.toolsRemoved)) return m;
53
+ const { toolsAdded: _added, toolsRemoved: _removed, ...rest } = m;
54
+ return rest;
55
+ });
56
+ }
@@ -15,7 +15,7 @@ import {
15
15
  type ExtensionAPI,
16
16
  type ExtensionContext,
17
17
  } from "@earendil-works/pi-coding-agent";
18
- import { ensureUserTailForAdvisor, stripInflightAdvisorCall } from "./context.js";
18
+ import { ensureUserTailForAdvisor, stripInflightAdvisorCall, stripToolDeclarations } from "./context.js";
19
19
  import { getInventoryMessage } from "./inventory.js";
20
20
  import {
21
21
  ERR_ABORTED_DETAIL,
@@ -124,7 +124,9 @@ export async function executeAdvisor(
124
124
  ctx.sessionManager.getEntries(),
125
125
  ctx.sessionManager.getLeafId(),
126
126
  );
127
- const branchMessages = ensureUserTailForAdvisor(stripInflightAdvisorCall(convertToLlm(sessionMessages)));
127
+ const branchMessages = ensureUserTailForAdvisor(
128
+ stripInflightAdvisorCall(stripToolDeclarations(convertToLlm(sessionMessages))),
129
+ );
128
130
  const inventoryMessage = getInventoryMessage(pi.getAllTools());
129
131
  const messages: Message[] = inventoryMessage ? [inventoryMessage, ...branchMessages] : branchMessages;
130
132
 
@@ -147,8 +149,8 @@ export async function executeAdvisor(
147
149
 
148
150
  // Single dispatch point — both attempts reuse the SAME `messages` and
149
151
  // `requestOptions`, so the retry cannot diverge from attempt 1. `tools: []`
150
- // reaffirms the "never calls tools" contract even when `messages` contains
151
- // prior toolCall/toolResult blocks (btw.ts:235).
152
+ // plus stripToolDeclarations keeps the "never calls tools" contract: on
153
+ // Pi >= 1.0 the transcript's system messages declare tools of their own.
152
154
  const callAdvisor = (): Promise<AssistantMessage> =>
153
155
  completeSimple(advisor, { systemPrompt: ADVISOR_SYSTEM_PROMPT, messages, tools: [] }, requestOptions);
154
156
 
package/advisor/index.ts CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  export { registerAdvisorCommand } from "./command.js";
27
27
  export { loadAdvisorConfig, saveAdvisorConfig } from "./config.js";
28
- export { ensureUserTailForAdvisor, stripInflightAdvisorCall } from "./context.js";
28
+ export { ensureUserTailForAdvisor, stripInflightAdvisorCall, stripToolDeclarations } from "./context.js";
29
29
  export {
30
30
  registerAdvisorBeforeAgentStart,
31
31
  registerModelSelectHandler,
@@ -32,8 +32,9 @@ Each call assembles the request in this order:
32
32
  non-user tails accept the payload.
33
33
 
34
34
  The reviewer is invoked with the advisor system prompt, `tools: []`, and the
35
- configured reasoning effort. It never calls tools and never writes to your
36
- transcript — its answer comes back only as the tool result the executor reads.
35
+ configured reasoning effort. The executor's tool declarations are removed from
36
+ the copied context, so the reviewer has no tools to call. It never calls tools
37
+ and never writes to your transcript — its answer comes back only as the tool result the executor reads.
37
38
  The default prompt guidelines direct the executor to restate the advisor's key
38
39
  guidance in its next visible reply, so the guidance is not left only in a
39
40
  collapsed tool card.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-advisor",
3
- "version": "2.13.6",
3
+ "version": "2.13.7",
4
4
  "description": "Pi extension. A second opinion the model can request from a stronger reviewer model before it acts.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -47,7 +47,7 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
- "@juicesharp/rpiv-config": "^2.13.6"
50
+ "@juicesharp/rpiv-config": "^2.13.7"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@earendil-works/pi-ai": "*",