diff --git a/chat.el b/chat.el index 8d7d2c6..ea6b0da 100644 --- a/chat.el +++ b/chat.el @@ -786,7 +786,8 @@ fn handle_chat(body: String) -> String { } } - let ctx: String = engram_compile(activation_seed) + // Issue 4 fix: engram_compile_multi adds entity + emotion fan-out seeds + let ctx: String = engram_compile_multi(activation_seed, message) let system: String = affective_prefix + build_system_prompt(ctx) // Issue 9 fix: add project-specific and session-summary searches to session preload. diff --git a/dist/soul-with-nlg.el b/dist/soul-with-nlg.el index 7655273..8e002cc 100644 --- a/dist/soul-with-nlg.el +++ b/dist/soul-with-nlg.el @@ -22313,7 +22313,23 @@ 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: load history BEFORE building the activation seed so we can + // apply the continuation guard that chat.el uses. The nlg code path previously + // called engram_compile(message) with no thread enrichment at all. + let stored_hist: String = state_get("conv_history") + let hist_len: Int = if str_eq(stored_hist, "") { 0 } else { json_array_len(stored_hist) } + let history_section: String = if hist_len > 0 { + "\n\n[RECENT CONVERSATION — last " + int_to_str(hist_len) + " turns]\n" + stored_hist + } else { + "" + } + + // Issue 7 fix: build enriched seed using build_activation_seed() — adds + // smart continuation detection, prior-user-topic anchoring, multi-turn context, + // and tail-biased snipping (Issues 2-3, 8-10). For demo mode, still use + // engram_compile_demo but with the enriched seed. + let nlg_seed: String = build_activation_seed(message, stored_hist, 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") @@ -22333,18 +22349,6 @@ fn handle_chat(body: String) -> String { let presence_line = "\n\n[ambient: I see " + interlocutor_name + rel_suffix + " on the camera right now. Address them naturally. Do not describe what they look like or narrate the picture unless asked.]" } - // Conversation history — soul-owned, persisted in process state across turns. - // Format stored in state: JSON array of {"role":"user"|"assistant","content":"..."} objects. - // We load it, inject into the system prompt, then append this exchange after the reply. - // Keep last 20 entries (10 turns) — truncate from the front when over limit. - let stored_hist: String = state_get("conv_history") - let hist_len: Int = if str_eq(stored_hist, "") { 0 } else { json_array_len(stored_hist) } - let history_section: String = if hist_len > 0 { - "\n\n[RECENT CONVERSATION — last " + int_to_str(hist_len) + " turns]\n" + stored_hist - } else { - "" - } - // Demo constraint: keep responses concise — under 150 words. No markdown headers. // This keeps inference cheap and responses readable in the chat widget. let demo_constraint: String = if is_demo { @@ -22505,7 +22509,12 @@ fn handle_chat_agentic(body: String) -> String { req_model } - let ctx: String = engram_compile(message) + // Issue 7 fix: load history and use build_activation_seed() for the agentic + // nlg path — no continuation guard existed here before (Issues 2-3, 8-10). + 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. "