forked from kent/consciousness
Include identity nodes in memory scoring
Identity memory nodes now participate in importance scoring alongside conversation memories. Score loading/saving handles both sections, and the conscious screen uses node.label() consistently for memory display. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
ba4e01b6f3
commit
7046e63b9d
3 changed files with 66 additions and 31 deletions
|
|
@ -62,8 +62,16 @@ fn build_token_ids(
|
|||
for node in context.system() {
|
||||
ids.extend(node.token_ids());
|
||||
}
|
||||
// Identity nodes can be filtered by key for scoring
|
||||
for node in context.identity() {
|
||||
ids.extend(node.token_ids());
|
||||
let skip = match &filter {
|
||||
Filter::SkipKey(key) => memory_key(node) == Some(*key),
|
||||
Filter::SkipAllMemories => is_memory(node),
|
||||
_ => false,
|
||||
};
|
||||
if !skip {
|
||||
ids.extend(node.token_ids());
|
||||
}
|
||||
}
|
||||
for node in context.journal() {
|
||||
ids.extend(node.token_ids());
|
||||
|
|
@ -175,7 +183,9 @@ pub async fn score_memories(
|
|||
// Collect memory keys and response indices under a brief lock
|
||||
let (memory_keys, response_indices) = {
|
||||
let ctx = agent.context.lock().await;
|
||||
let mut keys: Vec<String> = ctx.conversation().iter()
|
||||
// Include identity nodes and conversation memories
|
||||
let mut keys: Vec<String> = ctx.identity().iter()
|
||||
.chain(ctx.conversation().iter())
|
||||
.filter_map(|node| memory_key(node).map(String::from))
|
||||
.collect();
|
||||
keys.dedup();
|
||||
|
|
@ -331,7 +341,10 @@ where
|
|||
|
||||
{
|
||||
let store = &*store_arc;
|
||||
for (i, node) in context.conversation().iter().enumerate() {
|
||||
// Identity nodes always score at position 0; conversation nodes at their index
|
||||
let identity_nodes = context.identity().iter().map(|n| (0, n));
|
||||
let conv_nodes = context.conversation().iter().enumerate();
|
||||
for (pos, node) in identity_nodes.chain(conv_nodes) {
|
||||
if let Some(key) = memory_key(node) {
|
||||
if !seen.insert(key.to_owned()) { continue; }
|
||||
let last_scored = store.get_node(key)
|
||||
|
|
@ -340,7 +353,7 @@ where
|
|||
.map(|n| n.last_scored)
|
||||
.unwrap_or(0);
|
||||
if now - last_scored >= max_age_secs {
|
||||
candidates.push((i, key.to_owned(), last_scored));
|
||||
candidates.push((pos, key.to_owned(), last_scored));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue