Memory scores on entries, not a separate Vec

ConversationEntry::Memory gains score: Option<f64>. The scorer
writes scores directly onto entries when results arrive. Removes
Agent.memory_scores Vec and the memory_scores parameter from
context_state_summary().

Scores are serialized to/from the conversation log as memory_score.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 03:14:24 -04:00
parent 93f5f8b0c7
commit 39dcf27bd0
6 changed files with 36 additions and 50 deletions

View file

@ -276,7 +276,7 @@ impl Mind {
MindCommand::Compact => {
let threshold = compaction_threshold(&self.config.app) as usize;
let mut ag = self.agent.lock().await;
let sections = ag.context_state_summary(None);
let sections = ag.context_state_summary();
if crate::agent::context::sections_used(&sections) > threshold {
ag.compact();
ag.notify("compacted");
@ -341,7 +341,18 @@ impl Mind {
{
let mut ag = agent.lock().await;
ag.memory_scoring_in_flight = false;
if let Ok(ref scores) = result { ag.memory_scores = scores.clone(); }
if let Ok(ref scores) = result {
// Write scores onto Memory entries
for (key, weight) in scores {
for entry in &mut ag.context.entries {
if let crate::agent::context::ConversationEntry::Memory {
key: k, score, ..
} = entry {
if k == key { *score = Some(*weight); }
}
}
}
}
}
let _ = bg_tx.send(BgEvent::ScoringDone);
});
@ -364,7 +375,7 @@ impl Mind {
// Compact if over budget before sending
let threshold = compaction_threshold(&self.config.app) as usize;
let used = crate::agent::context::sections_used(
&ag.context_state_summary(None));
&ag.context_state_summary());
if used > threshold {
ag.compact();
ag.notify("compacted");