Fix agent provenance and add store activity for unconscious agents

- Remove bogus "agent:" prefix from provenance - just use agent name
- Add history field to UnconsciousSnapshot
- Update snapshots() to fetch store activity via recent_by_provenance
- Fix TUI to display store activity for both agent types

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-11 21:57:24 -04:00
parent d2dbdedc8f
commit e9e7458013
5 changed files with 66 additions and 32 deletions

View file

@ -456,10 +456,8 @@ impl Subconscious {
pub fn snapshots(&self, store: Option<&crate::store::Store>) -> Vec<SubconsciousSnapshot> {
self.agents.iter().map(|s| {
let history = store.map(|st| {
let prov = format!("agent:{}", s.name);
st.recent_by_provenance(&prov, 30)
}).unwrap_or_default();
let history = store.map(|st| st.recent_by_provenance(&s.name, 30))
.unwrap_or_default();
s.snapshot(&self.state, history)
}).collect()
}
@ -595,10 +593,9 @@ impl Subconscious {
dbglog!("[subconscious] triggering {}", auto.name);
let forked = agent.fork(auto.tools.clone()).await;
let prov = format!("agent:{}", auto.name);
{
let mut st = forked.state.lock().await;
st.provenance = prov.clone();
st.provenance = auto.name.clone();
// Surface agent gets near-interactive priority;
// other subconscious agents get lower priority.
st.priority = Some(if auto.name == "surface" { 1 } else { 2 });
@ -611,7 +608,7 @@ impl Subconscious {
let keys = memory_keys.clone();
let st = self.state.clone();
let recent: Vec<String> = store_guard.as_ref()
.map(|s| s.recent_by_provenance(&prov, 50)
.map(|s| s.recent_by_provenance(&auto.name, 50)
.into_iter().map(|(k, _)| k).collect())
.unwrap_or_default();