Repository navigation
Compaction: require verbatim preservation of paths, numbers, and proper nouns (patch + 293-round production evidence) #10303
Replies: 3 comments
|
Patch file (git am ready, against master @ 687f282 / v0.2.1-rc.2): From aff1cbbdc832b4df77bc629835fb51be1207a2b9 Mon Sep 17 00:00:00 2001
From: wjl14 <wjl14@users.noreply.github.com>
Date: Mon, 19 Oct 2026 10:41:03 +0800
Subject: [PATCH] feat(compaction): require verbatim preservation of paths,
numbers, and proper nouns in summaries
The default one-shot summarizer directive asks for terse bullets, which
models satisfy by paraphrasing away exact file paths, numeric values, and
identifier names - the facts a resumed session most often needs verbatim.
Add an explicit rule requiring those categories to be preserved verbatim
(paths with extensions, numbers/IDs/dates/token counts, proper nouns such
as script/function/command/key names), while leaving narrative content
free to compress.
The rule closes the loop with the prior-checkpoint instruction: values
superseded later in the conversation (replaced versions, renamed paths,
corrected figures) are dropped or replaced rather than carried forward,
so stale anchors do not accumulate across repeated compactions.
Validated in production replay and live sessions over two days; measured
results are summarized in the PR description. README.md/README.zh.md
fenced instruction blocks are synced, and a vitest case pins the new
rule text.
Co-Authored-By: Codex <codex@openai.com>
---
packages/compaction/compaction-basic/README.md | 1 +
packages/compaction/compaction-basic/README.zh.md | 1 +
.../compaction/compaction-basic/src/summarizer.ts | 1 +
.../compaction-basic/tests/compaction-basic.spec.ts | 13 +++++++++++++
4 files changed, 16 insertions(+)
diff --git a/packages/compaction/compaction-basic/README.md b/packages/compaction/compaction-basic/README.md
index fa4ae2fb48..86564917df 100644
--- a/packages/compaction/compaction-basic/README.md
+++ b/packages/compaction/compaction-basic/README.md
@@ -223,6 +223,7 @@ Rules:
- Do NOT mention this summarization request or that the context was compacted.
- Output only the checkpoint text: do not call any tool or take any other action.
- If the conversation already contains a <compacted-summary> block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts, drop stale ones, and merge newer information into a single consolidated summary under the same structure.
+- The following information must be preserved verbatim, never omitted, rewritten, or paraphrased: all file paths and filenames (including extensions), all specific numeric values (numbers, IDs, dates, token counts), all proper nouns (script names, function names, command names, key names). Other narrative content may be compressed. Every such item must appear verbatim in the output. Values superseded later in the conversation (replaced versions, renamed paths, corrected figures) follow the prior-checkpoint rule above: drop or replace them rather than carrying them forward.Token effectdiff --git a/packages/compaction/compaction-basic/README.zh.md b/packages/compaction/compaction-basic/README.zh.md
|
|
摘要里保留精确值,再给摘要附上原文入口,这两步可以配合。dsh-memory-plus 的 你这份补丁优先保留当前有效的路径、数字和专有名词;定位符则帮助在摘要省略细节后找到对应证据。联合回归可以检查三件事:当前值是否保留、被替换的旧值是否退出当前状态、遗漏内容是否仍能从原始记录找回。 定位符模块可作为对照实现,适合和这份补丁一起验证恢复路径。 |
|
感谢 QIANLING-0831 的补充。「摘要内保活值 + 摘要外留证据入口」的分层定位很清晰,与我们的逐字保真补丁确实互补。三点联合回归口径都认同,先指出一个已有交集:
联合回归共建非常欢迎:我们出原始会话样本和验证器,贵方出 locator 实现,两边按同一口径跑、结果互不背书但可对表。 另注:我们当前 reread 注入层因宿主进程的重启策略暂时旁路,P1 提示词补丁不受影响、仍在生效;locator 如需真机触发验证,我们的回归台架随时可用。 |
Uh oh!
There was an error while loading. Please reload this page.
正文
问题
默认一次性摘要指令要求 terse bullets,模型为求简会改写掉三类高价值事实的原文:精确文件路径(含扩展名)、具体数值(金额/ID/日期/token 数)、专有名词(脚本/函数/命令/键名)。被恢复的会话最常需要的就是这三类的逐字形态——路径错一个字符找不到文件,金额差一位追错 bug。
改动
COMPACTION_INSTRUCTION 末尾追加一条规则:三类信息逐字保留(禁省略/改写/转述),叙事内容自由压缩;并被限定句闭环到既有 prior-checkpoint 规则——会话后期被取代的值(换掉的版本、重命名路径、修正数字)按 stale-drop 规则丢弃或替换,不跨轮累积。
审查自问自答(预判 maintainer 问题)
pnpm vitest run packages/compaction/compaction-basic153/153 通过(rebase 后在新基线复跑,含上游新增 1 例);该包无 recorded-session 快照钉住指令文本,模型可见文本变化不改变任何既有快照(已实证)。测试
新增 vitest 用例断言指令含 4 个关键子串(均为新规则独有文本,与 62 行旧措辞不重叠,无假阳性)。
回滚
恢复 = revert 本 commit。生产环境留有补丁前 .bak(与上游编译产物逐字节一致),可随时还原。
All reactions