diff --git a/src/mind/subconscious.rs b/src/mind/subconscious.rs index 6e85081..d10f9e1 100644 --- a/src/mind/subconscious.rs +++ b/src/mind/subconscious.rs @@ -617,6 +617,7 @@ impl Subconscious { self.agents[idx].handle = Some(tokio::spawn(async move { let result = auto.run_forked_shared(&forked, &keys, &st, &recent).await; + super::unconscious::save_agent_log(&auto.name, &forked).await; (auto, result) })); } diff --git a/src/mind/unconscious.rs b/src/mind/unconscious.rs index 009e80f..a7e9e0a 100644 --- a/src/mind/unconscious.rs +++ b/src/mind/unconscious.rs @@ -296,17 +296,22 @@ impl Unconscious { } } -async fn save_agent_log(name: &str, agent: &std::sync::Arc) { +pub async fn save_agent_log(name: &str, agent: &std::sync::Arc) { let dir = dirs::home_dir().unwrap_or_default() .join(format!(".consciousness/logs/{}", name)); if std::fs::create_dir_all(&dir).is_err() { return; } let ts = chrono::Utc::now().format("%Y%m%d-%H%M%S"); let path = dir.join(format!("{}.json", ts)); - let nodes: Vec = { + let sections: serde_json::Value = { let ctx = agent.context.lock().await; - ctx.conversation().to_vec() + serde_json::json!({ + "system": ctx.system(), + "identity": ctx.identity(), + "journal": ctx.journal(), + "conversation": ctx.conversation(), + }) }; - if let Ok(json) = serde_json::to_string_pretty(&nodes) { + if let Ok(json) = serde_json::to_string_pretty(§ions) { let _ = std::fs::write(&path, json); dbglog!("[unconscious] saved log to {}", path.display()); }