diff --git a/src/mind/mod.rs b/src/mind/mod.rs index 8327a06..ecc4192 100644 --- a/src/mind/mod.rs +++ b/src/mind/mod.rs @@ -239,7 +239,13 @@ impl Mind { for cmd in cmds { match cmd { MindCommand::None => {} - MindCommand::Compact => self.check_compaction(), + MindCommand::Compact => { + let threshold = compaction_threshold(&self.config.app); + let mut ag = self.agent.lock().await; + if ag.last_prompt_tokens() > threshold { + ag.compact(); + } + } MindCommand::Score => { let mut s = self.shared.lock().unwrap(); if !s.scoring_in_flight { @@ -317,19 +323,6 @@ impl Mind { }); } - fn check_compaction(&self) { - let threshold = compaction_threshold(&self.config.app); - let agent = self.agent.clone(); - let shared = self.shared.clone(); - shared.lock().unwrap().compaction_in_flight = true; - tokio::spawn(async move { - let mut ag = agent.lock().await; - if ag.last_prompt_tokens() > threshold { - ag.compact(); - } - shared.lock().unwrap().compaction_in_flight = false; - }); - } pub async fn shutdown(&mut self) {