Compaction Runner: add post-sync mode scaffold

(cherry picked from commit 6ff5dedd66)
This commit is contained in:
Rodrigo Uroz
2026-02-24 16:32:43 +00:00
committed by Josh Lehman
parent 5760f60a1c
commit e5cf9f8d46

View File

@@ -268,6 +268,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<void> {
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.
@@ -810,6 +827,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 {