Skip to content

Commit ca68b7f

Browse files
committed
feat: sharpen compaction memory extraction prompt
Wave 3 of memory quality optimization plan. - Add good memory examples in buildCompactionPrompt() - Add bad memory examples to skip (test counts, commit hashes, etc.) - Add prompt assertions in tests to prevent regression - Emphasize 'useful if a new agent opens this workspace next week'
1 parent 023589a commit ca68b7f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/plugin.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ function buildCompactionPrompt(privateContext: string): string {
114114
"",
115115
"When unsure, skip it. Fewer high-signal memories are better than many low-value ones.",
116116
"",
117+
"Good memory examples:",
118+
"- [feedback] User prefers architecture reviews in Traditional Chinese.",
119+
"- [decision] Use frozen workspace memory snapshots plus ephemeral hot state for cache stability.",
120+
"- [project] The plugin should piggyback memory extraction on OpenCode compaction and avoid extra LLM calls.",
121+
"- [reference] Workspace memory appears in frozen system[1]; pending memories appear in hot session state until compaction.",
122+
"",
123+
"Bad memory examples to skip:",
124+
"- 42 tests passed.",
125+
"- Wave 2 completed successfully.",
126+
"- Modified 5 files.",
127+
"- commit 4309cb8 contains the latest fix.",
128+
"- TypeError: Cannot read properties of undefined.",
129+
"- Currently running npm test.",
130+
"",
131+
"A memory should still be useful if a new agent opens this workspace next week.",
132+
"",
117133
"Only extract facts that are likely to stay true across sessions.",
118134
"Do not extract session-specific progress like exact test counts, file counts, or phase numbers.",
119135
"For progress, extract the stable goal or durable milestone, not the current number.",

tests/plugin.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ test("compaction hook sets output.prompt with ---free template", async () => {
275275
// Should contain Memory candidates format
276276
assert.equal(prompt!.includes("Memory candidates:"), true,
277277
"Prompt should include Memory candidates: label");
278+
assert.equal(prompt!.includes("Good memory examples:"), true,
279+
"Prompt should include concrete positive memory examples");
280+
assert.equal(prompt!.includes("Bad memory examples to skip:"), true,
281+
"Prompt should include concrete negative memory examples");
282+
assert.equal(prompt!.includes("42 tests passed"), true,
283+
"Prompt should explicitly reject test-count snapshots");
284+
assert.equal(prompt!.includes("commit 4309cb8"), true,
285+
"Prompt should explicitly reject commit-hash snapshots");
278286

279287
// Should contain our context data (hot session state)
280288
assert.equal(prompt!.includes("Hot session state"), true,

0 commit comments

Comments
 (0)