fix/context-dedup-shared-ids
This commit is contained in:
@@ -1001,6 +1001,7 @@ fn handle_chat(body: String) -> String {
|
||||
// Issue 9 fix: add project-specific and session-summary searches to session preload.
|
||||
// Old hardcoded "user profile" and "in_progress active project" miss project-specific
|
||||
// nodes stored under names like "Prism" unless those exact words appear in content.
|
||||
// Dedup fix: skip any node whose ID already appeared in engram_compile's output.
|
||||
let session_preload: String = if hist_len == 0 {
|
||||
let profile_nodes: String = engram_search_json("user profile identity preferences", 5)
|
||||
let work_nodes: String = engram_search_json("in_progress active project work", 5)
|
||||
@@ -1026,21 +1027,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 n0_id: 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 str_eq(s0, "") || id_in_seen(n0_id, seen_ids) { bullets } else { "- " + s0 }
|
||||
} else { bullets }
|
||||
let bullets = if pn > 1 {
|
||||
let n1: String = json_array_get(profile_nodes, 1)
|
||||
let n1_id: 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 str_eq(s1, "") || id_in_seen(n1_id, seen_ids) { bullets } else { bullets + "\n- " + s1 }
|
||||
} else { bullets }
|
||||
let bullets = if pn > 2 {
|
||||
let n2: String = json_array_get(profile_nodes, 2)
|
||||
let n2_id: 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 str_eq(s2, "") || id_in_seen(n2_id, seen_ids) { bullets } else { bullets + "\n- " + s2 }
|
||||
} else { bullets }
|
||||
bullets
|
||||
} else { "" }
|
||||
@@ -1050,15 +1054,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 w0_id: 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 str_eq(ws0, "") || id_in_seen(w0_id, seen_ids) { wb } else { "- " + ws0 }
|
||||
} else { wb }
|
||||
let wb = if wn > 1 {
|
||||
let w1: String = json_array_get(work_nodes, 1)
|
||||
let w1_id: 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 str_eq(ws1, "") || id_in_seen(w1_id, seen_ids) { wb } else { wb + "\n- " + ws1 }
|
||||
} else { wb }
|
||||
wb
|
||||
} else { "" }
|
||||
@@ -1068,24 +1074,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 pr0_id: 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 str_eq(ps0, "") || id_in_seen(pr0_id, seen_ids) { pb } else { "- " + ps0 }
|
||||
} else { pb }
|
||||
let pb = if prn > 1 {
|
||||
let pr1: String = json_array_get(project_nodes, 1)
|
||||
let pr1_id: 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 str_eq(ps1, "") || id_in_seen(pr1_id, seen_ids) { 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 sn0_id: 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 str_eq(ss0, "") || id_in_seen(sn0_id, seen_ids) { "" } else { "- " + ss0 }
|
||||
} else { "" }
|
||||
|
||||
let hp: Bool = !str_eq(profile_bullets, "")
|
||||
|
||||
Reference in New Issue
Block a user