Skip to content

fix: default prompt falsely claimed compress renumbers refs (#541) - #543

Merged
ranxianglei merged 2 commits into
masterfrom
2026-09-25_prompt-ref-stability
Sep 25, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-09-25_prompt-ref-stability

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #541

What

The default summariesInContext prompt section told the model:

Every successful compress renumbers the remaining refs — refs recorded before that compress are stale.

That contradicts the kernel contract. Verified against acp-kernel@0.0.86 (pinned):

  • assignRefs (src/refs.ts, dist:61-77) copies options.existing.byRaw/byRef and skips already-mapped messages (if (map.byRaw[message.id]) continue;) — surviving refs keep their numbers across compress.
  • New refs are appended after highestUsedIndex + 1 (dist:4549-4550) — monotonic, never recycled.
  • This adapter's pruneOrphanRefs (src/runtime.ts:329-342) even keeps refs of block-covered messages resolvable via block.directMessageIds/effectiveMessageIds — so "refs recorded before that compress are stale" is false for both surviving and compressed-range refs.

Change

  • src/system-prompt.ts (summariesInContext bullet): replaced with "Message refs remain stable across compression within the same session state." The failure-handling rules (verify via acp_status, never guess offsets arithmetically, batch ranges in one call) are kept verbatim. The "same session state" qualifier excludes fork/derive/log-replay rebuilds where ref space is legitimately re-derived.
  • tests/fixtures/pi-system-prompt-default.txt: snapshot updated in lockstep; tests/surface-config.test.ts pins the prompt to this fixture byte-for-byte, which now encodes the corrected sentence as the regression anchor.
  • Second commit (labeled separately, comment-only, zero behavior change): src/runtime.ts clearDeadCompress docstring repeated the same false claim ("a successful compress renumbers refs so old fingerprints are meaningless"); corrected to state the real rationale (loop-breaker reset on progress).

Behavior change disclosure (per owner policy)

Model-facing surface change, intended by the fix:

  • Old: every successful compress → prompt claims all previously recorded refs are stale/renumbered → models tend to re-query acp_status after each compress.
  • New: prompt states refs remain stable within the same session state; unresolvable-ref handling unchanged (still: run acp_status, no arithmetic offset guessing).
    No runtime code path changed; dead-range validity checks and double-compress rejection are untouched (ref stability does not make an already-compressed range recompressible).

Verification

  • npm run typecheck green; npm run build green.
  • Snapshot test default system prompt is byte-identical to the recorded fixture passes with the new text.
  • Full suite: 94 failures in BOTH clean master and this branch in this sandbox (environment-bound: read-only /tmp, no pi host) — failure sets diff byte-identical, i.e. this change introduces zero new failures.

Scope note

Same false wording also exists in acp-kernel's lean prompt pack ("Refs may be renumbered after compression. …") — filed separately against acp-kernel per cross-repo policy.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Extension Artifact

Branch: 2026-09-25_prompt-ref-stability (72b57d9)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-543

Each push to this PR publishes a new version under the pr-543 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr543.tgz
pi install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 结论:方向正确、改动最小、验证充分,可以合并(合并操作留给人)。

① 原 issue(#541)— 独立复核通过

  • 旧句确实存在(src/system-prompt.ts:31,master fd8095e),且与内核行为矛盾。我对已安装 acp-kernel@0.0.86(pinned)逐行复核:assignRefs(dist:61-77)先复制 options.existing.byRaw/byRef,再对已映射消息 if (map.byRaw[message.id]) continue; 跳过——存活 ref 跨压缩保持编号;nextIndex: highestUsedIndex(...) + 1(dist:4549-4550)单调追加、永不回收。与 AGENTS.md「Kernel Contract: Message Ids Are Never Reused」一致。
  • 补充佐证:本仓库 pruneOrphanRefs(src/runtime.ts:329-342)经 block.directMessageIds/effectiveMessageIds 保留被压块覆盖消息的 ref 可解析——旧句对存活和被压两侧都失实。修的是根因(提示词文本本身写错),不是症状。
  • 新句的 "same session state" 限定词正确排除了 fork/derive/log-replay 重建(ref 空间合法重推导)场景。

② 回归审查 — 触碰路径的既有行为逐项判定

触碰面 既有行为 结论
src/system-prompt.ts summariesInContext bullet 默认系统提示词文本 有意变更(本修复本身,diff 确认仅首句替换,失败处理规则 acp_status 核对/禁止算术偏移/批量提交逐字保留)
tests/fixtures/pi-system-prompt-default.txt 字节级快照锚点 同步更新;snapshot 测试现钉死修正句,作为回归锚点
src/runtime.ts clearDeadCompress docstring 注释 comment-only,零行为变化;新文案与两个调用点吻合(src/compress-tool.ts:532 成功压缩=progress→重置 #250 loop breaker;src/index.ts:347 session_shutdown 内存卫生)
ref-tag 渲染 / token 校准 / host detection / .acp.json sidecar / update.ts / kernel pin 未触碰 无影响
双压缩拒绝 / dead-range 有效性检查 compress-tool.ts 逻辑未动 不受影响(ref 稳定 ≠ 已压范围可再压;compress-tool.ts:367 的拒绝文案与新表述自洽)

唯一附带效应(一次性):默认提示词文本变化后,升级后使用默认 prompt 的会话首轮 provider 前缀缓存失效一次——任何 prompt 文本修复的固有代价,可忽略。

③④⑤ 代码 / 测试 / diff

CI 与本地验证(head fd79f4b)

  • CI 全绿:test(ubuntu/windows × node 22/24)、e2e、pr-validation、build-artifact、docker 全部 success。
  • 本地复跑:typecheck 绿、build 绿、surface-config.test.ts 10/10 过;全套测试分支与 clean master 各 838 pass / 94 fail,失败清单逐字节一致(diff 为空)——零新增失败,PR 声明属实。

跨仓库跟进

同款错误文案在 acp-kernel lean pack(0.0.86 dist:5415)已按规范另立 acp-kernel#417(open,带来源标记);CONFIGURATION.md:890 的 "renumbering recovery" 描述待该 issue 落地后同步,不在本 PR 范围。

📌 中文摘要:PR #543 修正了默认系统提示词中"每次压缩都会重新编号 ref"的错误论断(内核 assignRefs 实际保留已有映射、编号单调追加),替换为 ref 稳定性表述并同步快照 fixture,另以独立 commit 修正了 runtime.ts 中重复同一谬误的注释;已独立复核内核行为、逐项回归审查、本地验证零新增失败且 CI 全绿,可以合并。

ework-agent added 2 commits September 25, 2026 22:33
The summariesInContext section told the model "Every successful compress
renumbers the remaining refs — refs recorded before that compress are
stale." The kernel does not renumber: assignRefs copies existing.byRaw/
byRef and skips already-mapped messages (acp-kernel src/refs.ts), new
refs are appended after highestUsedIndex, and pruneOrphanRefs keeps
refs of block-covered messages resolvable. The claim contradicts the
kernel contract (ids/refs never reused) and pushed models toward
redundant acp_status lookups after every compress.

Replace with "Message refs remain stable across compression within the
same session state.", keeping the failure-handling rules (verify via
acp_status, no arithmetic offset guessing). Update the byte-identical
snapshot fixture in lockstep (tests/surface-config.test.ts pins it).

Fixes #541
…omment

Same misconception as #541 in a code comment: "a successful compress
renumbers refs so old fingerprints are meaningless". assignRefs keeps
existing mappings; the loop breaker resets because a successful
compress is progress, not because refs moved. Comment-only, no
behavior change.
@ranxianglei
ranxianglei force-pushed the 2026-09-25_prompt-ref-stability branch from fd79f4b to 72b57d9 Compare September 25, 2026 14:34
@ranxianglei
ranxianglei merged commit 4393e71 into master Sep 25, 2026
9 checks passed
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.

默认提示词错误地声称压缩后消息引用会重新编号

1 participant