mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 06:15:01 +00:00
Compaction Runner: add post-sync mode scaffold
(cherry picked from commit 6ff5dedd66)
This commit is contained in:
committed by
Josh Lehman
parent
5760f60a1c
commit
e5cf9f8d46
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user