@skydiveai/pi-extensions 0.1.258-beta.131 → 0.1.258-beta.133

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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2608,6 +2608,12 @@ const assistantSchema = z.object({
2608
2608
  id: z.string(),
2609
2609
  model: z.string()
2610
2610
  });
2611
+ /** Sent as the SDK prompt when Pi's context ends with tool results. */
2612
+ const SEAT_CONTINUE_PROMPT = "Continue from the existing conversation and tool results.";
2613
+ const continuePromptSchema = z.object({ content: z.union([z.literal(SEAT_CONTINUE_PROMPT), z.tuple([z.object({
2614
+ type: z.literal("text"),
2615
+ text: z.literal(SEAT_CONTINUE_PROMPT)
2616
+ })])]) });
2611
2617
  const sdkToolResultSchema = z.object({ content: z.array(z.object({ type: z.literal("tool_result") })).min(1) });
2612
2618
  function assistantMessage(entry) {
2613
2619
  if (entry.type !== "assistant") return null;
@@ -2630,6 +2636,8 @@ function isSdkToolResult(entry) {
2630
2636
  * the pair must stay so the cached prefix is byte-identical between steps, but
2631
2637
  * once a newer user message exists it is dropped: otherwise the model rereads
2632
2638
  * itself saying "No response requested." once per historical tool step.
2639
+ * Only our own continuation prompt goes with it; when a steer was the prompt,
2640
+ * the user's text follows the synthetic turn and must be kept.
2633
2641
  */
2634
2642
  function withoutResumePlaceholders(entries) {
2635
2643
  let dropPrompt = false;
@@ -2640,7 +2648,7 @@ function withoutResumePlaceholders(entries) {
2640
2648
  }
2641
2649
  if (dropPrompt && entry.type === "user") {
2642
2650
  dropPrompt = false;
2643
- return false;
2651
+ return !continuePromptSchema.safeParse(entry.message).success;
2644
2652
  }
2645
2653
  return true;
2646
2654
  });
@@ -2795,7 +2803,7 @@ async function prepareSeatHistory({ context, configDir, cwd, toolName, model })
2795
2803
  const hashes = seatPrefixHashes(context, model);
2796
2804
  const messages = [...context.messages];
2797
2805
  const last = messages.at(-1);
2798
- const prompt = last?.role === "user" ? userContent(last.content) : "Continue from the existing conversation and tool results.";
2806
+ const prompt = last?.role === "user" ? userContent(last.content) : SEAT_CONTINUE_PROMPT;
2799
2807
  if (last?.role === "user") messages.pop();
2800
2808
  if (messages.length === 0) return {
2801
2809
  prompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skydiveai/pi-extensions",
3
- "version": "0.1.258-beta.131",
3
+ "version": "0.1.258-beta.133",
4
4
  "homepage": "https://skydive.com",
5
5
  "license": "MIT",
6
6
  "author": "Create, Inc.",