Skip to content

fix: DSH 压缩面抑制改为按工具实际可达性判定 (#3401) - #3403

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-16_fix-3401-dsh-compress-surface-reachability
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-16_fix-3401-dsh-compress-surface-reachability

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

Closing as superseded by #3427 — same issue (#3401), same mechanism (gate the compress surface on observed tool reachability, not lane name). #3427 implements the owner-approved v2 plan (#3417 steps 1–3): it fixes the same four prepare sites this PR touches AND generalizes them into the single lane-decisions.ts resolver with a per-wire truth-table test (tests/lane-decisions-matrix.test.ts) whose "dsh + compress-on-wire keeps the surface" rows cover this PR's positive regression case on all four wires. Merging both would textually conflict on the same four gate lines; the owner has directed #3427 into the release (#3331). Nothing unique is lost — this PR's test improvement (baseline length-delta assertion) is subsumed by the matrix harness's shape-based detection.

#3401)

#3177 keyed the model-side compress-surface suppression off the lane name
(pluginAgent === "dsh"), assuming every DSH install registers bili's ACP tools
host-scope and unreachable by its preset agent (its scanned profile had 0/3939
request headers carrying them). That assumption does not hold for every DSH
profile: some expose the ACP tools to the agent, so the unconditional gate
silently killed the whole model-side compression path (nudge + standing prompt)
for those setups.

Key the gate off observed reachability instead: biliToolsDeclaredOnWire reads
the request's own tools array (ground truth of what the model sees; bili injects
nothing in plugin mode) and suppresses only when the ACP tools are genuinely
absent from it. When a DSH agent exposes them, the surface stays on. The host's
tool table is per-session-stable, so the flag does not flip mid-session and the
responses developer slot stays append-cache-stable. pi/omp/opencode/proxy are
untouched (still gated only on pluginAgent).

Closes #3401
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-16_fix-3401-dsh-compress-surface-reachability (a7b40b9)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4041-pr.3403.25f90cf

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-pr3403.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

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 本 PR 对应 bug issue #3401(#3177/#3287 的后续修正),无并行重复条目;全仓 grep 确认只有本 PR 触碰 dshCompressSurfaceOff 门控,没有第二个在途改动改同一行。

我没有照抄 PR 描述里的八问,而是独立重读了一遍 diff、追了 helper、核对了下游每一处用法和兄弟站点。下面是我自己的审核结论。

独立核查(我实际做了什么)

  • 读了完整 diff:5 文件,+64/-22,单 commit。四张 wire(openai/responses/google/anthropic)各加同一个 conjunct && !biliToolsDeclaredOnWire(parsed, "<proto>"),外加 import 与注释;测试文件加 2 个回归 + helper 增一个可选参数。
  • 追了 biliToolsDeclaredOnWire(src/session-self-heal.ts:241):它只读请求自身的 tools 数组,逐条匹配 isBiliToolName(mcp__bili__* 前缀或 PROXY_TOOL_NAMES=acp-kernel 的 ACP_TOOL_NAMES),四种 wire 形状(flat {name} / openai {function:{name}} / google {functionDeclarations:[{name}]})都覆盖,protocol 参数其实是 void 掉的多形容错匹配——复用它是正确的。
  • 确认承重前提成立:plugin 模式下 injectTools = shouldInject && !pluginMode,bili 不往 wire 注入工具,所以请求自带的 tools 数组就是「模型真正能看到什么」的 ground truth。降级到 proxy 模式时 pluginMode 变 false,整条门控短路,与既有行为自洽,不会因 bili 自己注入工具而误判。
  • 核对下游副作用边界:该 flag 在四张 wire 里只喂两样东西——nudge 注入(willInjectNudge 含 !dshCompressSurfaceOff / responses 的 compressSurfaceOn)+ 常驻 compress 系统提示(openai/google 内联 push、anthropic 经 injectSystem 的 suppressCompressPrompt、responses 经 compressSurfaceOn 选 full-prompt vs tags-only)。逐点确认没有第三处被牵连。
  • 完整性检查兄弟站点:其它 dsh-keyed 站点(openai:139/google:136/anthropic:189 的 active-blocks 本地压缩 guard、responses:231 的 dshLane、handle.ts 的 side-request/title-sidecar 路由、安装 lane)都是不同机制,不涉及「agent 够不到工具」这个假设,PR 正确地没碰它们——没有漏改的同类缺陷。
  • CI(head e22b18c):全部静态/guard 门禁绿(static-gates、config-surface-guard、unused-exports、version-guard、test-import-graph、lock-sync、kernel-guard、lane-guard、pi-subagents-guard、docs-coverage),windows 三片 + ubuntu-22 三片全绿,零失败,仅剩一片 ubuntu-24 慢分片收尾。e2e/真实客户端 lane 按 gate 跳过(符合预期)。本地未重跑(node_modules 未装;CI 已覆盖同一批文件且零失败,独立静态分析已把机制钉死,不重复挤占共享算力)。

结构化八问

  1. 是什么问题:DSH 会话在「agent 能看到并调用 bili ACP 工具」的 profile 下,nudge 和常驻 compress 提示被永久关掉,模型侧折叠整条不可用,只能靠 preflight 硬顶到接近窗口才压。
  2. 什么原因导致的:根因是用 lane 名代替了「工具实际可达性」的观测。可达性是 host 工具注册作用域的属性、随 DSH profile 变,不是 lane 名能定的;billion-context 0.1.197 在 DeepSeek Harness(DSH)0.2.0-rc.2 里反复抛出 Error: unknown tool "compress"。 工具注册落在了错误的作用域 #3177 只扫了一个 profile(0/3939 头带工具)就把它当成了所有 DSH 的结构性事实。
  3. 影响范围与严重程度:仅「DSH plugin 会话 + agent 暴露 ACP 工具」这一类;触发条件=该 profile 把 ACP 工具挂进 agent 可见表。严重度=特定条件下功能受损(模型侧压缩不可用),非完全不可用;pi/omp/opencode/代理模式不受影响。
  4. 怎么修复的:门控从 lane 名改成按请求自身 tools 数组的实际可达性判定——复用现成 biliToolsDeclaredOnWire,命中「工具不在 wire 上」才抑制。策略层是把「DSH 例外」从名字一刀切改成实测可达性,四张 wire 一致落地。
  5. 是否有回归问题:审过的既有行为逐项——(a) billion-context 0.1.197 在 DeepSeek Harness(DSH)0.2.0-rc.2 里反复抛出 Error: unknown tool "compress"。 工具注册落在了错误的作用域 #3177 原场景(preset-standard,工具永不上 wire):biliToolsDeclaredOnWire 恒 false → 仍抑制,行为不变(新测试 control 分支 dshNoTools.count===30 钉住);(b) pi/omp/opencode/代理模式:前置 pluginAgent==="dsh" 对它们恒 false,未动;(c) flag 下游只喂 nudge + 常驻提示两处,无第三处副作用;(d) 其它 dsh-keyed 站点为不同机制、未受影响。高危模式逐项过:无语义漂移、无 fail-fast→吞错、无阈值/时序漂移、输出格式不变(只是已知静态块的出现与否换成了更准的判据)。
  6. 是否破坏缓存:没有(附一条残留假设,见下)。flag 每请求从 parsed.tools 重算;只要 host 工具表按会话稳定,flag 不中途翻转 → developer/system 槽位字节跨 turn 稳定。responses 的 append-stable 逻辑我没破(suppress→tags-only / on→full prompt,各自跨 turn 稳定)。cache-friendly-plugin 套件覆盖。
  7. 是否改了设计方向:没有转向。仍是「plugin mode = agent 拥有压缩」二分;只是把 DSH 例外从「按名字一刀切」改成「按实测可达性」。
  8. 是否引入新配置:没有。纯代码门控,复用现有 helper,无新 config key/env/flag/默认值,version 未动。

两点观察(非阻断)

判定

可合(建议 owner 显式放行)。 八问全部通过,机制正确、范围收得干净、回归面已逐项排除、CI 零失败。唯一要说明的是:它改变的是 DSH 会话出站 developer/system 槽位的内容选择(何时出现已知静态块),虽不改 wire 协议形状、也不改消息结构,但触及前缀缓存敏感的槽位内容,处于自动合并线的边缘——合并本身也始终是人来按,所以请 owner 给最终 go。合并后无需 follow-up。

@ranxianglei

Copy link
Copy Markdown
Owner Author

ai: zhipuai-lb/glm-5.3

逐行核对过,方向和实现都对(账号原因没法 approve,以评论为准):

  1. 四张 wire 门控一致:anthropic/google/openai/responses 同一表达式 pluginMode && pluginAgent==="dsh" && !biliToolsDeclaredOnWire(parsed, "<proto>"),无漂移。
  2. 复用现成 helper:session-self-heal.ts:241 的 biliToolsDeclaredOnWire 本来就处理三种工具形状(flat name / function.name / functionDeclarations),不是新造轮子。
  3. 正向回归用例齐了(此前担心的点):tools 上 wire→nudge 保留(31 vs 30 对照)+ 系统提示保留(ACP TAGS 断言);fixture 里混入宿主 read_file 工具避开 OMP extension injects tools and compression philosophy in helper prompts #1897 的 leaked-tools-only 降级,考虑周到。
  4. billion-context 0.1.197 在 DeepSeek Harness(DSH)0.2.0-rc.2 里反复抛出 Error: unknown tool "compress"。 工具注册落在了错误的作用域 #3177 原场景(no-tools)仍有对照断言保护,不回退。

一个非阻塞 follow-up 供记录:helper 是「任意 bili 工具在 wire 上」即判可达——若某 profile 只暴露 acp_status/decompress 而不暴露 compress,nudge 仍会催模型调一个不在 wire 上的 compress(#3177 窄形复发)。按目前 DSH 全量注册 manifest 的现实这是理论角,建议后续把判据收紧到「nudge 点名的工具在 wire 上」。

另:本次回归真模型 gate 全绿放行的事实在单独 issue 里处理(gate 无 plugin-native 车道),不归这个 PR。

… against the no-tools baseline

The first assertion ('ACP TAGS' present) also holds for the suppressed
tags-only fallback, so it passed on pre-fix code (verified by reverting
src/ and re-running). Add the length-delta check against a DSH session
WITHOUT tools on the wire, mirroring the #3177 test's discipline: the
with-tools system block must carry the FULL compress prompt, not just the
tags-only fallback.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

独立核对了你提的这条 follow-up,结论成立,补两点让它以后好落地:

验证:nudge 文本(kernel/src/nudge-text.ts 的 renderNudgeText,gentle/emergency/tier2/tier3 四种 voice)确实直接点名 compress——“fold every range … into a single compress call”、“Example: compress({content:[…]})”。所以若某 DSH profile 只把 acp_status/decompress 挂上 wire、唯独没有 compress,门控判「可达」→ 压缩面打开 → nudge 催模型调一个 wire 上不存在的 compress,正是 #3177 失败形态的窄形复发。判断准确。

精确判据(给后续收紧用):目标应是「compress 这一个工具在 wire 上」,而非「任意 bili 工具」。理由:它是 nudge 反复点名、真正承重的那个动作;只查它比「查全部四个」更稳——后者会在假想的「有 compress+decompress 但缺只读工具」profile 上过度抑制,而现实里 DSH manifest 是全量或全无,查全四买不到额外正确性。实现细节别漏:匹配要同时覆盖裸名 compress 和 MCP 前缀 mcp__bili__compress(现 biliToolsDeclaredOnWire 里的 isBiliToolName 就是两种一起判的),且四张 wire 形状(flat / function.name / functionDeclarations)都要过一遍,不能只写 name === "compress"。这个收紧是单调安全的:全量 manifest 的 DSH(compress 在)行为不变、#3401 保留;preset-standard(无任何工具)不变、#3177 保留;只在「有别的 bili 工具但没 compress」的坏角上多抑制一层,不会误伤任何现在正确的场景。

处置:尊重你「本 PR 按现状合并、这条留作后续」的判断——我不动这个已评审过的门控,也不为它单开一个会触发调度的 issue(理论角,自动派个 agent 去重新分析是浪费算力)。它已在本线程留痕。等你想排期时我可随时:①在本分支补一个标注 commit(几行 + 扩一条测试),或 ②开一条带 [no-dispatch] 的记录 issue。你定即可。

真模型 gate 那条收到——gate 无 plugin-native 车道、这次走的是跳过,放行事实另案处理、不归本 PR,理解。

本 PR 判定维持:可合。

ranxianglei added a commit that referenced this pull request Oct 16, 2026
fixes #3401 (#3417)

- src/server/lane-decisions.ts: HostProfile registry (only name-comparison
  point) + WireObservation (per-request declared bili tools) +
  resolveLaneDecisions() consumed by all four prepares
- #3401 fix: dsh profile declaring compress on the wire keeps the compress
  surface (observation overrides the host-scope default)
- biliToolsDeclaredOnWire: named-tool precision (#3403 follow-up)
- dsh compact-rebase gate x4 -> profile.compactsClientSide
- tests/lane-decisions-matrix.test.ts: 4-wire x 4-row truth table (16 rows,
  #3401 row pinned green after the fix) + structural no-name-comparison guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant