fix(memory-core): avoid double bulleting promoted snippets (#85724) · openclaw/openclaw@983a3b9
davidbennett
·
2026-05-23
·
via Recent Commits to openclaw:main
File tree
extensions/memory-core/src
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1417,6 +1417,48 @@ describe("short-term promotion", () => {
|
1417 | 1417 | }); |
1418 | 1418 | }); |
1419 | 1419 | |
| 1420 | +it("does not double-prefix promoted snippets that are already markdown bullets", async () => { |
| 1421 | +await withTempWorkspace(async (workspaceDir) => { |
| 1422 | +await writeDailyMemoryNote(workspaceDir, "2026-04-01", [ |
| 1423 | +"alpha", |
| 1424 | +"- Gateway binds loopback and port 18789", |
| 1425 | +]); |
| 1426 | +await recordShortTermRecalls({ |
| 1427 | + workspaceDir, |
| 1428 | +query: "gateway host", |
| 1429 | +results: [ |
| 1430 | +{ |
| 1431 | +path: "memory/2026-04-01.md", |
| 1432 | +startLine: 2, |
| 1433 | +endLine: 2, |
| 1434 | +score: 0.92, |
| 1435 | +snippet: "- Gateway binds loopback and port 18789", |
| 1436 | +source: "memory", |
| 1437 | +}, |
| 1438 | +], |
| 1439 | +}); |
| 1440 | + |
| 1441 | +const ranked = await rankShortTermPromotionCandidates({ |
| 1442 | + workspaceDir, |
| 1443 | +minScore: 0, |
| 1444 | +minRecallCount: 0, |
| 1445 | +minUniqueQueries: 0, |
| 1446 | +}); |
| 1447 | +const applied = await applyShortTermPromotions({ |
| 1448 | + workspaceDir, |
| 1449 | +candidates: ranked, |
| 1450 | +minScore: 0, |
| 1451 | +minRecallCount: 0, |
| 1452 | +minUniqueQueries: 0, |
| 1453 | +}); |
| 1454 | + |
| 1455 | +expect(applied.applied).toBe(1); |
| 1456 | +const memoryText = await fs.readFile(path.join(workspaceDir, "MEMORY.md"), "utf-8"); |
| 1457 | +expect(memoryText).toContain("- Gateway binds loopback and port 18789"); |
| 1458 | +expect(memoryText).not.toContain("- - Gateway binds loopback and port 18789"); |
| 1459 | +}); |
| 1460 | +}); |
| 1461 | + |
1420 | 1462 | it("does not re-append candidates that were promoted in a prior run", async () => { |
1421 | 1463 | await withTempWorkspace(async (workspaceDir) => { |
1422 | 1464 | await writeDailyMemoryNote(workspaceDir, "2026-04-01", [ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1584,7 +1584,7 @@ function buildPromotionSection(
|
1584 | 1584 | const snippet = candidate.snippet || "(no snippet captured)"; |
1585 | 1585 | lines.push(`<!-- ${PROMOTION_MARKER_PREFIX}${candidate.key} -->`); |
1586 | 1586 | lines.push( |
1587 | | -`- ${snippet} [score=${candidate.score.toFixed(3)} recalls=${candidate.recallCount} avg=${candidate.avgScore.toFixed(3)} source=${source}]`, |
| 1587 | +`- ${snippet.replace(/^- +/, "")} [score=${candidate.score.toFixed(3)} recalls=${candidate.recallCount} avg=${candidate.avgScore.toFixed(3)} source=${source}]`, |
1588 | 1588 | ); |
1589 | 1589 | } |
1590 | 1590 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。