Skip to content

fix: apply the effective render strategy consistently across all lanes (#2483) - #2485

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-09_render-strategy-consistency
Oct 10, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-09_render-strategy-consistency

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Part of #2483 — the immediately-actionable consistency fixes from the issue thread. The core ask (per-route render-tags control for stateful upstreams, e.g. magpie / Claude Code relays) awaits owner sign-off on the proposed compress.renderTags design discussed in the issue; this PR ships the rest of the mechanism family.

Changes

  1. Google lane now honors renderNone (src/server/prepare-google.ts). ACP_RENDER_NONE / diagnostics.renderNone was dead config on /v1beta: processTurn, Prepared.renderTags and countTokens all hardcoded "text-only", and the [bug] ACP 标签泄漏:<acp tokens=...> 标签被模型原样复述到回复正文,仅靠系统提示劝阻不足 #1881 tagsOnly prompt gate had no knob check (unlike the other three lanes). Now mirrors the openai lane: one strategy const drives processTurn, the diag log, Prepared and the tagsOnly gate.
  2. Diag log reports the real strategy (all four lanes). diagTagSummary(messages, sessionId, strategy) takes a strategy parameter, but every call site hardcoded "text-only" — so the processTurn: line kept printing renderTags=text-only while the tag counts proved none was active (the reporter's Minor complaint). Each lane now passes its effective value.
  3. Cache report hint (src/cache-ledger.ts). The PROVIDER-SIDE MISS section now names the stateful-upstream failure mode (render tags on echoed assistant text break session continuity on stateful upstreams (magpie / Claude Code), causing full-history cache misses #2483): a gateway validating echoed history against its own transcript rejects bili's render tags even though bili's list is unchanged → points at diagnostics.renderNone=true, notes the expected single replay when flipping mid-session.

Behavior changes (disclosed)

Surface Old New Who is affected
Google lane + knob set ignored — tags always rendered, NEVER-echo prompt always injected honored — no tags, prompt section dropped only users who explicitly set ACP_RENDER_NONE/diagnostics.renderNone; default is byte-identical (pinned by new e2e tests)
processTurn: log line renderTags=text-only constant effective strategy log output only
/acp-cache PROVIDER-SIDE MISS detail line only + one hint line report output only

No config surface change (reuses existing diagnostics.renderNone; no new fields/env vars). No kernel change. No wire change under default configuration.

Preflight audit (left unchanged, verified safe)

src/preflight.ts:1172/:1274 also hardcode renderTags: "text-only", but preflight's rendered view is estimation-only: after any compression the server re-runs runPrepare() and forwards the PREPARE-rendered body (src/server.ts:4677), so those bytes never reach the wire. Preflight already estimates with its own deliberate view (noEmergencyTruncate config); under none its estimate is conservatively larger by the tag bytes (~tens of bytes per tagged message) — folds marginally earlier, never later. No fix needed.

Tests

  • tests/issue2483-render-strategy.test.ts (new, ungated, hermetic): e2e through the real proxy on both the OpenAI-chat and Gemini-native wires — default still tags assistant/model text (behavior pin); under ACP_RENDER_NONE=1 forwarded text is byte-identical to the model's raw output and the NEVER-echo section disappears (both lanes).
  • tests/cache-seam-detector.test.ts: pins the new hint line in the PROVIDER-SIDE MISS section.
  • Local: targeted suites green (23/23), typecheck green, build green; full suite via CI.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 上游冲突已解决并推送(c1f85e382..7f1a2cefd),PR 已恢复 mergeable: true(当前 blocked 仅因等待新 head 的 CI 检查)。按八问汇报:

1. 是什么问题:系统转发上游冲突唤醒——本 PR 分支与 master 产生文本冲突。master 在分支切出点(f2b84b6)之后前进到 4d5dab9(release v0.1.189 及后续),其中 #2432(compress circuit breaker cause-awareness)恰好改动了本 PR 触碰的同一行区域:willInjectNudge 表达式与本 PR 修改的 diagTagSummary(...) 调用相邻,openai/google/responses 三个 lane 文件全部文本冲突。

2. 什么原因导致的:两个独立变更落在同一行邻域——本 PR 把 diagTagSummary 第三参从硬编码 "text-only" 换成有效策略变量;master 侧 #2432 给紧邻的 willInjectNudge 加了 !compressBreakerArmed(session) 项。git 无法自动合并相邻行的两个独立编辑,属正常的并发热点文件冲突(§7.2 hot-file contention),不是任何一方改错。

3. 影响范围与严重程度:冲突本身零运行时影响——风险只在解决方式上:若只保留一侧,要么丢掉 breaker 的 nudge 熔断门(master 行为回归),要么丢掉策略变量(PR 目的落空)。按「两侧意图取并集」解决后无影响面。

4. 怎么修复的:按 house style 用 merge commit(非 rebase/force-push)把 origin/master 合入分支;三处冲突逐处取并集——保留本 PR 的策略变量(renderStrategy/renderTags)同时保留 master 的 !compressBreakerArmed(session) 项(responses lane 另保留其独有的 !isCompactionTrigger)。两个机制正交:breaker 门控 nudge 注入,策略门控 tag 渲染,互不干扰。

5. 是否有回归问题:无。验证证据:① 合并树 vs PR head 对三个文件的 diff 恰好等于 master 侧新增(breaker import、#2432 dsh native-compaction rebase、#1933/#2407 billed-caliber denominator 等),两侧内容零丢失;② typecheck 绿(kernel + pi-subagents pre-hook 构建通过);③ 定向测试 38/38 绿——本 PR 自己的 tests/issue2483-render-strategy.test.ts(双 lane e2e)+ tests/cache-seam-detector.test.ts,加上 master 侧被合并代码的 tests/issue2432-breaker-awareness.test.ts + tests/issue2432-dsh-local-compaction.test.ts;④ build 绿。全量套件由 CI 把关。高危模式逐项过:无语义漂移(fail-fast 未变)、无阈值/时序变化、默认配置下 wire 字节不变(renderStrategy 表达式与旧内联表达式等价)。

6. 是否破坏缓存:不涉及。缓存/重试/增量游标逻辑未触碰;cache-ledger 改动仅新增一行提示文本(PROVIDER-SIDE MISS 段,报告输出)。

7. 是否改了设计方向:不涉及。仍为原 PR 机制家族;核心诉求(per-route compress.renderTags,stateful upstream 如 magpie/Claude Code relay 场景)继续等 owner 在 #2483 线程拍板,本 PR 未越界。

8. 是否引入了新的配置:不涉及。复用既有 diagnostics.renderNone,无新字段/env。

顺手小修(独立标注 commit 7f1a2cefd):PR 里三处 Prepared return 对象中 renderTags: renderStrategy 前有多余空格(openai/google/anthropic lane 各一处),已收敛。

结论:可合。 冲突已清、两侧意图完整保留、定向验证全绿;待 CI 对新 head 跑完即可由人工合并。

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-09_render-strategy-consistency (cbe4f09)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2908-pr.2485.be1797f

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-pr2485.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei force-pushed the 2026-10-09_render-strategy-consistency branch from 7f1a2ce to 854eabf Compare October 9, 2026 08:26
…2483)

- google lane honored renderNone not at all (dead config on /v1beta):
  processTurn, Prepared.renderTags, countTokens hardcoded "text-only"
  and the #1881 tagsOnly gate had no knob check; now mirrors openai lane
- diagTagSummary call sites hardcoded "text-only" in all four lanes, so
  the processTurn log line lied under renderNone; pass the effective value
- cache report PROVIDER-SIDE MISS section names the stateful-upstream
  failure mode (#2483) and points at diagnostics.renderNone=true
- e2e tests pin default tagging AND renderNone byte-identity on both the
  OpenAI-chat and Gemini-native wires
@ranxianglei
ranxianglei force-pushed the 2026-10-09_render-strategy-consistency branch from 854eabf to 0690f4f Compare October 10, 2026 15:53
@ranxianglei

Copy link
Copy Markdown
Owner Author

Rebased onto current master (0690f4f) — was DIRTY against the four prepare-*.ts lanes.

Conflict resolution notes (semantic union, both sides preserved):

  • willInjectNudge lines: kept master's newer guards everywhere — !(autoFoldEngaged(...) && growthFoldingArmed(...)) (openai/google/responses; responses keeps its codex-compact health-ratio variant too) — while taking this PR's diagTagSummary(..., renderStrategy|renderTags) line.
  • prepare-anthropic return: kept master's anthropicClientCacheControls: clientCacheControls field, swapped renderTags to this PR's renderStrategy.
  • prepare-google imports/budget: union — master's dshLedgerFloorTokens (dsh压缩与bili压缩冲突 #2490/fix(#2490): plan output budgets against the refused dsh raw ledger; fail fast doomed evidence probes #2577 clamp floor) kept alongside this PR's renderNone as knobRenderNone; the clamp call still passes ledgerFloorTokens and the lane now honors renderNone.

Verified: typecheck 0; issue2483-render-strategy 4/4 (new e2e pins), issue2490-ledger-floor-doomed-probe, issue2122-clamp-calibration 7/7, issue2636 model-switch, e2e-plugin-grow-compress, compress-observability — all green. CI running.

…epared returns) — re-introduced by rebase
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到 rebase 报告,已对 rebase 后的 head(0690f4fb1,on master@44d5ac95a)做了独立核验,并补了一个小修 commit。按八问:

1. 是什么问题:确认你报告的 rebase——分支已被 force-update 为单 commit 0690f4fb1(我此前的 merge commit 5c2be35bc + style commit 7f1a2cefd 被 rebase 取代)。本轮工作 = 核验 rebase 结果完整性。

2. 什么原因导致的:rebase 重建时未携带我之前的 style commit(它只改空格、无内容价值,被正常丢弃),导致两处空格瑕疵重新出现;非语义问题。

3. 影响范围与严重程度:仅内部实现/外观,零运行时影响。

4. 怎么修复的:核验结论——① rebase 后 head vs 其父 commit 的 diff 恰好是原 PR 的 7 个文件、+311/-16,stat 与原始 PR 完全一致,无内容丢失;② 四处 willInjectNudge 与你描述一致:全部 lane 保留 master 新守卫(!compressBreakerArmed && !(autoFoldEngaged && growthFoldingArmed)),responses 保留 codex health-ratio 变体 + !isCompactionTrigger,diagTagSummary 用策略变量;③ anthropic return 保留 anthropicClientCacheControls;④ 两个测试文件完整(e2e +268、seam pin +13)。发现的两处回归瑕疵(openai/google Prepared return 里 renderTags: 前多余空格,your 版本里 anthropic 那处已是干净的)已按「小问题直接修」补独立标注 commit cbe4f0996(纯空白,git diff -w 验证零非空白差异)。

5. 是否有回归问题:审了 rebase 触碰的全部既有行为——nudge 注入守卫链(breaker/autoFold/growthFolding/codex-ratio)、anthropic cache-controls 字段、google ledger-floor clamp 与本 PR renderNone 的共存,均为两侧意图并集,与你的 notes 逐条对上;无语义漂移、无阈值/时序变化。默认配置 wire 字节不变。

6. 是否破坏缓存:不涉及。

7. 是否改了设计方向:不涉及。

8. 是否引入了新的配置:不涉及。

当前状态:mergeable: true,仅 behind master 一个 commit(#2687 web-access 文案,与本 PR 七个文件零交集,不构成冲突);CI 正在跑新 head。可合。

@ranxianglei
ranxianglei merged commit 6064a0e into master Oct 10, 2026
28 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.238-master.6064a0e (rolling master tag).

npm install -g billion-context@0.0.238-master.6064a0e  # 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.

ranxianglei added a commit that referenced this pull request Oct 11, 2026
…der-strategy consistency)

All four wires gain a constant +65 bytes per outbound body from turn 0
(#2485 applies the effective render strategy consistently across lanes);
nudge/stats/state sections shift accordingly. foldAt/editedAt/blockContents
unchanged. Regenerated at branch HEAD (4b3e3b4 + storage-mode stamp).
ranxianglei added a commit that referenced this pull request Oct 11, 2026
…der-strategy consistency)

All four wires gain a constant +65 bytes per outbound body from turn 0
(#2485 applies the effective render strategy consistently across lanes);
nudge/stats/state sections shift accordingly. foldAt/editedAt/blockContents
unchanged. Regenerated at branch HEAD (4b3e3b4 + storage-mode stamp).
ranxianglei added a commit that referenced this pull request Oct 11, 2026
…der-strategy consistency)

All four wires gain a constant +65 bytes per outbound body from turn 0
(#2485 applies the effective render strategy consistently across lanes);
nudge/stats/state sections shift accordingly. foldAt/editedAt/blockContents
unchanged. Regenerated at branch HEAD (4b3e3b4 + storage-mode stamp).
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
@ranxianglei
ranxianglei deleted the 2026-10-09_render-strategy-consistency branch October 15, 2026 05:32
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