mirror of
https://github.com/sdwolf4103/opencode-working-memory.git
synced 2026-06-02 06:19:36 +02:00
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'
This commit is contained in:
@@ -114,6 +114,22 @@ function buildCompactionPrompt(privateContext: string): string {
|
||||
"",
|
||||
"When unsure, skip it. Fewer high-signal memories are better than many low-value ones.",
|
||||
"",
|
||||
"Good memory examples:",
|
||||
"- [feedback] User prefers architecture reviews in Traditional Chinese.",
|
||||
"- [decision] Use frozen workspace memory snapshots plus ephemeral hot state for cache stability.",
|
||||
"- [project] The plugin should piggyback memory extraction on OpenCode compaction and avoid extra LLM calls.",
|
||||
"- [reference] Workspace memory appears in frozen system[1]; pending memories appear in hot session state until compaction.",
|
||||
"",
|
||||
"Bad memory examples to skip:",
|
||||
"- 42 tests passed.",
|
||||
"- Wave 2 completed successfully.",
|
||||
"- Modified 5 files.",
|
||||
"- commit 4309cb8 contains the latest fix.",
|
||||
"- TypeError: Cannot read properties of undefined.",
|
||||
"- Currently running npm test.",
|
||||
"",
|
||||
"A memory should still be useful if a new agent opens this workspace next week.",
|
||||
"",
|
||||
"Only extract facts that are likely to stay true across sessions.",
|
||||
"Do not extract session-specific progress like exact test counts, file counts, or phase numbers.",
|
||||
"For progress, extract the stable goal or durable milestone, not the current number.",
|
||||
|
||||
@@ -275,6 +275,14 @@ test("compaction hook sets output.prompt with ---free template", async () => {
|
||||
// Should contain Memory candidates format
|
||||
assert.equal(prompt!.includes("Memory candidates:"), true,
|
||||
"Prompt should include Memory candidates: label");
|
||||
assert.equal(prompt!.includes("Good memory examples:"), true,
|
||||
"Prompt should include concrete positive memory examples");
|
||||
assert.equal(prompt!.includes("Bad memory examples to skip:"), true,
|
||||
"Prompt should include concrete negative memory examples");
|
||||
assert.equal(prompt!.includes("42 tests passed"), true,
|
||||
"Prompt should explicitly reject test-count snapshots");
|
||||
assert.equal(prompt!.includes("commit 4309cb8"), true,
|
||||
"Prompt should explicitly reject commit-hash snapshots");
|
||||
|
||||
// Should contain our context data (hot session state)
|
||||
assert.equal(prompt!.includes("Hot session state"), true,
|
||||
|
||||
Reference in New Issue
Block a user