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
+18 -2
View File
@@ -114,7 +114,23 @@ describe("CompactionPromptPlugin", () => {
);
expect(context.logs).toHaveLength(0);
expect(output.context).toHaveLength(1);
expect(output.context).toHaveLength(0);
});
test("does not modify compaction when no instructions are provided", async () => {
const context = await createContext();
const hooks = await CompactionPromptPlugin(context as never);
const output: { context: string[]; prompt?: string } = {
context: ["Existing context"],
};
await hooks["experimental.session.compacting"]?.(
{ sessionID: "test" },
output,
);
expect(output.context).toEqual(["Existing context"]);
expect(output.prompt).toBeUndefined();
});
test("logs non-missing memory file errors without failing compaction", async () => {
@@ -131,6 +147,6 @@ describe("CompactionPromptPlugin", () => {
);
expect(context.logs).toHaveLength(1);
expect(output.context).toHaveLength(1);
expect(output.context).toHaveLength(0);
});
});