feat(FN-1553): reduce memory bloat with selective save behavior

- Update project memory instructions to encourage selective writes instead of unconditional appends
- Instruct agents to consolidate existing entries rather than add duplicates
- Add guidance to skip memory updates when no durable learnings were discovered
- Clarify what qualifies as durable learnings vs task-specific trivia
- Update user-facing memory documentation to reflect new selective behavior
- Add test coverage for selective memory write instructions
This commit is contained in:
gsxdsm
2026-04-11 00:35:39 -07:00
parent afa2e153ee
commit c8831f7b3b
6 changed files with 135 additions and 785 deletions

View File

@@ -173,10 +173,29 @@ describe("project-memory", () => {
expect(instructions).toMatch(/read.*memory\.md/i);
});
it("instructs agent to append learnings at end", () => {
it("instructs agent to selectively write learnings at end", () => {
const instructions = buildExecutionMemoryInstructions(testDir);
expect(instructions).toMatch(/end of execution|before calling.*task_done/i);
expect(instructions).toMatch(/append/i);
// Should mention selective/skip behavior, not just append
expect(instructions).toMatch(/skip.*memory.*update|selectively|durable.*learnings/i);
});
it("instructs agent to skip when nothing durable was learned", () => {
const instructions = buildExecutionMemoryInstructions(testDir);
// Should explicitly allow skipping when nothing durable was learned
expect(instructions).toMatch(/skip.*memory.*update|nothing durable|if nothing/i);
});
it("instructs agent to avoid task-specific trivia", () => {
const instructions = buildExecutionMemoryInstructions(testDir);
// Should explicitly forbid task-specific trivia
expect(instructions).toMatch(/avoid.*trivia|task-specific.*trivia|per-task.*log|changelog/i);
});
it("allows editing/consolidating existing entries", () => {
const instructions = buildExecutionMemoryInstructions(testDir);
// Should allow consolidation/editing, not forbid it
expect(instructions).toMatch(/consolidate|update.*refine.*existing|edit.*existing/i);
});
it("specifies project-root path not worktree-local", () => {
@@ -184,10 +203,5 @@ describe("project-memory", () => {
// Should use .fusion/memory.md (project root relative) not absolute worktree paths
expect(instructions).toContain("`.fusion/memory.md`");
});
it("warns against deleting existing content", () => {
const instructions = buildExecutionMemoryInstructions(testDir);
expect(instructions).toMatch(/do not delete|only append/i);
});
});
});