Skip to content

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

fix(pi): no condensed marker when pi reports a failed compaction

AdityaUmale75f3f533d13e
diff --git a/server/drivers/pi.ts b/server/drivers/pi.ts
index e955843d89..9a56f00ef8 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") && (evt as { aborted?: boolean }).aborted !== true) emit({ ...base(threadId, turnId), type: "context.compacted" });
+ if (evt.type.endsWith("compaction_end") && !(evt as { aborted?: boolean }).aborted && !(evt as { errorMessage?: string }).errorMessage) 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 eba26843ab..9b9e3211e4 100755
--- a/server/testing/fake-pi-cli.ts
+++ b/server/testing/fake-pi-cli.ts
@@ -133,6 +133,9 @@ const streamErrorTurn = () => {
const streamCompactionTurn = () => {
send({ type: "agent_start" });
send({ type: "turn_start" });
+ // A failed attempt first (pi reports it with errorMessage, not aborted), then the one that succeeds.
+ send({ type: "compaction_start", reason: "threshold" });
+ 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 });
send({ type: "message_update", usage: { input: 0, output: 0 }, assistantMessageEvent: { type: "text_delta", contentIndex: 0, delta: "compacted" } });