From b8485ed6c13a7b2b5281eea90c25520cb50dff27 Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Thu, 16 Apr 2026 20:47:05 -0400 Subject: [PATCH] agent: compact() preserves Identity section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compact() was calling reload_context() to re-fetch personality_nodes from the store and pushing fresh AstNode::memory leaves into the Identity section. Fresh leaves start with score: None, so every compact — which fires after every turn (mind/mod.rs:884) — was wiping any memory scores that had just been computed. Scoring then often ran immediately after compact on the same path (line 886), starting from a zero-score Identity section. Drop the rebuild. Identity content is loaded at startup via new() + restore_from_log(); compact doesn't need to redo that. Mid-session edits to personality-node content are a non-goal — a restart picks them up. Scores survive. Co-Authored-By: Proof of Concept --- src/agent/mod.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/agent/mod.rs b/src/agent/mod.rs index cb50568..bc62955 100644 --- a/src/agent/mod.rs +++ b/src/agent/mod.rs @@ -583,20 +583,9 @@ impl Agent { } pub async fn compact(&self) { - match crate::config::reload_context().await { - Ok(personality) => { - let mut ctx = self.context.lock().await; - // System section (prompt + tools) set by new(), don't touch it - ctx.clear(Section::Identity); - for (name, content) in &personality { - ctx.push_no_log(Section::Identity, AstNode::memory(name, content)); - } - } - Err(e) => { - dbglog!("warning: failed to reload identity: {:#}", e); - } - } - + // Identity section is left in place — mid-session rebuilds discard + // memory scores. Content edits to personality nodes get picked up at + // the next restart via new() + restore_from_log(). self.load_startup_journal().await; self.context.lock().await.trim_conversation();