show suggested link targets in agent prompts
Agents were flying blind — they could see nodes to review and the topology header, but had no way to discover what targets to link to. Now each node shows its top 8 text-similar semantic nodes that aren't already neighbors, giving agents a search-like capability. Also added section-level targeting guidance to linker.md, transfer.md, and replay.md prompts: always target the most specific section, not the file-level node. Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
59cfa2959f
commit
3e883b7ba7
4 changed files with 59 additions and 0 deletions
31
src/neuro.rs
31
src/neuro.rs
|
|
@ -284,6 +284,37 @@ fn format_nodes_section(store: &Store, items: &[ReplayItem], graph: &Graph) -> S
|
|||
out.push_str(")\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Suggested link targets: text-similar semantic nodes not already neighbors
|
||||
let neighbor_keys: std::collections::HashSet<&str> = neighbors.iter()
|
||||
.map(|(k, _)| k.as_str()).collect();
|
||||
let mut candidates: Vec<(&str, f32)> = store.nodes.iter()
|
||||
.filter(|(k, _)| {
|
||||
// Only semantic/topic file nodes, not episodic
|
||||
!k.starts_with("journal.") && !k.starts_with("deep-index.")
|
||||
&& !k.starts_with("daily-") && !k.starts_with("weekly-")
|
||||
&& !k.starts_with("monthly-") && !k.starts_with("session-")
|
||||
&& *k != &item.key
|
||||
&& !neighbor_keys.contains(k.as_str())
|
||||
})
|
||||
.map(|(k, n)| {
|
||||
let sim = similarity::cosine_similarity(content, &n.content);
|
||||
(k.as_str(), sim)
|
||||
})
|
||||
.filter(|(_, sim)| *sim > 0.1)
|
||||
.collect();
|
||||
candidates.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
|
||||
candidates.truncate(8);
|
||||
|
||||
if !candidates.is_empty() {
|
||||
out.push_str("\nSuggested link targets (by text similarity, not yet linked):\n");
|
||||
for (k, sim) in &candidates {
|
||||
let is_hub = graph.degree(k) >= hub_thresh;
|
||||
out.push_str(&format!(" - {} (sim={:.3}{})\n",
|
||||
k, sim, if is_hub { ", HUB" } else { "" }));
|
||||
}
|
||||
}
|
||||
|
||||
out.push_str("\n---\n\n");
|
||||
}
|
||||
out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue