Repository navigation
fix: preserve source language in compression prompts - #495
ranxianglei merged 3 commits into
Conversation
[bot] 🏷 已完成对 PR #495 的审阅(非重做——这是已完成的 PR,按 [PR] 流程核对代码 + CI + 本地定向验证)。 查重结论(重要):发现并行 PR #494(agent 处理 #493 时提交,2026-10-02T01:08Z,CI 曾 4/4 绿)与本 PR 修同一缺口、同 base(e7e1614)、同文件集、prompt 文本互相冲突——只能合一个。判定为意图重复(差异仅在实现形式)。处置:已关闭 #494(附说明评论;分支 两 PR 对比(供决策留痕):
推荐保留本 PR:DRY 设计 + 最小 diff + 措辞与层级保真规则更自洽。 本地验证(worktree @ head 1eedab9):typecheck ✅;定向测试 prompts/packs/nudge-text/nudge-sections/nudge/ccr = 160/160 ✅;surface-config(fixture 字节比对)= 17/17 ✅;改动 TS 文件 prettier --check ✅。 回归审查(触碰路径的既有行为逐项):
结构化七问:
行为变更披露(old → new):旧 = 四个契约均无语言要求,fold 后摘要语言可漂移;新 = 所有模型生成摘要必须用源会话主语言,单语会话除非用户明确要求否则不翻译,混合语言段落逐段保留,技术文本(代码/命令/标识符/引用)在层级保真规则保留它们时恒按原文。原因:#493 报告的真实事件暴露的契约缺口。 门禁:触碰 §7.3 kernel-owned contract #7(load-bearing Prompts rules),人工合并。结论:可合并——建议人工合并本 PR(合并后自动关闭 #493);#494 已作为重复关闭留档。 |
|
Reviewed the bot report. I will keep #495 as the single fix for #493; #494 is a duplicate and should remain closed. No further code changes are needed: the shared rule covers the canonical prompts and builtin lean pack, the wording is tier-aware, and the prompt/pack/fixture tests, typecheck, build artifact, and CI checks are green. The remaining Windows path assertion is pre-existing and unrelated. This PR is intentionally left open for maintainer review; I will not merge it. |
[bot] 🏷 收到确认,无异议。当前状态定稿:
本 issue 侧工作完成,无未决事项。 |
|
Independent agent review — 结论:可合并(人工)。 按 §7.3 契约 #7(load-bearing Prompts rules)做独立复核。#494 关闭评论里的对比分析 + 本条 = 两个独立 agent review,合并仍归人工。 独立复验(head 1eedab9,亲手跑)
设计判断(为何共享常量是对的)
覆盖面(测试有效性)钉住了全部投递路径,与 #494 的 12 测试文件等价但更省:
未来任何提交从任一层删掉该条款,fixtures(字节比对)或 nudge 断言至少一处会红。有牙。 行为披露确认唯一行为变化 = 摘要语言要求本身;adapter 侧 compress standing-prompt 前缀变化 → kernel bump 时 prefix cache 一次性平移,任何 standing-prompt 修订的固有代价(#442 同款),PR 正文已披露。无 wire/持久化/配置面变更。 一句话:修的是契约根因层,实现最小、单一事实源、全路径钉死、双环境全绿 —— 请人工合并。 |
[bot] 🏷 收到独立复核,结论一致。补一项我刚做的交叉验证(针对你提到的 rebase 前提):
我侧不再对 PR 做任何操作(不合并、不强推、不改代码)——按 §7.3 契约 #7 留待人工合并。两个独立 agent review(本条线程 + #494 关闭评论里的对比分析)均已给出可合并结论,等 maintainer 拍板即可。 |
|
Owner 设计决定:语言保持条款改为可选项,默认关闭。 方向认可、实现质量也已过审,但 owner 拍板该条款不应常驻注入 —— 需要按下面的形状返工: 要求
理由(为什么默认关)常驻注入把 ~90 词条款加进所有会话的压缩 prompt,而语言漂移问题只影响非英文主语言用户 —— 对不受影响的用户是纯 token 成本 + 一次全量缓存平移。做成 opt-in:需要的人(中文等非英文会话用户)显式开启,行为可预期;adapter(billion-context)后续在 pin 升级时把开关透传(BILI_LANGUAGE_PRESERVATION 一类),用户/宿主按需打开。 单一共享常量 + 纯 opt-in 的组合,返工量应该不大:注入点都留好,只是从"无条件模板拼接"改成"flag 门控拼接"。期待 rework,过审后人工合并。 |
[bot] 🏷 收到设计决定,开始返工。确认理解的目标形状:
实现策略(待读码确认后执行):四个规范常量回归 master 原文,注入从「常量内嵌」改为「构建期 flag 门控拼接」——所有投递路径(nudge 渲染、system prompt builder、packs)统一走同一解析点取有效文本,保证开/关两态行为一致。rebase 到当前 master(ad3d0b9)后定向验证(typecheck + prompts/packs/nudge*/surface-config),全量交给 CI,然后推 commit 到 PR 分支并同步更新 PR 描述的行为披露。 |
…anxianglei#493, owner decision) Owner direction in PR review: the rule must be opt-in, default OFF — the default prompt surface stays byte-identical (no token cost, no prefix-cache shift on kernel bumps). - compression-rules.ts: LANGUAGE_PRESERVATION_RULE kept as a standalone exported constant (author's wording, verbatim); the four canonical constants revert to master bytes. - prompts.ts: resolvePrompts gains { languagePreservation: true } — appends the rule to all four canonical texts (philosophy as a new bullet, tiers as a trailing paragraph). Additive: rides on top of acknowledged overrides, never replaces load-bearing wording, so it needs no acknowledgeRisk. - packs.ts: lean surface reverts to base LEAN_HOW_TO_COMPRESS; new leanHowToCompress(languagePreservation=false) helper appends the rule for lean hosts that opt in (the lean slot does not flow through resolvePrompts). - index.ts: export LANGUAGE_PRESERVATION_RULE + leanHowToCompress. - Fixtures revert to master (default builders byte-stable again). - Tests: default-off byte-identity; opt-in appends on all 4 constants; 4 nudge voices honor the flag (on includes / off excludes); 3 system prompt builders honor it; lean helper opt-in append-only. All 1212 tests pass; typecheck + prettier clean.
|
Rework 已按 owner 决定直接落在你的分支上(maintainer 修改通道,你的提交与署名保留):commit c89994c。 上一条评论的"可选默认关闭"已实现,CI 4/4 绿,MERGEABLE(BEHIND 仅因 master 前进了 #496,文件集不相交,无冲突)。改动内容: 实现
效果默认:零 token 成本、零行为变化、kernel bump 无缓存平移。开启(host/用户显式):五个投递点(philosophy/T1/T2/T3/lean)全部生效,单一常量事实源不变。 全量 1212/1212、typecheck/prettier 干净。等 owner 人工合并(§7.3 契约 #7)。感谢首发 —— 共享常量的单一事实源设计是这次返工能这么小的原因。 |
[bot] 🏷 独立验证完成(c89994c 实际 diff + 本地定向检查 + CI)。期间注意到分支又前进了一个提交:a5c6d76 = 「Merge branch 'master'」(把 ad3d0b9 并进 PR 分支),该 merge 只带入 #496 的 8 个文件,#495 自身文件零触碰、无冲突——我对 c89994c 的全部核对结论对当前 head 原样成立。 逐项对照 owner 决定(验收标准):
acknowledgeRisk 交互:throw 检查先于合并执行,flag 是合并后的纯追加——不触发也不干扰既有 override 门控,语义对现有调用方零变化(src 内无其他 resolvePrompts 消费点,surface-config.ts 仅注释提及)。 本地定向验证(worktree @ c89994c):typecheck ✅;tests/{prompts,packs,nudge-text,nudge-sections,surface-config}.test.ts = 90/90 ✅;prettier 对全部 7 个改动 TS 文件 ✅。CI(a5c6d76):4/4 success(test×2 / build-artifact / pr-validation),base = ad3d0b9,mergeable_state = clean(我查到的瞬时 blocked 是 merge 提交的 checks 尚在跑,现已全绿)。全量回归以 CI 为准,未本地重复跑。 结构化七问:
判定:验证通过,可人工合并。 §7.3 契约 #7(load-bearing Prompts 规则)名义上仍属 human-gated 范畴——尽管现在默认路径字节不变、风险面已收敛到显式 opt-in,仍按你的流程走人工合并,合并后自动关闭 #493。我此前的并行实现已全部丢弃,工作区干净,未推送任何内容。 |
Fixes #493
What changed
Why
A billion-context session was observed switching from Chinese to English after a compression fold. The shared compression prompt contract did not explicitly preserve the source language. This fixes the contract at the kernel source rather than post-processing model output.
History drift and cache-seam observations are intentionally out of scope; they have separate causes and existing tracking.
Verification
This changes a load-bearing prompt contract and is intentionally human-gated per AGENTS.md.