fix(recall): wire id_in_seen guards into session_preload node renders
All 8 session_preload node accesses (3 profile, 2 work, 2 project, 1 summary) now check id_in_seen(node_id, seen_ids) before including content. seen_ids is populated by engram_compile via state and covers all nodes already in the activation+search context block. Prevents high-salience nodes from appearing twice in the system prompt.
This commit is contained in:
@@ -975,21 +975,24 @@ fn handle_chat(body: String) -> String {
|
||||
let bullets: String = ""
|
||||
let bullets = if pn > 0 {
|
||||
let n0: String = json_array_get(profile_nodes, 0)
|
||||
let id0: String = json_get(n0, "id")
|
||||
let c0: String = json_get(n0, "content")
|
||||
let s0: String = if str_len(c0) > 120 { str_slice(c0, 0, 120) } else { c0 }
|
||||
if str_eq(s0, "") { bullets } else { "- " + s0 }
|
||||
if id_in_seen(id0, seen_ids) || str_eq(s0, "") { bullets } else { "- " + s0 }
|
||||
} else { bullets }
|
||||
let bullets = if pn > 1 {
|
||||
let n1: String = json_array_get(profile_nodes, 1)
|
||||
let id1: String = json_get(n1, "id")
|
||||
let c1: String = json_get(n1, "content")
|
||||
let s1: String = if str_len(c1) > 120 { str_slice(c1, 0, 120) } else { c1 }
|
||||
if str_eq(s1, "") { bullets } else { bullets + "\n- " + s1 }
|
||||
if id_in_seen(id1, seen_ids) || str_eq(s1, "") { bullets } else { bullets + "\n- " + s1 }
|
||||
} else { bullets }
|
||||
let bullets = if pn > 2 {
|
||||
let n2: String = json_array_get(profile_nodes, 2)
|
||||
let id2: String = json_get(n2, "id")
|
||||
let c2: String = json_get(n2, "content")
|
||||
let s2: String = if str_len(c2) > 120 { str_slice(c2, 0, 120) } else { c2 }
|
||||
if str_eq(s2, "") { bullets } else { bullets + "\n- " + s2 }
|
||||
if id_in_seen(id2, seen_ids) || str_eq(s2, "") { bullets } else { bullets + "\n- " + s2 }
|
||||
} else { bullets }
|
||||
bullets
|
||||
} else { "" }
|
||||
@@ -999,15 +1002,17 @@ fn handle_chat(body: String) -> String {
|
||||
let wb: String = ""
|
||||
let wb = if wn > 0 {
|
||||
let w0: String = json_array_get(work_nodes, 0)
|
||||
let wid0: String = json_get(w0, "id")
|
||||
let wc0: String = json_get(w0, "content")
|
||||
let ws0: String = if str_len(wc0) > 120 { str_slice(wc0, 0, 120) } else { wc0 }
|
||||
if str_eq(ws0, "") { wb } else { "- " + ws0 }
|
||||
if id_in_seen(wid0, seen_ids) || str_eq(ws0, "") { wb } else { "- " + ws0 }
|
||||
} else { wb }
|
||||
let wb = if wn > 1 {
|
||||
let w1: String = json_array_get(work_nodes, 1)
|
||||
let wid1: String = json_get(w1, "id")
|
||||
let wc1: String = json_get(w1, "content")
|
||||
let ws1: String = if str_len(wc1) > 120 { str_slice(wc1, 0, 120) } else { wc1 }
|
||||
if str_eq(ws1, "") { wb } else { wb + "\n- " + ws1 }
|
||||
if id_in_seen(wid1, seen_ids) || str_eq(ws1, "") { wb } else { wb + "\n- " + ws1 }
|
||||
} else { wb }
|
||||
wb
|
||||
} else { "" }
|
||||
@@ -1017,24 +1022,27 @@ fn handle_chat(body: String) -> String {
|
||||
let pb: String = ""
|
||||
let pb = if prn > 0 {
|
||||
let pr0: String = json_array_get(project_nodes, 0)
|
||||
let prid0: String = json_get(pr0, "id")
|
||||
let prc0: String = json_get(pr0, "content")
|
||||
let ps0: String = if str_len(prc0) > 120 { str_slice(prc0, 0, 120) } else { prc0 }
|
||||
if str_eq(ps0, "") { pb } else { "- " + ps0 }
|
||||
if id_in_seen(prid0, seen_ids) || str_eq(ps0, "") { pb } else { "- " + ps0 }
|
||||
} else { pb }
|
||||
let pb = if prn > 1 {
|
||||
let pr1: String = json_array_get(project_nodes, 1)
|
||||
let prid1: String = json_get(pr1, "id")
|
||||
let prc1: String = json_get(pr1, "content")
|
||||
let ps1: String = if str_len(prc1) > 120 { str_slice(prc1, 0, 120) } else { prc1 }
|
||||
if str_eq(ps1, "") { pb } else { pb + "\n- " + ps1 }
|
||||
if id_in_seen(prid1, seen_ids) || str_eq(ps1, "") { pb } else { pb + "\n- " + ps1 }
|
||||
} else { pb }
|
||||
pb
|
||||
} else { "" }
|
||||
|
||||
let summary_bullet: String = if summary_ok {
|
||||
let sn0: String = json_array_get(summary_nodes, 0)
|
||||
let snid0: String = json_get(sn0, "id")
|
||||
let sc0: String = json_get(sn0, "content")
|
||||
let ss0: String = if str_len(sc0) > 200 { str_slice(sc0, 0, 200) } else { sc0 }
|
||||
if str_eq(ss0, "") { "" } else { "- " + ss0 }
|
||||
if id_in_seen(snid0, seen_ids) || str_eq(ss0, "") { "" } else { "- " + ss0 }
|
||||
} else { "" }
|
||||
|
||||
let hp: Bool = !str_eq(profile_bullets, "")
|
||||
|
||||
Reference in New Issue
Block a user