Skip to content

feat(memory): preserve verbatim content the user explicitly asked to …#9

Merged
im4codes merged 1 commit intomasterfrom
dev
Apr 21, 2026
Merged

feat(memory): preserve verbatim content the user explicitly asked to …#9
im4codes merged 1 commit intomasterfrom
dev

Conversation

@im4codes
Copy link
Copy Markdown
Owner

…remember

The memory compression path summarises conversation events and can therefore drop exact user text — names, numbers, sentences the user flagged with an explicit "remember this" imperative were getting paraphrased or summarised into generic bullets in ## Key Decisions, then losing specificity further on each update cycle. Result: durable memory was missing content the user explicitly asked to preserve.

This is handled entirely in prompts — no language-specific keyword table, no regex gate. The compressor LLM already reads the user's messages; we just tell it to recognise the INTENT (cross-language: 记住/记得/记下/牢记, remember/keep in mind/note this, 覚えて, 기억해줘, recuerda, запомни, etc.) and route that content into a dedicated section.

  • summary-compressor.ts buildCompressionPrompt: new ## User-Pinned Notes section in the structured template. Both the fresh-compression branch and the update-existing-summary branch carry an explicit VERBATIM PRESERVATION RULE telling the LLM: copy pinned content word-for-word, never paraphrase, translate, or truncate; carry it forward unchanged across every update.

  • materialization-coordinator.ts extractDurableSignalsFromSummary: refactored to use a shared extractSummarySection helper (escaped-title regex) so any section can be pulled out. Now also scans ## User-Pinned Notes and pushes each non-empty line into the preferences bucket of DurableSignals. Effect: pinned content is automatically promoted to durable_memory_candidate instead of living only in the short-lived recent_summary, where it could eventually age out on rotation.

Existing summary-compressor + materialization tests remain green (25/25). The compressor tests don't assert on prompt text, so the change ships without touching test expectations.

…remember

The memory compression path summarises conversation events and can therefore
drop exact user text — names, numbers, sentences the user flagged with an
explicit "remember this" imperative were getting paraphrased or summarised
into generic bullets in `## Key Decisions`, then losing specificity further
on each update cycle. Result: durable memory was missing content the user
explicitly asked to preserve.

This is handled entirely in prompts — no language-specific keyword table,
no regex gate. The compressor LLM already reads the user's messages; we
just tell it to recognise the INTENT (cross-language: 记住/记得/记下/牢记,
remember/keep in mind/note this, 覚えて, 기억해줘, recuerda, запомни, etc.)
and route that content into a dedicated section.

- `summary-compressor.ts buildCompressionPrompt`: new `## User-Pinned Notes`
  section in the structured template. Both the fresh-compression branch and
  the update-existing-summary branch carry an explicit VERBATIM PRESERVATION
  RULE telling the LLM: copy pinned content word-for-word, never paraphrase,
  translate, or truncate; carry it forward unchanged across every update.

- `materialization-coordinator.ts extractDurableSignalsFromSummary`:
  refactored to use a shared `extractSummarySection` helper (escaped-title
  regex) so any section can be pulled out. Now also scans
  `## User-Pinned Notes` and pushes each non-empty line into the
  `preferences` bucket of DurableSignals. Effect: pinned content is
  automatically promoted to `durable_memory_candidate` instead of living
  only in the short-lived recent_summary, where it could eventually age
  out on rotation.

Existing summary-compressor + materialization tests remain green (25/25).
The compressor tests don't assert on prompt text, so the change ships
without touching test expectations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@im4codes im4codes merged commit 405c227 into master Apr 21, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant