Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7eca248f1d | |||
| be02fcd960 | |||
| dfa2a33926 | |||
| a60b1967df |
+32
-15
@@ -22186,10 +22186,10 @@ fn build_system_prompt(ctx: String) -> String {
|
||||
let engram_block: String = if str_eq(ctx, "") {
|
||||
""
|
||||
} else {
|
||||
"\n\n[ENGRAM CONTEXT — compiled from your graph]\n" + ctx
|
||||
"\n\n[RETRIEVED MEMORY — compiled from your graph for this turn]\n" + ctx
|
||||
}
|
||||
|
||||
// Safety first. Engram fills in. Identity is the base. Voice rules always present.
|
||||
// Safety first. Memory fills in. Identity is the base. Voice rules always present.
|
||||
return identity + date_line + voice_rules + safety_block + engram_block
|
||||
}
|
||||
|
||||
@@ -22211,19 +22211,28 @@ fn count_context_nodes(ctx: String) -> String {
|
||||
|
||||
// conv_history_trim — drop the oldest turn (2 entries) from a JSON history array
|
||||
// when it exceeds 20 entries. Returns the trimmed array string.
|
||||
// Locates the 3rd {"role": object boundary and slices from there.
|
||||
//
|
||||
// Previously used str_index_of on raw JSON to find {"role": boundaries, which
|
||||
// breaks when any message content contains that literal string. Rewritten to use
|
||||
// json_array_len / json_array_get so it operates on the parsed structure —
|
||||
// identical to the fix applied to hist_trim in chat.el.
|
||||
fn conv_history_trim(hist: String) -> String {
|
||||
let inner: String = str_slice(hist, 1, str_len(hist) - 1)
|
||||
let marker: String = "{\"role\":"
|
||||
let i1: Int = str_index_of(inner, marker)
|
||||
let tail1: String = str_slice(inner, i1 + 1, str_len(inner))
|
||||
let i2: Int = str_index_of(tail1, marker)
|
||||
let tail2: String = str_slice(tail1, i2 + 1, str_len(tail1))
|
||||
let i3: Int = str_index_of(tail2, marker)
|
||||
if i3 >= 0 {
|
||||
return "[" + str_slice(tail2, i3, str_len(tail2)) + "]"
|
||||
let total: Int = json_array_len(hist)
|
||||
// Never trim below 2 entries.
|
||||
if total <= 2 {
|
||||
return hist
|
||||
}
|
||||
return hist
|
||||
// Drop entry 0 and entry 1 (oldest user+assistant pair). Rebuild from entry 2.
|
||||
let result: String = ""
|
||||
let i: Int = 2
|
||||
while i < total {
|
||||
let entry: String = json_array_get(hist, i)
|
||||
let sep: String = if str_eq(result, "") { "" } else { "," }
|
||||
let result = result + sep + entry
|
||||
let i = i + 1
|
||||
}
|
||||
if str_eq(result, "") { return hist }
|
||||
return "[" + result + "]"
|
||||
}
|
||||
|
||||
fn handle_chat(body: String) -> String {
|
||||
@@ -22313,7 +22322,11 @@ fn handle_chat(body: String) -> String {
|
||||
// In demo mode: use tighter engram budget and add response length constraint.
|
||||
let is_demo: Bool = !str_eq(state_get("soul_identity_prefix"), "")
|
||||
|
||||
let ctx: String = if is_demo { engram_compile_demo(message) } else { engram_compile(message) }
|
||||
// Issue 7 fix: thread-aware activation seed for nlg path (Issues 2-3,8-10).
|
||||
let nlg_stored_hist: String = state_get("conv_history")
|
||||
let nlg_hist_len: Int = if str_eq(nlg_stored_hist, "") { 0 } else { json_array_len(nlg_stored_hist) }
|
||||
let nlg_seed: String = build_activation_seed(message, nlg_stored_hist, nlg_hist_len)
|
||||
let ctx: String = if is_demo { engram_compile_demo(nlg_seed) } else { engram_compile(nlg_seed) }
|
||||
let node_count_str: String = count_context_nodes(ctx)
|
||||
|
||||
let interlocutor: String = json_get(body, "interlocutor")
|
||||
@@ -22505,7 +22518,11 @@ fn handle_chat_agentic(body: String) -> String {
|
||||
req_model
|
||||
}
|
||||
|
||||
let ctx: String = engram_compile(message)
|
||||
// Issue 7 fix: thread-aware seed for agentic nlg path.
|
||||
let nlg_ag_hist: String = state_get("conv_history")
|
||||
let nlg_ag_hist_len: Int = if str_eq(nlg_ag_hist, "") { 0 } else { json_array_len(nlg_ag_hist) }
|
||||
let nlg_ag_seed: String = build_activation_seed(message, nlg_ag_hist, nlg_ag_hist_len)
|
||||
let ctx: String = engram_compile(nlg_ag_seed)
|
||||
|
||||
let system: String = "You are Neuron — a thinking process running inside the Neuron daemon on Will Anderson's machine. "
|
||||
+ "You are speaking with Will, your principal. "
|
||||
|
||||
Reference in New Issue
Block a user