Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(pi): condensed marker needs a text summary

AdityaUmale798400181fb9
diff --git a/server/drivers/pi.ts b/server/drivers/pi.ts
index 0c5a81d889..1bf53d2430 100644
--- a/server/drivers/pi.ts
+++ b/server/drivers/pi.ts
@@ -734,7 +734,7 @@ export const PiDriver: ProviderDriver<PiConfig> = {
compactionObserved = true;
deletePromptSplitReceipt("pi", JSON.stringify([threadId, sessionFile]));
}
- if (evt.type.endsWith("compaction_end") && /\S/.test(String((evt as { result?: { summary?: unknown } }).result?.summary ?? "")) && !(evt as { aborted?: boolean }).aborted && !(evt as { errorMessage?: string }).errorMessage) { flushAssistantText(); emit({ ...base(threadId, turnId), type: "context.compacted" }); }
+ if (evt.type.endsWith("compaction_end") && typeof (evt as { result?: { summary?: unknown } }).result?.summary === "string" && /\S/.test((evt as { result: { summary: string } }).result.summary) && !(evt as { aborted?: boolean }).aborted && !(evt as { errorMessage?: string }).errorMessage) { flushAssistantText(); emit({ ...base(threadId, turnId), type: "context.compacted" }); }
return;
}
case "message_end":
diff --git a/server/testing/fake-pi-cli.ts b/server/testing/fake-pi-cli.ts
index 8582e98b1c..43c09ca754 100755
--- a/server/testing/fake-pi-cli.ts
+++ b/server/testing/fake-pi-cli.ts
@@ -140,9 +140,10 @@ const streamCompactionTurn = () => {
send({ type: "compaction_end", reason: "threshold", result: undefined, aborted: false, willRetry: false, errorMessage: "Compaction failed" });
send({ type: "compaction_start", reason: "threshold" });
send({ type: "compaction_end", reason: "threshold", result: undefined, aborted: false, willRetry: false });
- // An extension can also hand back a result with an empty summary: nothing usable was made, so no marker either.
+ // An extension can also hand back a result with an empty or non-text summary: nothing usable was made, so no marker either.
send({ type: "compaction_start", reason: "threshold" });
send({ type: "compaction_end", reason: "threshold", result: { summary: " ", firstKeptEntryId: "e1", tokensBefore: 100 }, aborted: false, willRetry: false });
+ send({ type: "compaction_end", reason: "threshold", result: { summary: {}, firstKeptEntryId: "e1", tokensBefore: 100 }, aborted: false, willRetry: false });
if (process.env.FAKE_PI_COMPACTION_FAILS_ONLY !== "1") {
send({ type: "compaction_start", reason: "threshold" });
send({ type: "compaction_end", reason: "threshold", result: { summary: "fake summary", firstKeptEntryId: "e1", tokensBefore: 100 }, aborted: false, willRetry: false });