surface: tag recent nodes as (new) instead of hiding them

Links to nodes created after the conversation window start are
tagged with (new) in memory_render output. The surface prompt
tells the agent not to surface these — they're its own recent
output, not prior memories. Observe can still see and update them.

POC_MEMORIES_OLDER_THAN env var set from the oldest message
timestamp in the conversation window.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-03-26 21:19:19 -04:00
parent 7fc1d60113
commit 27861a44e5
5 changed files with 75 additions and 23 deletions

View file

@ -599,12 +599,14 @@ fn resolve_conversation(budget: Option<usize>) -> String {
let max_bytes = budget.unwrap_or_else(|| cfg.surface_conversation_bytes.unwrap_or(100_000));
let mut fragments: Vec<String> = Vec::new();
let mut total_bytes = 0;
let mut oldest_ts = String::new();
for (role, content, ts) in iter {
if total_bytes >= max_bytes { break; }
let name = if role == "user" { &cfg.user_name } else { &cfg.assistant_name };
let formatted = if !ts.is_empty() {
format!("**{}** {}: {}", name, &ts[..ts.len().min(19)], content)
oldest_ts = ts[..ts.len().min(19)].to_string();
format!("**{}** {}: {}", name, &oldest_ts, content)
} else {
format!("**{}:** {}", name, content)
};
@ -612,6 +614,14 @@ fn resolve_conversation(budget: Option<usize>) -> String {
fragments.push(formatted);
}
// Set cutoff so surface doesn't see nodes created during this conversation
if !oldest_ts.is_empty() {
if let Ok(dt) = chrono::NaiveDateTime::parse_from_str(&oldest_ts, "%Y-%m-%dT%H:%M:%S") {
let epoch = dt.and_local_timezone(chrono::Local).unwrap().timestamp();
unsafe { std::env::set_var("POC_MEMORIES_OLDER_THAN", epoch.to_string()); }
}
}
// Reverse back to chronological order
fragments.reverse();
fragments.join("\n\n")