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:
parent
f45f663dc0
commit
5ef9098deb
4 changed files with 124 additions and 17 deletions
|
|
@ -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()));
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ impl Store {
|
|||
let mut node = existing.clone();
|
||||
node.content = content.to_string();
|
||||
node.provenance = provenance.to_string();
|
||||
node.timestamp = now_epoch();
|
||||
node.version += 1;
|
||||
self.append_nodes_unlocked(std::slice::from_ref(&node))?;
|
||||
self.nodes.insert(key.to_string(), node);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue