fix: skip empty compaction instructions

This commit is contained in:
2026-08-01 16:57:58 +05:30
parent 018ee0a85e
commit f3e8dd4b04
5 changed files with 33 additions and 5 deletions
+9 -1
View File
@@ -28,7 +28,11 @@ function buildInstructions(
prompt: string,
completionMarker: string,
memory: string,
): string {
): string | undefined {
if (!prompt && !memory) {
return undefined;
}
const sections = [
"## User Compaction Instructions",
`These instructions take precedence over previous instructions if there is conflict. At the very end of the summary, echo exactly: **${completionMarker}**`,
@@ -110,6 +114,10 @@ export const CompactionPromptPlugin: Plugin = async (
const memory = await readMemory(memoryPath, logError);
const instructions = buildInstructions(prompt, completionMarker, memory);
if (!instructions) {
return;
}
if (mode === "replace") {
output.prompt = instructions;
} else {