mind: inline compaction (not async), remove check_compaction
Compaction is CPU-only on in-memory data — no reason to spawn a task. Inline it in run_commands as a synchronous agent lock + compact. Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
2d6a17e773
commit
556a56035b
1 changed files with 7 additions and 14 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue