From de204e307576225afcceec4439e8f019fbf2ff86 Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Wed, 11 Mar 2026 00:18:58 -0400 Subject: [PATCH] agents: surface search hit counts to guide keep/demote decisions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nodes actively found by search now show "Search hits: N ← actively found by search, prefer to keep" in both the node section (seen by extractor, linker, etc.) and rename candidate listings. Extractor and rename prompts updated to respect this signal — merge into high-hit nodes rather than demoting them, skip renaming nodes that are working well in search. --- poc-memory/agents/extractor.agent | 3 +++ poc-memory/agents/rename.agent | 3 +++ poc-memory/src/agents/prompts.rs | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/poc-memory/agents/extractor.agent b/poc-memory/agents/extractor.agent index 74bafb7..c08f58a 100644 --- a/poc-memory/agents/extractor.agent +++ b/poc-memory/agents/extractor.agent @@ -110,6 +110,9 @@ New node keys should be descriptive: `skills#bcachefs-assert-triage`, nodes. Make existing ones better rather than adding more. - **DEMOTE aggressively.** If a node's useful content is now captured in a better node, demote it. This is how the graph gets cleaner. +- **Respect search hits.** Nodes marked "actively found by search" are + being retrieved in live queries. Prefer to keep these — merge *into* + them rather than demoting them. - **Don't force it.** If the neighborhood is already well-organized, say so. "This neighborhood is clean — no changes needed" is a valid output. Don't produce filler. diff --git a/poc-memory/agents/rename.agent b/poc-memory/agents/rename.agent index 04a0e2f..68baa17 100644 --- a/poc-memory/agents/rename.agent +++ b/poc-memory/agents/rename.agent @@ -51,5 +51,8 @@ If a node already has a reasonable name, skip it. - **Don't rename to something longer than the original.** - **Preserve the date.** Always keep YYYY-MM-DD. - **When in doubt, skip.** A bad rename is worse than an auto-slug. +- **Respect search hits.** Nodes marked "actively found by search" are + being retrieved by their current name. Skip these unless the rename + clearly preserves searchability. {{rename}} diff --git a/poc-memory/src/agents/prompts.rs b/poc-memory/src/agents/prompts.rs index b43fc4a..ec5bce6 100644 --- a/poc-memory/src/agents/prompts.rs +++ b/poc-memory/src/agents/prompts.rs @@ -114,6 +114,11 @@ pub fn format_nodes_section(store: &Store, items: &[ReplayItem], graph: &Graph) } out.push('\n'); + let hits = crate::counters::search_hit_count(&item.key); + if hits > 0 { + out.push_str(&format!("Search hits: {} ← actively found by search, prefer to keep\n", hits)); + } + // Content (truncated for large nodes) let content = &node.content; if content.len() > 1500 { @@ -306,6 +311,11 @@ pub fn format_rename_candidates(store: &Store, count: usize) -> (Vec, St }; out.push_str(&format!("Created: {}\n", created)); + let hits = hit_map.get(key).copied().unwrap_or(0); + if hits > 0 { + out.push_str(&format!("Search hits: {} ← actively found by search, prefer to keep current name\n", hits)); + } + let content = &node.content; if content.len() > 800 { let truncated = crate::util::truncate(content, 800, "\n[...]");