feat(prompts): add facet guard and length limits to memory_merge_bundle#533
Open
lishixiang0705 wants to merge 1 commit intovolcengine:mainfrom
Open
Conversation
- Add 'skip' decision: reject merging memories with different facets even if they share the same category, preventing semantic dilution - Add hard character limits: abstract ≤80, overview ≤200, content ≤300 - Change merge strategy from accumulate-all to condensed snapshot: conflicts resolved by keeping newer version only - Bump template version from 1.0.0 to 2.0.0 Motivation: without facet checking, the merge prompt would combine unrelated facts (e.g. 'Python code style' + 'food preferences') into a single bloated memory just because both were categorized as 'preferences'. Without length limits, merged memories grew unbounded (some exceeding 1000+ chars), causing embedding dilution and low retrieval precision in downstream vector search.
|
lishixiang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The current
memory_merge_bundle.yamltemplate has three issues that degrade memory quality over time:No facet coherence check — Two memories sharing the same category (e.g. both
preferences) are always merged, even when they describe completely unrelated topics (e.g. "Python code style" + "food preferences"). This produces bloated, semantically diluted memories.No length constraints — Merged content grows unbounded. In production, single memory items can exceed 1000+ characters, causing:
Accumulate-only strategy — The template instructs to "keep non-conflicting details", which means memories only grow, never condense. Old, superseded facts persist alongside new ones.
Solution
Upgrade template to v2.0.0 with three changes:
1. Facet guard (
decision: skip)Before merging, the LLM must verify both memories describe the same specific facet/topic. If they cover different facets, output
{"decision": "skip"}to keep them separate. Includes concrete examples for both cases.2. Hard character limits
abstract: ≤ 80 charactersoverview: ≤ 200 characterscontent: ≤ 300 charactersWhen limits would be exceeded, aggressively summarize — drop older details first, preserve specific values (names, numbers, versions) over narrative.
3. Condensed snapshot strategy
Replace "keep non-conflicting details" with:
Breaking Changes
decisionfield now accepts"skip"in addition to"merge". Callers that parse the merge output must handle this new value.Testing
Tested in production with ~2800 vectors and ~76 leaf memory files. The facet guard correctly prevents cross-topic merges, and length limits keep individual memories within embedding-friendly bounds.