perf(memory): bound the prefix memory index with a recency budget - #8144
Open
chuiwenwei wants to merge 1 commit into
Open
perf(memory): bound the prefix memory index with a recency budget#8144chuiwenwei wants to merge 1 commit into
chuiwenwei wants to merge 1 commit into
Conversation
chuiwenwei
force-pushed
the
perf/index-prefix-budget
branch
2 times, most recently
from
August 10, 2026 10:12
3b5ddfe to
7e02c2a
Compare
The MEMORY.md index folds into the cache-stable system-prompt prefix at boot, so its size is a per-turn token cost that grows without bound as facts accumulate: stale facts never leave, and the only removal path is a manual `forget`. - IndexBounded renders the prefix projection: stale facts (per memoryFreshness) fold into a summary line, the rest order by recency (most recently updated first) and cap to a soft 1200-char budget, always keeping at least one line. A fold line tells the model more memories exist and are reachable via the memory tool. - The on-disk MEMORY.md stays complete; only the prefix-facing projection is capped (Set.Load now uses IndexBounded). - Rendering is a deterministic function of the memory set, so the prefix stays byte-stable within a session (cache-first invariant preserved). Standing instructions and recall behavior are untouched. Measured ~280 tokens/round on a 10-fact store, with the gain scaling as memories accumulate.
chuiwenwei
force-pushed
the
perf/index-prefix-budget
branch
from
August 11, 2026 12:28
7e02c2a to
c43feb5
Compare
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.
Summary
Issues
(可留空)
Verification
Documentation impact
Documentation-impact: none - 不改记忆模型、命令或配置;索引投影是内部渲染规则,MEMORY.md 的语义描述不变。
Cache impact
Cache-impact: low - 索引投影是 (记忆集, now) 的确定性函数、启动时快照,会话内前缀字节稳定(与现状同一规则);仅投影规则变化(一次性),standing instructions 与 recall 未动。
Cache-guard: 聚焦 guard—— go test ./internal/boot -run TestGoldenBaseline (前缀基线)+ TestIndexBoundedDeterministic (字节稳定)+ 既有 memory 测试;scripts/cache-guard.sh 为 release 级缓存命中检查(本次未跑,改动不触 provider 请求序列化)。
System-prompt-review: esengine — 模型可见的索引列表可能缩减(折叠行保留可发现性,memory 工具仍是检索路径);需维护者确认后合并。