feat(recall): context-dedup improvements #51

Closed
will.anderson wants to merge 0 commits from improve/recall-context-dedup into main
Owner

Summary

Reduces redundant engram queries per chat turn by caching results across functions:

  • Issue 2: Cache bell node result in engram_compile state key engram_compile_bell_node so handle_chat affective_prefix reads the cached value instead of firing a second engram_search_json("bell distress...")
  • Issue 7: Cache primary activation result in engram_compile_activation_json so strengthen_chat_nodes reuses it instead of calling engram_activate_json(message, 2) a third time per turn
  • Issue 6: Replace str_slice(ctx, 0, 6000) mid-object truncation with backwards-scan for } boundary — prevents malformed trailing JSON objects in context

What changed

  • engram_compile(): adds state_set("engram_compile_bell_node", recent_bell) and state_set("engram_compile_activation_json", ...) after assembling context
  • handle_chat() affective_prefix: replaced live engram_search_json("bell distress...") with state_get("engram_compile_bell_node")
  • handle_chat() end: replaced engram_activate_json(message, 2) with state_get("engram_compile_activation_json")
  • Context cap: backwards-scan for } boundary replaces abrupt character slice
## Summary Reduces redundant engram queries per chat turn by caching results across functions: - **Issue 2**: Cache bell node result in `engram_compile` state key `engram_compile_bell_node` so `handle_chat` `affective_prefix` reads the cached value instead of firing a second `engram_search_json("bell distress...")` - **Issue 7**: Cache primary activation result in `engram_compile_activation_json` so `strengthen_chat_nodes` reuses it instead of calling `engram_activate_json(message, 2)` a third time per turn - **Issue 6**: Replace `str_slice(ctx, 0, 6000)` mid-object truncation with backwards-scan for `}` boundary — prevents malformed trailing JSON objects in context ## What changed - `engram_compile()`: adds `state_set("engram_compile_bell_node", recent_bell)` and `state_set("engram_compile_activation_json", ...)` after assembling context - `handle_chat()` `affective_prefix`: replaced live `engram_search_json("bell distress...")` with `state_get("engram_compile_bell_node")` - `handle_chat()` end: replaced `engram_activate_json(message, 2)` with `state_get("engram_compile_activation_json")` - Context cap: backwards-scan for `}` boundary replaces abrupt character slice
will.anderson added 2 commits 2026-06-22 18:16:32 +00:00
- Issue 2: replace raw 50-char threshold with is_genuine_continuation() that
  checks for explicit follow-up phrases and mid-sentence capitalization (proper
  nouns signal a new topic, not a continuation)
- Issue 3/8: build_activation_seed() scans back to find the prior USER turn as
  the topic anchor instead of using the last assistant reply (hist_len-1)
- Issue 4: engram_compile_multi() fans out across three seeds — enriched primary,
  raw message (entity queries), and emotion query — merging non-redundant results
- Issue 5: agent workspace_root appended to ag_seed so agentic activation is
  workspace-aware; previously ignored despite being available in state
- Issue 6: distill_transcript() extracts salient tail+question content from full
  transcripts before passing to engram_compile in dharma room handlers
- Issue 7: dist/soul-with-nlg.el handle_chat and handle_chat_agentic now load
  history and use build_activation_seed() — the raw message path is eliminated
- Issue 9: topic_snip_from_entry() takes the TAIL 200 chars of a long reply and
  finds the last sentence boundary — captures end-of-reply named concepts
- Issue 10: multi_turn_topic() pulls up to 3 prior user turns into the non-
  continuation seed so earlier thread context re-activates high-salience nodes
feat(recall): context-dedup improvements
Neuron Soul CI / build (pull_request) Has been cancelled
cbe8c09068
- Cache bell node in engram_compile state (engram_compile_bell_node)
  so handle_chat reads cached value instead of duplicate bell query (Issue 2)
- Cache activation result (engram_compile_activation_json) for strengthen_chat_nodes
  reuse — eliminates third activation query per turn (Issue 7)
- Fix context cap to truncate at clean JSON object boundary (Issue 6)
will.anderson closed this pull request 2026-06-22 18:31:23 +00:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: neuron-technologies/neuron#51