Repository navigation
feat: trim prompt surfaces ~21% + lean prompt pack (compress.promptPack) - #453
ranxianglei wants to merge 8 commits into
Conversation
4292e07 to
7ffd651
Compare
📦 Built Plugin ArtifactBranch: Option A — Install from npm PR tag (recommended)opencode plugin opencode-acp@pr-453 --globalEach push to this PR publishes a new version under the Option B — Install from GitHubopencode plugin "github:ranxianglei/opencode-acp#2026-09-24_prompt-trim-lean-pack" --globalOption C — Download artifact
tar xzf opencode-acp-pr453.tgz
cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist
This comment is automatically updated on each push. |
…se 1) Condense system prompt, 5 tool descriptions and nudge templates toward the density used by billion-context-pi's default surface. Load-bearing content (HOW_TO_COMPRESS_RULES from context-compress-algorithms, ID rules, KEEP/REF marker docs, candidate-mode variants, internal dcp tags) is preserved verbatim. Standing prompt surface (Anthropic tokenizer): 9004 -> 7143 tokens (-20.7%). Per surface: system(ranges) 3055->2612, compress tool desc 1063->764, decompress 452->227, search 101->56, acp_status 184->98, recap 83->59. Also fixes a latent bug: three nudge templates had the dcp-message-id tag name stripped from their ID-rule lines (committed as 'use IDs you can see in tags'); restored the explicit tag name so the rule is actually readable.
Adds opt-in 'lean' prompt surface pack (billion-context-pi style):
- lib/prompts/packs.ts: pack builders + DEFAULT_* description constants
moved verbatim from tool files; LEAN_* texts adapted from acp-kernel (MIT)
- PromptStore takes promptPack; RuntimePrompts carries the four standing
tool descriptions; factories read them from the store at creation time
- config: compress.promptPack ('default'|'lean', global scope, validated,
declared in dcp.schema.json); default behavior byte-identical
- tests/prompt-packs.test.ts (16 tests): sizes, load-bearing fragments,
candidates toggle, validation, merge, store incl. override-beats-lean
- devlog entry REQ/WORKLOG/DESIGN
Master's new E2E suites (PR #448/#449) build tool factories with a minimal {reload(){}} prompts mock; since promptPack landed, factories also call getRuntimePrompts() at creation time. Give both files the same makeDefaultPromptsMock() helper used by the four pre-existing factory test files so they run against the shipped default-pack descriptions.
7ffd651 to
6870ee9
Compare
[bot] 🏷 收到,开始 review PR #453(分支 初步状态:
结论稍后在本楼更新。 |
[bot] 🏷 ## Review 结论:PR #453(分支 总体:主体工作(trim + lean pack)扎实、方向正确、回归有防护,可以合并;发现 1 个需要处理的问题(F1,关于本 PR 披露的 nudge tag 修复在运行时不生效)。CI 全绿(pr-validation / test 22+24 / build / e2e / build-artifact,mergeable_state=clean),本地复核:typecheck 干净、 ① 原 issue 方向(#452)功能类两阶段需求。方案已于 #452 floor 3/4 公示(bcp 的 lean 本质是 acp-kernel 的 prompt pack 机制;只削 surface、不降级 4 条 load-bearing 规则),实现与公示方案一致。病因定位准确:冗余常驻 surface(~9004 tok)+ 缺少可选紧凑 surface,两者都在源头解决,不是治标。✅ ② 回归审查(逐项既有行为清点)
③ 代码审查 —— F1:nudge tag 名修复运行时不生效(建议合并前处理)证据链:
影响:披露第 2 条("Nudges now name the actual message-ID tag")从第二个 pass 起不成立。实际危害中等偏低(系统提示词里的同名引用不受影响——系统提示不走 stripHallucinations,模型仍有正确参照),但按现状合并会让这条披露变成不实描述。 最小修复建议(3 行,不动剥离逻辑):三处 nudge 的行改为不带尖括号的写法,如 ④ 测试有效性16 个新测试断言有牙:尺寸护栏(<80%,双模式)、承重片段钉住(含 INTEGRITY/PENDING 反虚构条款)、candidates 双向开关、真实文件 fixture 的优先级集成(override > lean > bundled)、enum+unknown-key 校验、mergeCompress 稀疏/undefined 用例。6 个既有测试文件的 mock 适配是机械替换(pin default pack),无断言弱化。作者声明的 2 个失败与本沙箱 ⑤ diff 整洁度26 文件全部与本 PR 目的相关;describe() 调用的 prettier 重排发生在本就触碰的文件内;无锁文件/版本/无关文件混入;devlog REQ/WORKLOG/DESIGN 齐全,DESIGN.md 质量高(global-only 理由、RANGE_FORMAT_EXTENSION 共享理由、备选方案、风险表俱全)。 处置建议推荐:(a) 我直接在 PR 分支上补一个 3 行的 commit 修掉 F1(改措辞避开尖括号),然后即可合并;或 (b) 现在合并,F1 作为后续跟进。我的倾向是 (a)——这三行正是本 PR 声称修复的对象,以已知失效的形式合入不合适。等你一句话,说改我就改。 中文摘要:审完 PR #453(提示词削减 20.7% + 新增 lean 提示词包),方向正确、代码/测试/diff 均合格,唯一问题是 nudge 里修复的标签名会在第二轮之后被 |
In-pass fix flagged by PR #453 code review: hardcoded /tmp path made this E2E fail in any environment where /tmp is not writable (e.g. sandboxed CI with read-only /tmp). The toFile validator already accepts os.tmpdir().
Closes #452
TL;DR (中文)
两阶段完成:阶段1 削减默认提示词冗余(standing surface 9004→7143 tokens,-20.7%,load-bearing 契约逐字保留);阶段2 新增
compress.promptPack: "default" | "lean"配置,提供对齐 billion-context-pi 的 lean 模式(系统提示词 -57%,工具描述一行化)。默认包除阶段1削减外运行时行为字节级不变。Phase 1 — default surface trim (-20.7%)
Per-surface before → after (Anthropic tokenizer):
Removed: duplicated boundary-ID rules, duplicated batching prose, JSON examples repeated between nudges and tool descriptions, restatements. Kept verbatim: all load-bearing rules (ID resolution, KEEP/REF marker docs, protected-tool semantics, candidate-mode variants, internal
dcpXML tags); HOW_TO_COMPRESS_RULES (shared package) untouched.Latent bug fixed in passing: the TOOLS section said "five" tools but listed four — added the missing
acp_context_recapbullet.Bug fix (disclosed): three nudge templates (
lib/prompts/context-limit-nudge.ts,turn-nudge.ts,iteration-nudge.ts) had the literal message-ID tag text stripped from their ID-rule lines on master (verified via git blob hex dump — lines read as "use IDs you can see in tags" with a double-space gap). Restored the explicit tag name so the instruction references the actual tag.Phase 2 — lean prompt pack (opt-in)
New config:
"compress": { "promptPack": "lean" }(default"default", global scope, enum-validated, declared indcp.schema.json).lib/prompts/packs.ts: pack builders; DEFAULT_* description constants moved verbatim out of the four tool files (single source of truth); LEAN_* texts adapted from acp-kernel (MIT, same author — provenance noted in-file).PromptStoretakes the pack; tool factories now read their descriptions from the store at creation time (pack-aware, zero hot-path cost).Design rationale:
devlog/2026-09-24_prompt-trim-lean-pack/DESIGN.md(incl. why global-only scoping, why RANGE_FORMAT_EXTENSION is shared, alternatives considered).Behavior changes (old → new, per AGENTS.md disclosure rule)
compress.promptPack; with"default"(the default) phase 2 changes nothing at runtime (regression-guarded by byte-equality test).Tests
npm run typecheckpasses; touched files prettier-clean.tests/prompt-packs.test.ts: 16/16 (pack ids, lean<default sizes, load-bearing fragment presence, candidates toggle, lean/default tool-desc pairs, default byte-stability, validation unknown-key+enum, mergeCompress propagation, PromptStore integration incl. override-beats-lean)./tmpread-only) and pre-exist this change:tests/soft-block.test.ts(mkdirSync('/tmp/opencode-dcp-dangerous-*')EACCES at module load) and one decompress-toFile E2E test using a/tmppath.Devlog
devlog/2026-09-24_prompt-trim-lean-pack/{REQ.md,WORKLOG.md,DESIGN.md}Review round (2026-09-24)
Dual-agent review (AGENTS.md §5.3 code + §5.6 tests) completed over the full diff. Findings applied in
eff1fdb0:ensureDefaultFilesdefault-pack invariant pinned (managed reference files read back and asserted default-pack-only).