memory: fix timestamp and provenance on agent writes

Two bugs: upsert_provenance didn't update node.timestamp, so history
showed the original creation date for every version. And native memory
tools (poc-agent dispatch) didn't set POC_PROVENANCE, so all agent
writes showed provenance "manual" instead of "agent:organize" etc.

Fix: set node.timestamp = now_epoch() in upsert_provenance. Thread
provenance through memory::dispatch as Option<&str>, set it via
.env("POC_PROVENANCE") on each subprocess Command. api.rs passes
"agent:{name}" for daemon agent calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kent Overstreet 2026-03-20 12:16:45 -04:00
parent f45f663dc0
commit 5ef9098deb
4 changed files with 124 additions and 17 deletions

View file

@ -82,7 +82,24 @@ pub async fn call_api_with_tools(
let args: serde_json::Value = serde_json::from_str(&call.function.arguments)
.unwrap_or_default();
let output = tools::dispatch(&call.function.name, &args, &tracker).await;
let output = if call.function.name.starts_with("memory_") {
let prov = format!("agent:{}", agent);
match poc_agent::tools::memory::dispatch(
&call.function.name, &args, Some(&prov),
) {
Ok(text) => poc_agent::tools::ToolOutput {
text, is_yield: false, images: Vec::new(),
model_switch: None, dmn_pause: false,
},
Err(e) => poc_agent::tools::ToolOutput {
text: format!("Error: {}", e),
is_yield: false, images: Vec::new(),
model_switch: None, dmn_pause: false,
},
}
} else {
tools::dispatch(&call.function.name, &args, &tracker).await
};
log(&format!("tool result: {} chars", output.text.len()));