diff --git a/poc-memory/src/agents/knowledge.rs b/poc-memory/src/agents/knowledge.rs index 183ef97..64aad7e 100644 --- a/poc-memory/src/agents/knowledge.rs +++ b/poc-memory/src/agents/knowledge.rs @@ -73,6 +73,11 @@ pub fn run_one_agent_with_keys( all_keys.extend(extra_keys); let agent_batch = super::prompts::AgentBatch { prompt, node_keys: all_keys }; + // Record visits eagerly so concurrent agents pick different seeds + if !agent_batch.node_keys.is_empty() { + store.record_agent_visits(&agent_batch.node_keys, agent_name).ok(); + } + run_one_agent_inner(store, agent_name, &def, agent_batch, llm_tag, log, debug) } @@ -90,6 +95,12 @@ pub fn run_one_agent( log("building prompt"); let agent_batch = super::defs::run_agent(store, &def, batch_size)?; + // Eagerly record visits so concurrent agents pick different seeds. + // The not-visited query filter checks this timestamp. + if !agent_batch.node_keys.is_empty() { + store.record_agent_visits(&agent_batch.node_keys, agent_name).ok(); + } + run_one_agent_inner(store, agent_name, &def, agent_batch, llm_tag, log, debug) } @@ -132,11 +143,6 @@ fn run_one_agent_inner( if debug { print!("{}", response_section); } log(&format!("response {}KB", output.len() / 1024)); - // Record visits for processed nodes - if !agent_batch.node_keys.is_empty() { - store.record_agent_visits(&agent_batch.node_keys, agent_name).ok(); - } - Ok(AgentResult { output, node_keys: agent_batch.node_keys,