Feed observe agents their recent writes to prevent duplicate nodes

Observe was creating byte-identical nodes under slightly different names
(e.g. april-8-evening-folded-presence, -presence-2, -folded-state)
because it had no visibility into its own prior writes across runs.

Query recent writes by provenance in trigger(), pass through
run_forked_shared/resolve_prompt as {{recently_written}}, and include
the list in the observe phase prompts so the agent knows what it
already recorded.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-08 23:27:12 -04:00
parent 44a0bc376a
commit 24b211dc35
4 changed files with 28 additions and 4 deletions

View file

@ -52,6 +52,7 @@ fn resolve_prompt(
template: &str,
memory_keys: &[String],
state: &std::collections::BTreeMap<String, String>,
recently_written: &[String],
) -> String {
let cfg = crate::config::get();
let template = template.replace("{assistant_name}", &cfg.assistant_name);
@ -67,6 +68,7 @@ fn resolve_prompt(
} else {
match name {
"seen_current" => format_key_list(memory_keys),
"recently_written" => format_key_list(recently_written),
_ => {
result.push_str("{{");
result.push_str(&after[..end + 2]);
@ -152,9 +154,10 @@ impl AutoAgent {
agent: &std::sync::Arc<Agent>,
memory_keys: &[String],
state: &std::collections::BTreeMap<String, String>,
recently_written: &[String],
) -> Result<String, String> {
let resolved_steps: Vec<AutoStep> = self.steps.iter().map(|s| AutoStep {
prompt: resolve_prompt(&s.prompt, memory_keys, state),
prompt: resolve_prompt(&s.prompt, memory_keys, state, recently_written),
phase: s.phase.clone(),
}).collect();
let orig_steps = std::mem::replace(&mut self.steps, resolved_steps);