Fix subconscious screen showing empty names during runs
Keep name and last_run_entries on SubconsciousAgent directly, not just on the AutoAgent (which gets replaced with a placeholder during spawned runs). Snapshot reads stable fields. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
3788695634
commit
48c843234d
1 changed files with 11 additions and 4 deletions
|
|
@ -297,9 +297,11 @@ pub struct SubconsciousSnapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SubconsciousAgent {
|
struct SubconsciousAgent {
|
||||||
|
name: String,
|
||||||
auto: AutoAgent,
|
auto: AutoAgent,
|
||||||
last_trigger_bytes: u64,
|
last_trigger_bytes: u64,
|
||||||
last_run: Option<Instant>,
|
last_run: Option<Instant>,
|
||||||
|
last_run_entries: Vec<ConversationEntry>,
|
||||||
handle: Option<tokio::task::JoinHandle<(AutoAgent, Result<String, String>)>>,
|
handle: Option<tokio::task::JoinHandle<(AutoAgent, Result<String, String>)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +328,11 @@ impl SubconsciousAgent {
|
||||||
def.temperature.unwrap_or(0.6), def.priority,
|
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 {
|
fn is_running(&self) -> bool {
|
||||||
|
|
@ -341,12 +347,12 @@ impl SubconsciousAgent {
|
||||||
|
|
||||||
fn snapshot(&self) -> SubconsciousSnapshot {
|
fn snapshot(&self) -> SubconsciousSnapshot {
|
||||||
SubconsciousSnapshot {
|
SubconsciousSnapshot {
|
||||||
name: self.auto.name.clone(),
|
name: self.name.clone(),
|
||||||
running: self.is_running(),
|
running: self.is_running(),
|
||||||
current_phase: self.auto.current_phase.clone(),
|
current_phase: self.auto.current_phase.clone(),
|
||||||
turn: self.auto.turn,
|
turn: self.auto.turn,
|
||||||
last_run_secs_ago: self.last_run.map(|t| t.elapsed().as_secs_f64()),
|
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(
|
let (auto_back, result) = handle.await.unwrap_or_else(
|
||||||
|e| (AutoAgent::new(String::new(), vec![], vec![], 0.0, 0),
|
|e| (AutoAgent::new(String::new(), vec![], vec![], 0.0, 0),
|
||||||
Err(format!("task panicked: {}", e))));
|
Err(format!("task panicked: {}", e))));
|
||||||
|
self.agents[idx].last_run_entries = auto_back.last_run_entries.clone();
|
||||||
self.agents[idx].auto = auto_back;
|
self.agents[idx].auto = auto_back;
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
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);
|
let outputs = std::mem::take(&mut self.agents[idx].auto.outputs);
|
||||||
|
|
||||||
if let Some(walked_str) = outputs.get("walked") {
|
if let Some(walked_str) = outputs.get("walked") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue