Skip to content

fix: promptPack=lean actually reaches the proxy system prompt (kernel/packs) (#2335) - #2337

Merged
ranxianglei merged 4 commits into
masterfrom
2026-10-07_lean-pack-effective
Oct 8, 2026
Merged

ranxianglei merged 4 commits into
masterfrom
2026-10-07_lean-pack-effective

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

kernel-change: lean pack promptSections hoist — CompressPromptSections gains tri-state philosophy/howToCompress, builders stop hardcoding the two lead blocks (no-override output byte-identical, pinned by test). Fixes #2335 (proxy lanes assembling the full default system prompt under pack=lean). No wire-format change; acp-kernel npm pin untouched (vendored kernel/ tree in-repo).

Fixes #2335

Before (captured live, issue #2335)

  • compress.promptPack: "lean" only swapped tool descriptions; the assembled system prompt stayed the full default (10,876 chars), byte-identical to pack=default
  • The condensed lean contract ("Your summary is the ONLY record …") and the recall discipline ("Recall on demand only", "read that file") lived only in adapters.pi.promptSections — reachable only by billion-context-pi, never by the proxy lanes
  • Root cause: the kernel builders (buildCompressSystemPrompt/Text/Hybrid) hardcode [prompts.compressPhilosophy, prompts.howToCompressRules] and only honor 6 overridable sections; lean's content sat in a slot the builders never read

Change (kernel/ vendored tree, no proxy code changes needed)

  1. CompressPromptSections gains tri-state philosophy / howToCompress — the two lead blocks become per-call section entries inside the builders. No-override output stays byte-identical (pinned by test).
  2. leanPack.surface.promptSections hoisted to top level — the pi adapter keeps the exact same object via a shared const (LEAN_PROMPT_SECTIONS), so billion-context-pi behavior is unchanged; the proxy now gets the condensed contract + recall discipline in every lane.
  3. File-pack sanitize whitelist widened (COMPRESS_SECTION_KEYS + philosophy + howToCompress) so project/user packs can trim them too.

After (same live A/B harness as the issue)

pack system prompt content
lean (before) 10,876 chars default full text, lean contract absent
lean (after) 6,856 chars lean contract ✓ recall discipline ✓ file-pointer ✓ default philosophy gone
default (before) 10,876 chars —
default (after) 10,876 chars byte-identical to before (re-captured, == verified)

Tests

  • kernel: +3 (lean top-level sections drive all three builders; no-override byte-stability; file-pack trim round-trip) — kernel suite 1259/1259
  • bc: +1 (resolveCompressSurface({promptPack:"lean"}) → builder output carries contract+discipline; default unchanged) — pack family 14/14
  • typecheck ✓ (bc + kernel)

cc #2200 (recall discipline now delivered on the lean lane; the default-lane wording decision stays with that issue)

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-07_lean-pack-effective (f3c6178)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2554-pr.2337.9b463a4

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2337.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2337 review 完成(基于 rebase 到 fdbfb0e9b 的分支)。逐项:

1. 是什么问题
compress.promptPack: "lean" 只换了工具描述,注入的 system prompt 仍是完整默认文本(10,876 chars,与 pack=default 逐字节相同);lean 的精简契约("Your summary is the ONLY record…")和召回纪律("Recall on demand only" / "read that file")只存在于 adapters.pi.promptSections——只有 billion-context-pi 读得到,所有 proxy lane 都拿不到。

2. 什么原因导致的(两层,分层清楚)

  • 机制层:kernel 三个 builder(buildCompressSystemPrompt/Text/Hybrid)把 [prompts.compressPhilosophy, prompts.howToCompressRules] 硬编码在 section 列表之外,只有 6 个 section 可被覆盖——lean 的内容放在 builder 根本不读的槽位里;
  • 通道层:billion-context 的 resolver/注入路径从不读 surface.adapters,pi 专属槽位对 proxy 天然不可达。

3. 怎么修复的
把两个 lead block 变成与其余 section 同等的 tri-state section(builder 内默认文本仍取自传入的 prompts,无覆盖输出字节不变);lean 的 sections 提升到顶层 promptSections,与 pi adapter 共享同一个 const(LEAN_PROMPT_SECTIONS)——单一事实源,两通道永不漂移;file-pack sanitize 白名单(COMPRESS_SECTION_KEYS)同步加宽。方向与 issue #2335 的分析完全一致,修在机制源头而非症状层。

4. 是否有回归问题
审过的既有行为:

5. 是否破坏缓存
缓存键/去重/增量游标不受影响。注意一点预期内的变化:已在使用 lean 的会话,其注入 system prompt 字节会变(这正是本 PR 的目的)→ 下次请求一次性的 prefix-cache miss,之后恢复稳定;default lane 字节不变,绝大多数会话零影响。

6. 是否改了设计方向
没有转向:是把既有的 per-call section-override 机制扩展到原先硬编码的两个块,并延续「一个对象一个事实源」的 pi/proxy 双通道纪律。cc #2200 的分工不变:召回纪律现在随 lean lane 送达,default lane 的措辞决定仍归 #2200。

7. 是否引入了新的配置
无新 env/config/CLI 面。行为变更披露:promptPack: "lean" 现在真正改变所有 proxy lane 的 system prompt(10,876 → 6,856 chars,你的 live A/B 数字;我验证了构成要素:契约 ✓ 召回纪律 ✓ file-pointer ✓ 默认哲学消失 ✓);default pack 不变。

流程合规:PR body 首行有 kernel-change: 声明 ✓;kernel 版本 bump 最初缺失(kernel-guard CI 因此红),你在 review 期间已推 8f9faf9e3(0.0.105 → 0.0.106,独立 commit)✓;kernel 变更为人审档,owner 本人实现 ✓。

本地定向验证(全量留给 CI):root + kernel typecheck 干净;packs 家族 16/16(含新增回归测试);kernel packs 26/26。

判定:代码方向正确、机制层修复到位、发现的回归已修并有测试钉住;等 fdbfb0e9b 上 CI 全绿即可由你合并。

ranxianglei and others added 4 commits October 8, 2026 09:25
…#2335)

Before: leanPack.surface only swapped tool descriptions; every lane assembled
the full default 10.9KB system prompt (A/B capture: pack=lean vs default were
byte-identical) and the condensed contract + recall discipline lived only in
adapters.pi, unreachable by the proxy.

- CompressPromptSections gains tri-state philosophy/howToCompress; the three
  builders take them as per-call lead entries instead of hardcoding
  [prompts.compressPhilosophy, prompts.howToCompressRules]. No-override output
  stays byte-identical (pinned by test).
- leanPack: hoist the pi promptSections object to the TOP-LEVEL surface
  (shared const LEAN_PROMPT_SECTIONS, single source for both slots); pi adapter
  keeps the same reference — zero behavior change for billion-context-pi.
- file-pack sanitize whitelist (COMPRESS_SECTION_KEYS) widened to the two new
  keys so project packs can trim them too.

Live A/B after fix: lean system 6,856 chars (contract + recall discipline +
file-pointer rule delivered, default philosophy gone); default lane re-captured
byte-identical to pre-fix (10,876 chars).
…ompress (#2335)

#2335 made philosophy/howToCompress tri-state sections in the kernel
builders. buildAcpTagsOnlyPrompt still computed its slice prefix from the
hardcoded prompts.* values, so for any pack that replaces or drops those
lead blocks (lean nulls philosophy and swaps rules) the startsWith guard
failed and the whole ACP-TAGS NEVER-echo prompt silently vanished from the
injectTool=false lanes (#1881 protection lost). Compute the prefix from
the effective sections, mirroring applySectionOverrides semantics exactly.
@ranxianglei
ranxianglei force-pushed the 2026-10-07_lean-pack-effective branch from fdbfb0e to f3c6178 Compare October 8, 2026 01:27
@ranxianglei
ranxianglei merged commit 3fae4cf into master Oct 8, 2026
25 checks passed
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.136-master.3fae4cf (rolling master tag).

npm install -g billion-context@0.0.136-master.3fae4cf  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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.

promptPack=lean 在代理上只改工具描述:系统提示词静默保持 default — 精简契约/召回纪律从未投递(抓包实证)

1 participant