Skip to content

fix: plugin-lane absorb tool follows base config so manifest and gate agree (#1359) - #1369

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-26_absorb-plugin-toolname
Sep 26, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-26_absorb-plugin-toolname

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

The plugin manifest advertised the absorb tool under its static constants (acp_absorb / absorb / gemini_absorb / absorb_responses) while per-session adjudication (src/absorb.ts:52) resolves the merged route/model name via effectiveAbsorbConfig. Whenever absorb.toolName was renamed at any level, the host registered the static name from the manifest but the /__bili/plugin/tool gate expected the renamed name → the advertised tool 400s and the absorb surface is unusable on the plugin lane. Same silent-loss class as #1345 (CCR); wider trigger surface — one top-level config line reproduces it, no provider/model override needed.

Fix

In plugin mode the whole absorb block follows the base config — advertise the base name, adjudicate the base name, so the two can never diverge. Provider/model absorb.* overrides stay proxy-lane-only (proxy mode still injects and adjudicates the merged name exactly as before). This mirrors the lane-governance decision landed for CCR in #1360.

  • src/compress-settings.ts — new resolveAbsorbSettings(): single source of truth for raw→resolved absorb, shared by applyCompressSettings and the plugin-lane base stamp so both resolve identically.
  • src/server.ts — at each prepare site + the forward path, plugin mode now stamps loopConfig.absorb from the base config; the injected tool array and the system-prompt section follow the resolved name. Proxy mode unchanged.
  • src/plugin.ts — manifest advertises the resolved name via new absorbToolsFor(name) (byte-identical wire shapes at the default name).
  • src/config.ts — load-time per-field divergence warning (findAbsorbPluginDivergences), mirroring the fix(ccr): plugin-mode sessions execute the base ccr block exclusively #1360 CCR diagnostic.
  • CONFIGURATION.md / CONFIGURATION.zh-CN.md — document the lane governance.
  • tests/absorb-plugin.test.ts — regression coverage.

Behavior change (old → new)

Before After
Plugin-lane absorb advertised name static constant base-resolved name
Plugin-lane absorb executed name merged (base + route + model) base-resolved name
Provider/model absorb.* overrides advertised ignored, executed honored → divergence ignored on the plugin lane; still honored on the proxy lane

Why: the plugin manifest is built from base config at registration time and cannot see per-session route/model merges. Making both advertisement and execution follow the base guarantees they agree. Consequence: a user who renames absorb.toolName at provider/model level expecting plugin-mode agents to pick it up will now get the base name on the plugin lane (the rename still applies to plain-proxy clients) — identical semantics to CCR after #1360.

Related, out of scope here

The V2 native opencode plugin (src/agent/opencode-v2.ts:116) registers ABSORB_TOOL_OPENAI statically — the same divergence class on a separate registration path. Not touched by this manifest fix (consistent with #1360, which also left it). Flagged for the owner to decide whether to track separately.

Pre-flight

  • npm run typecheck — clean
  • npm test — 2656 tests, 2645 pass, 0 fail, 11 skipped (gated e2e/registry suites)
  • npm run build — success
  • New targeted suite tests/absorb-plugin.test.ts: 10/10 pass (plugin manifest follows the resolved name and the gate agrees; proxy still honors the merged override; default shapes byte-identical; divergence diagnostic fires/stays silent)

Fixes #1359

… agree (#1359)

The plugin manifest advertised absorb under its static constants while
per-session adjudication resolved the merged route/model name, so a renamed
absorb.toolName made the advertised tool 400 (same silent-loss class as #1345,
wider trigger surface: one base-level rename suffices).

- resolveAbsorbSettings(): single source of truth for raw->resolved absorb,
  shared by applyCompressSettings and the plugin-lane base stamp.
- server.ts: in plugin mode the whole absorb block follows the BASE config
  (advertise + adjudicate the same name); provider/model absorb.* overrides
  stay proxy-lane-only. Proxy mode unchanged (still honors the merged name).
- plugin.ts: manifest advertises the resolved name via absorbToolsFor(), which
  builds byte-identical wire shapes at the default name.
- config.ts: load-time per-field divergence warning (findAbsorbPluginDivergences),
  mirroring the #1360 ccr diagnostic.
- docs (en+zh): document lane governance for absorb.toolName.
- tests/absorb-plugin.test.ts: regression coverage (plugin manifest follows the
  resolved name and the gate agrees; proxy still honors the merged override;
  default shapes byte-identical; divergence diagnostic fires/stays silent).

Fixes #1359
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-26_absorb-plugin-toolname (d67780d)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1369

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

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1369.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 #1369 审查结论(fix: plugin-lane absorb tool follows base config,修 #1359)

① 方向关 ✅ — #1359 根因:manifest 用静态常量 advertise,而 per-session gate(src/absorb.ts:52)按合并后名字 adjudicate → 任意层级改名后 host 注册的静态名在 /__bili/plugin/tool 被拒 400。本 PR 让 plugin lane 的 advertise 与 execute 同源跟随 base config(resolveAbsorbSettings(opts.compress.absorb)),与 CCR(#1360) 的 lane-governance 决策一致。打到根因(单一事实来源),非治标。

② 回归审查(逐项既有行为):

  • 默认名(未改名):manifest/gate/injection 全部解析为 "absorb"(已用 node 验证 DEFAULT_ABSORB_CONFIG.toolName === ABSORB_TOOL_NAME === ABSORB_TOOL.name === ABSORB_TOOL_OPENAI.function.name)→ 字节级不变,无回归。
  • Plugin lane 注入本就关闭(src/server.ts:2538 injectTool && !pluginMode),所以本改动只影响 manifest advertise 名 + gate stamp 名;两者现在同源 → 结构上不可能再分叉。✅
  • Proxy lane —— 有一处需澄清的行为变更:旧代码 proxy lane 注入的是静态 ABSORB_TOOL(name="absorb"),而 gate/prompt 早已用合并名 → 旧代码在「route/model 层改名」时 proxy lane 本身也是分叉/坏的(schema 说 absorb、gate 要改名后的值 → 400)。新代码让 proxy 注入的 schema 也跟随合并名(e2e test2 已断言 wire 上出现 "route_absorb")。这是修复而非回归,但 PR 描述里 “Proxy mode unchanged / still injects the merged name exactly as before” 这句不够准确——实际 proxy 注入工具名从「静态默认」变成了「合并名」。建议披露表补一行说明。(仅影响「在 route/model 层改过 absorb.toolName 且走纯 proxy 客户端」的用户;旧行为本就是坏的。)

③ 代码审查:

  • resolveAbsorbSettings() 是从 applyCompressSettings 抽出的纯重构,逻辑逐字一致;effectiveAbsorbBlock(pluginMode, config, baseAbsorb) = pluginMode ? resolveAbsorbSettings(baseAbsorb) : config.absorb,5 个调用点(4 prepare + forward)统一用它算 absorbBlock/loopConfig/stamp。✅
  • 关键不变量成立:manifest 由 applyCompressSettings(config, …, opts.compress)(base,永不见 per-request 合并)构建,plugin-lane gate 用 resolveAbsorbSettings(opts.compress.absorb)(同函数同输入)→ 保证一致,不靠巧合。✅
  • loopConfig 重构与旧的等价(active→block,否则 undefined),除意图内的 plugin-lane 变更外无副作用。✅
  • 所有 adjudication/execution 点都跟随 resolved/stamped 名(stream.ts:53、loop/core.ts:184&730、plugin.ts:642&892、absorb.ts:28/52);4 个注入点全走 absorbToolsFor(resolvedName)。唯一残留静态注册是 src/agent/opencode-v2.ts:116(V2_BILI_TOOLS 用 ABSORB_TOOL_OPENAI)——PR 已明确标注 out-of-scope(独立 in-host 注册路径,与 fix(ccr): plugin-mode sessions execute the base ccr block exclusively #1360 一致地留了)。确认属实,不阻塞;是否单独立项由你定。

④ 测试有效性:tests/absorb-plugin.test.ts 是真测试、有牙 —— manifest 改名后 advertise 新名且不再 advertise 静态名(核心修复);gate 只接受 stamp 的新名;e2e test1 走真实 /__bili/plugin/tool 端点断言 200+ok:true(正是 #1359 复现,pre-fix 会 400);e2e test2 钉住「plugin 跟 base、proxy 跟 override 且 wire 注入改名工具」;divergence 诊断对齐/未设→静默、route 改名→只报 toolName、model 层只报 SET 字段、"80%"==0.8 归一化。bug 回归时这些都能抓住。✅

⑤ diff 整洁度:8 文件全为 src/docs/test,无 lockfile/dist/生成物,git diff --check 零空白错误,无大段重排。小 nit:src/compress-tool.ts(absorbToolsFor 的家)没写进 PR 描述 bullet 列表,建议补一句。

本地 + CI 验证(我实跑):

结论:可以合并。 根因修得干净、不变量结构保证、测试有牙、CI 含真实 codex e2e 全绿。唯一建议(非阻塞):把「proxy lane 注入工具名 静态默认→合并名(属修复)」这一行补进行为变更披露表,避免 “Proxy mode unchanged” 被误读为字节级不变。


一句话中文摘要:修复了 absorb 工具在 plugin lane「manifest advertise 静态名 vs gate 按合并名裁决」导致改名后 400 的分叉(顺带把 proxy lane 注入 schema 也对齐到合并名),通过让两 lane 各自的 advertise/gate/inject 同源解析实现,测试有牙且 CI 含真实 codex e2e 全绿,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

深审通过(独立验证,零改动):

设计核验(#1359 是 #1345 的同类病,修法对齐):

  • absorbToolsFor(name) 把四种 wire 形状参数化——manifest 广播、逐请求注入、工具裁决三条路径吃同一个已解析名,改名不再分叉
  • provider/model 级 absorb 覆盖只作用于 proxy 车道(plugin 车道跟 base)——分歧不再静默:加载时一次性 warn,列出每个越界字段与两侧值
  • normAbsorbValue 处理了 75% 字符串与 0.75 数值的归一化对比,不会因书写形式不同误报

实测:absorb-plugin 10/10(250 行新测试,含改名端到端+分歧警告断言)。

合并无阻塞。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,感谢独立深审确认——与我的结论一致(根因同源解析、默认名字节级不变、测试有牙、CI 含真实 codex e2e 全绿)。

我此前提的两条均为非阻塞观察:

  • proxy 车道注入工具名「静态默认→合并名」(属修复)可补进行为变更披露表一行;
  • src/compress-tool.ts(absorbToolsFor 所在)可补进 PR 描述 bullet 列表。
    既然「零改动」,这两条保持可选即可,不影响正确性与可合并性,由你定。

按系统规则合并是人工操作,我不代合;方便时你直接 merge #1369 即可(fix PR,合入即落 master,不涉及发布流程)。审查侧我这边无遗留项。

@ranxianglei
ranxianglei merged commit 27397d6 into master Sep 26, 2026
11 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-26_absorb-plugin-toolname 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.

bug(absorb): plugin manifest tool name can diverge from the session-resolved absorb tool name

1 participant