diff --git a/src/mind/dmn.rs b/src/mind/dmn.rs index 86cbfff..28d6007 100644 --- a/src/mind/dmn.rs +++ b/src/mind/dmn.rs @@ -297,9 +297,11 @@ pub struct SubconsciousSnapshot { } struct SubconsciousAgent { + name: String, auto: AutoAgent, last_trigger_bytes: u64, last_run: Option, + last_run_entries: Vec, handle: Option)>>, } @@ -326,7 +328,11 @@ impl SubconsciousAgent { def.temperature.unwrap_or(0.6), def.priority, ); - Some(Self { auto, last_trigger_bytes: 0, last_run: None, handle: None }) + Some(Self { + name: name.to_string(), + auto, last_trigger_bytes: 0, last_run: None, + last_run_entries: Vec::new(), handle: None, + }) } fn is_running(&self) -> bool { @@ -341,12 +347,12 @@ impl SubconsciousAgent { fn snapshot(&self) -> SubconsciousSnapshot { SubconsciousSnapshot { - name: self.auto.name.clone(), + name: self.name.clone(), running: self.is_running(), current_phase: self.auto.current_phase.clone(), turn: self.auto.turn, last_run_secs_ago: self.last_run.map(|t| t.elapsed().as_secs_f64()), - last_run_entries: self.auto.last_run_entries.clone(), + last_run_entries: self.last_run_entries.clone(), } } } @@ -387,11 +393,12 @@ impl Subconscious { let (auto_back, result) = handle.await.unwrap_or_else( |e| (AutoAgent::new(String::new(), vec![], vec![], 0.0, 0), Err(format!("task panicked: {}", e)))); + self.agents[idx].last_run_entries = auto_back.last_run_entries.clone(); self.agents[idx].auto = auto_back; match result { Ok(_) => { - let name = self.agents[idx].auto.name.clone(); + let name = self.agents[idx].name.clone(); let outputs = std::mem::take(&mut self.agents[idx].auto.outputs); if let Some(walked_str) = outputs.get("walked") {