From 52e2db4221234177338a1ab73cf91fb777155da3 Mon Sep 17 00:00:00 2001 From: Rodrigo Uroz Date: Tue, 24 Feb 2026 16:32:43 +0000 Subject: [PATCH] Compaction Runner: add post-sync mode scaffold --- src/agents/pi-embedded-runner/compact.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/agents/pi-embedded-runner/compact.ts b/src/agents/pi-embedded-runner/compact.ts index 4a3f580b646..2895f0d730d 100644 --- a/src/agents/pi-embedded-runner/compact.ts +++ b/src/agents/pi-embedded-runner/compact.ts @@ -242,6 +242,23 @@ function classifyCompactionReason(reason?: string): string { return "unknown"; } +function resolvePostCompactionIndexSyncMode(config?: OpenClawConfig): "off" | "async" | "await" { + const mode = config?.agents?.defaults?.compaction?.postIndexSync; + if (mode === "off" || mode === "async" || mode === "await") { + return mode; + } + return "async"; +} + +async function syncPostCompactionSessionMemory(params: { + config?: OpenClawConfig; + mode: "off" | "async" | "await"; +}): Promise { + if (params.mode === "off" || !params.config) { + return; + } +} + /** * Core compaction logic without lane queueing. * Use this when already inside a session/global lane to avoid deadlocks. @@ -667,6 +684,10 @@ export async function compactEmbeddedPiSessionDirect( session.compact(params.customInstructions), ); emitSessionTranscriptUpdate(params.sessionFile); + await syncPostCompactionSessionMemory({ + config: params.config, + mode: resolvePostCompactionIndexSyncMode(params.config), + }); // Estimate tokens after compaction by summing token estimates for remaining messages let tokensAfter: number | undefined; try {