Repository navigation
[PR] fix(hermes): tool_search still binds session identity and model budget when deferring plugin tools (/acp panel + 500K wi | fix(hermes): tool_search 延迟插件工具时仍绑定会话身份与模型预算(/acp 面板 + 500K 窗口) - #4856
ranxianglei merged 4 commits into
Conversation
8b99a39 to
0cc265f
Compare
…4856 review) The author's rebase landed on 05c379e; master has since advanced via ranxianglei#4837 (kernel-guard lockfile exemption). Additive sync per AGENTS §7.2 — no history rewrite.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。按失败签名(hermes tool_search / x-bili-plugin-compression / pfa-* 匿名会话)检索 open+closed 的 issue 与 PR:仅相关项为 #4855(本 PR 的来源 issue);#2398 已关闭且机制不同(Responses 预算记账);#4694/#4702 是 pi subagents 配置,无关。 标签: bug / hermes / scope/wiring / p2(缺陷修复;hermes 车道;协议接线层;能用但面板与窗口错——压缩本身不受影响,故 p2 不 p1)。 审核结论(八问)
审核发现与处置(小问题直接修,均已推上 PR 分支)
分支维护说明审核期间 PR head 被换成了基于较旧 master(05c379efd)的 rebase 版本,而当前 master 已推进到 24e71f6(含 #4837 等)。我把当前 master 合并进 PR 分支(additive sync,未改写历史),最终 head 验证typecheck 干净;定向套件(wire-contract-golden / plugin-protocol / hermes-native / pi-subagent-channel / plugin-native-binding / lane-decisions-matrix)191/191 pass;全量回归以远程 CI 为准(新 head 上重跑中)。 判定:方向正确、机制健全、测试双向有牙(gate 纪律的正反两侧都钉住了)、唯一拦路项(golden 红)已修并推上 PR 分支。CI 转绿后可合——按 §7.4 触及会话绑定/身份语义,需人工 review 与手动合并:#4856 |
… the ACP tools (ranxianglei#4855) Hermes defaults tools.tool_search to "auto": model_tools.py:517-534 rewrites the plugin toolset into the tool_search/describe/call bridge, so the outgoing request never carries compress/decompress/acp_status. _plugin_tools_visible() therefore returns False and on_llm_request bailed out entirely — dropping x-bili-plugin, x-bili-plugin-conversation, the model and the context-window headers. The proxy then minted a pfa-* anonymous session (session.ts:1330): /acp's status lookup 404'd and read as "No model request yet", and the window fell back to 200K. Decouple identity/budget from whoever executes compression. The proxy advertises x-bili-plugin-compression in the manifest headers; the plugin stamps "proxy" only when that capability is advertised AND the ACP tools are absent from the request, and the proxy honors it only alongside the x-bili-plugin marker (same degradation shape as ranxianglei#2155's plugin-channel death and ranxianglei#2268's pi-subagent role whitelist). Identity and budget now bind to the conversation; the proxy keeps owning the compress injection while the tools stay deferred. Tests: plugin-protocol gains a 4-leg case (deferred/subset/no-override/no-marker — the last one must still 404) and hermes-native a defer-fallback driver scenario.
…pression (ranxianglei#4855) The PR added the optional protocol header x-bili-plugin-compression, broadcast in the plugin manifest under headers.compression, but did not regenerate the wire-contract golden snapshots, so tests/wire-contract-golden.test.ts went red on manifest-default.json and manifest-optin.json (CI: 3 of 6 test shards failing on exactly those two tests; parent commit was fully green). Regenerated with scripts/update-wire-contract-goldens.ts; the diff is additive only — one new key per manifest snapshot. Ledger grows, nothing shrinks.
…ompression-channel comments (ranxianglei#4855) All six comments added by this PR cite ranxianglei#4657, which is an unrelated closed PR (hermes proxy-misdetection fix, Fixes ranxianglei#4656). The anchor must point at the issue being fixed, ranxianglei#4855. Comment text otherwise untouched.
…l/compression) (ranxianglei#4855) The manifest example listed only agent/conversation/contextWindow/instructionsMutable — it already missed maxOutput and model before this PR, and now also misses headers.compression. Complete the example to match the real manifest and add one sentence documenting the optional per-request compression override semantics.
8faf94b to
75c8170
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.873-master.e4cc685 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Fixes #4855
问题
Hermes 默认开启
tools.tool_search,model_tools.py:517-534把插件 toolset 换成tool_search/describe/call桥,出站tools[]里没有compress/decompress/acp_status。_plugin_tools_visible()(hermes-plugin/__init__.py:1567-1576)因此为假,on_llm_request在:1602-1607整个return None—— 连x-bili-plugin、x-bili-plugin-conversation、model、window 四个头一起丢。代理只能铸pfa-*匿名会话(src/session.ts:1330),于是/acp用local-*查状态 404 并误报 "No model request yet",窗口也从 500K 回落 200K。压缩本身没坏(
pfa-*下确实在 fold),坏的是身份与预算。做法:身份/预算与压缩执行者解耦
新增可选协议头
x-bili-plugin-compression: proxy:src/plugin.ts:113-123)定义PLUGIN_COMPRESSION_HEADER,并在 manifestheaders.compression广播;pluginCompressionProxyHeader()(:266-271)要求同时存在x-bili-pluginmarker 才认,src/server/handle.ts:1791-1801据此关闭pluginMode(首次命中记session.metadata.compressionProxyNotified+ 一条 info 日志)。这是既有降级形态的复用:会话卡死自愈机制:卡死模式检测与代理侧主动补救 #2155 plugin 通道死亡、[Pi / pi-subagents] 默认内置角色的 tools 白名单阻挡 ACP:bili 自动加载成功,但上下文工具仍不可调用 #2268 pi-subagent 角色白名单。hermes-plugin/__init__.py):_state["compression_header"]从 manifest 读能力;on_llm_request在工具不可见但代理广播了该能力时,照常盖 identity/model/max-output/window 头,再追一个proxy。老代理不广播 → 该分支不可达,零行为变化。结果:会话仍绑在
local-*上,/acp有面板、窗口走真实 500K;压缩继续由代理注入执行(工具仍在tool_search后面,代理模式本来就需要自己注入才跑得起来,见src/server/lane-decisions.ts:264-278)。为什么不按「有 tool_call 桥就转 native」
桥的存在不证明当前会话能调出全部 ACP 工具(模型可能从不
describecompress)。那样做会把插件头盖在一个实际压不了的会话上,比现状更糟。测试
tests/plugin-protocol.test.ts新用例 4 条腿:①deferred(仅read_file)→ 上游收到注入的compress/decompress/acp_status且保留read_file,status?conversationId=sess-defer200、pluginAgent=hermes、contextLimit=500000;②部分快照(只有compress)→compress不重复注入、其余补齐;③无 override 头 → 纯插件道不注入;④只有 conversation + compression、无x-bili-pluginmarker → 会话仍 404。tests/hermes-native.test.ts新增defer-fallback驱动场景(无工具 / 仅compress/ 全可见三种 mw 调用),断言前两者都带proxy、全可见时不带。本地:
npm run typecheck0 错;npm run build成功;node --import tsx --test tests/plugin-protocol.test.ts tests/pi-subagent-channel.test.ts tests/plugin-native-binding.test.ts45/45 pass;tests/hermes-native.test.ts51/51 pass(均为 RED→GREEN)。实机验证(Hermes TUI + 本 PR 构建):
/__bili/plugin/status?conversationId=local-b6dc…由 404 变 200,pluginAgent=hermes、windowSource=plugin、contextLimit=500000、runtimeInfo.source=hermes-native。风险 / 已知边界
tool_search,不在本 PR 范围。_plugin_tools_visible()只读tools[].function.name|name;模式误判会导致同名工具重复注入(被 404 腿的断言卡住)。pfa-*的块状态不复用(首轮一次性重付),属预期。按 AGENTS §7.4,本 PR 触及会话绑定/身份语义,需人工 review,不自动合。