Skip to content

[PR] fix: forward toolless structured-output requests as side requests - #5074

Closed
elight wants to merge 10 commits into
ranxianglei:masterfrom
elight:2026-10-28_structured-output-side-request
Closed

elight wants to merge 10 commits into
ranxianglei:masterfrom
elight:2026-10-28_structured-output-side-request

Conversation

@elight

@elight elight commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5073

What changes

isSideRequest() now returns true for a request that has no tools and asks for a structured JSON reply: response_format of type json_schema or json_object on the chat wire, or text.format with those types on the Responses wire. Such a request takes the #388 side passthrough, so it is forwarded verbatim with no ACP tools added.

The classification ships as the exported isStructuredOutputCall(parsed) predicate with the #546 no-tools veto built into it. handle() consults that predicate independently of isSideRequest() — the same shape as the #2500 isServerToolUtilityCall predicate — so it can:

Order of the rules in isSideRequest():

  1. An explicit side persona is still a side request, and an explicit main persona is still a main turn.
  2. The [bug] Claude Code 的 WebSearch 子请求被当成主对话:nudge 基准被搜索的 usage 重锚,导致提前折叠;每次搜索还被注入 bili 工具 #2500 server-tool utility call is unchanged.
  3. The [bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 rule is unchanged: any request carrying tools is a main turn, with or without response_format.
  4. New: no tools plus a structured format is a side request (after the [bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 veto, so a tool-carrying structured request stays a main turn).
  5. The output-budget heuristic is unchanged.

Why

The Hermes plugin sets HTTP(S)_PROXY in the Hermes process, so child processes inherit the proxy. The Hindsight memory daemon is one of them. Its fact-extraction calls have no tools, set response_format, and use a 64000-token budget, so they were classified as main turns and got the six ACP tools added. PolyStrata answers that combination with a 400, and every Hindsight retain failed. Agent turns always carry tools, so this rule does not touch them.

The root cause is the classification, not the injection: a toolless structured-output request is a one-shot utility call, so the fix routes it through the existing #388 verbatim passthrough (the same treatment the #2500 server-tool utility call gets) rather than adding a new mechanism or changing the wire shape.

Tests

tests/side-request-isolation.test.ts:

tests/side-lane-invariants.test.ts: the #1440 (G) import allowlist admits the new pure predicate.

Locally, the six side-request suites (side-request-isolation, side-lane-truth-table, side-lane-invariants, websearch-side-request, dsh-title-side-lane, dsh-title-sidecar-handle) pass, tsc --noEmit is clean, and check:unused-exports / check:test-import-graph are clean. The full suite is left to CI.

We have run the same change in production on 0.1.208, patched into dist/index.js. Hindsight retains went from 400 to 200, and normal Hermes requests still get the ACP tools.

No config surface, kernel/, or wire-shape changes.

🤖 Generated with Claude Code

A request with no tools that asks for a JSON reply (response_format
json_schema/json_object, or text.format on the Responses wire) is a
utility call, not an agent turn. Child processes of a host inherit the
proxy through HTTP(S)_PROXY, and adding the ACP tools to their
extraction calls makes backends that refuse tools plus response_format
answer 400. Tool-carrying requests and an explicit main persona are
still main turns.

Fixes ranxianglei#5073

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ranxianglei ranxianglei changed the title fix: forward toolless structured-output requests as side requests [PR] fix: forward toolless structured-output requests as side requests Oct 28, 2026
…Output

The helper is only called by isSideRequest() inside the same module; no
other file imports it, so the unused-exports gate rejects the leading
export. Behavior is unchanged.
@ranxianglei ranxianglei added bug Something isn't working hermes 改动范围:内核之外的主机侧接线(src/agent 适配器、server 路由、注入拦截)/范围兜底/客户端标签 p2 scope/wiring labels Oct 29, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 — 按失败签名(toolless + response_format + 注入工具后 400 / Hindsight / hermes 代理继承)检索 open+closed issues 与 PRs,无既有条目。

标签: bug, hermes, scope/wiring, p2(特定条件下记忆抽取子调用被上游拒收;有绕行、不影响核心 agent 回合 → p2)。

审查进展(首报):

方向审核:正确。 根因在 isSideRequest() 分类门:toolless + 结构化输出请求属于 utility call,应走 #388 passthrough 逐字转发,而不是被注入 ACP 工具。修在决策点上,不是症状层打补丁;规则顺序核对无误(显式 persona > #2500 server-tool > #546 tools-veto > 新规则 > 预算启发式),agent 回合恒带 tools,不受影响。两个调用点(handle.ts:1003 persona 键解析、handle.ts:2092 #388 passthrough 决策)行为一致。

复现验证:

  • 红:master 代码 + PR 测试文件 → 恰好只有 2 个新增测试失败(36 tests / 34 pass);
  • 绿:PR 分支 → 六个 side-request 套件 76/76 通过,与作者描述一致;
  • 测试质量:正反双向行齐全(含 control),e2e 断言有牙(tools 缺失 + messages/response_format deepEqual 逐字)。

发现 1 处 CI 红(非 master 继承红): unused-exports 门禁报 INTERNAL_ONLY src/server/side-request.ts: requestsStructuredOutput — 新增函数被 export 但仅在文件内引用,且下游全部 test/e2e job 依赖该门禁而被 skip。本地已复现同一结果。

按「小问题直接修」,正在 PR 分支补一个标注 commit:①去掉多余的 export(门禁自身给出的处置);②给两处新注释补 #5073 编号锚点(对齐同文件其他规则的 house style)。推上去确认 CI 转绿后给最终八问结论。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复——失败签名(unused-exports 门禁报 requestsStructuredOutput)由本 PR 新引入的符号独占,本地在 PR head 复现确认;镜像缓存显示该 head 上其余 29 项检查全部绿/skip,非继承性失败,无需 merge ci-fixes。

标签:bug / hermes / scope/wiring / p2(前序会话已打好,复核一致:Hermes 车道请求分类缺陷,功能问题有绕行面)。

CI 的 unused-exports 红已在 PR 分支直接修复,push 完成(commit 7a29d546c),等 CI 重跑。

八问

  1. 是什么问题:CI 的 unused-exports 门禁红——本 PR 新增的辅助函数被导出了,但没有任何模块外的代码引用它。
  2. 什么原因导致的:src/server/side-request.ts 新增的 requestsStructuredOutput() 带了 export,而它只被同文件的 isSideRequest() 调用;全仓检索该符号仅出现在这个文件内(定义 + 调用各一处),测试走的是 isSideRequest 入口而非直接 import 这个辅助函数。门禁把「导出但无人引用」判为 INTERNAL_ONLY,拒绝合入。
  3. 影响范围与严重程度:只挡本 PR 的 CI 门禁,不影响任何运行时行为;严重度 = 构建门禁阻断(PR 不绿不能合并),无用户面影响。
  4. 怎么修复的:去掉函数前缀的 export,让它保持模块私有——定义、函数体、调用点一字未动,只改可见性。这是门禁给出的三种处置里唯一无损的一种(删函数会破坏功能,加 waiver 则给内部辅助函数开永久豁免,都不合适)。
  5. 是否有回归问题:无。逐点过:同文件唯一调用方不受影响(模块内引用不依赖 export);无任何其他文件/测试 import 此符号;不改任何阈值、时序、输出格式或错误处理路径。修复后本地重跑 node scripts/check-unused-exports.mjs 通过(✓ clean, 6 waived,与 master 基线一致)。完整测试套件按仓库纪律交给远程 CI 在 push 后的 head 上把关。
  6. 是否破坏缓存:不涉及——纯源码可见性修改,不触碰缓存、重试、游标或去重逻辑。
  7. 是否改了设计方向:不涉及。side-request 分类规则本身(标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 侧通道、[bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 带工具即主回合、新增的无工具+结构化格式判侧请求)全部原样保留。
  8. 是否引入了新的配置:不涉及。

判定:小修已闭环,等 CI 重跑;若全绿即可进入正常 review/合并流程(合并由人执行)。

Review supplement on 7a29d54 (ranxianglei#5074): every classification rule in this file carries its issue number as a comment anchor (ranxianglei#2500/ranxianglei#2503/ranxianglei#3149/ranxianglei#4438); the two comments added by ef508e9 did not, so the rule's provenance was not greppable. Comments only - no behavior change.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

重启后状态确认:unused-exports 修复已端到端闭环。

结论:CI 侧无任何遗留问题,PR 处于可 review 状态;合并由人执行(review/merge 是人工门禁)。本自动修复车道收工。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

最终结论(结构化八问)

  1. 是什么问题:Hermes 进程里继承代理的子进程(Hindsight 记忆守护)发出的「无工具 + 要求 JSON 结构化输出」的事实抽取请求,被 bili 当成主回合处理并注入了六个 ACP 工具,PolyStrata 对「结构化工具组合」直接 400,导致每次 retain 都失败。
  2. 什么原因导致的:isSideRequest() 分类门缺一条规则——它只有「显式 persona / [bug] Claude Code 的 WebSearch 子请求被当成主对话:nudge 基准被搜索的 usage 重锚,导致提前折叠;每次搜索还被注入 bili 工具 #2500 server-tool / [bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 带工具即主回合 / ≤200 token 输出预算启发式」四道判定,Hindsight 的抽取请求无工具且输出预算 64K,全部漏过,落入主回合路径。
  3. 影响范围与严重程度:仅限继承宿主代理、发 toolless+structured 请求的子进程(当前即 Hindsight retain);agent 回合恒带工具([bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546),完全不受影响。特定条件下功能失效、有绕行(作者已生产验证修复),p2。
  4. 怎么修复的:在分类决策点加一条规则——无工具且 response_format(chat 线)/text.format(Responses 线)type ∈ {json_schema, json_object} → 判为 side request,走 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 逐字透传(不注入任何工具)。规则顺序正确:显式 persona > [bug] Claude Code 的 WebSearch 子请求被当成主对话:nudge 基准被搜索的 usage 重锚,导致提前折叠;每次搜索还被注入 bili 工具 #2500 > [bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 tools-veto > 新规则 > 预算启发式。修在决策点上,不是症状层打补丁。
  5. 是否有回归问题:逐项审过既有行为——带工具请求仍是主回合([bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 未动)、显式 main/side persona 未动、[bug] Claude Code 的 WebSearch 子请求被当成主对话:nudge 基准被搜索的 usage 重锚,导致提前折叠;每次搜索还被注入 bili 工具 #2500 与预算启发式未动、两个调用点(persona 键解析 handle.ts:1003、透传决策 handle.ts:2092)行为一致。有意变更披露(旧→新):toolless+structured 请求从「走完整管道(注入工具)」变为「标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 逐字透传(不注入)」——这正是本 PR 要修的;附带边界:这类请求不再享受 preflight 压缩救援,payload 超窗时按 side request(max_tokens<=200)绕过 preflight 且不检查载荷体积,携带全量历史直转上游导致 400 #554 守卫本地 413 而非转发——这是 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 透传的设计契约,既有 side 请求同契约,非回归。未发现回归。
  6. 是否破坏缓存:不涉及——side 透传不触碰 kernel 状态与主会话前缀缓存;side 请求不认领 persona 锚([bug] dsh:side request 先到会抢走 persona 锚点,主会话被 fork 到 |sub:<fp>,原生 compress 永久失败 #2156 语义)保持不变。
  7. 是否改了设计方向:不涉及——在既有判定表上加一行,架构/边界/数据流未转向。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

验证与处置记录

判定:可合并,等 owner 合并(agent 不代合)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

重启后进度汇报:无阻塞——重启前工作已全部闭环,刚复核状态无变化。

@elight

elight commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

The four red lanes were master-red, not this change.

The branch tree predated the #5046/#5018 storage convergence (2026-10-30/31), so the merge preview ran the new unified-storage second-writer guard (StorageSecondWriterError, src/storage/store.ts:540) against the pre-convergence harness. Both failures are that one guard refusing a second writer to the same sessions/index.db:

  • #4982 e2e: draining same-lane predecessor + squatter → newcomer ladders instead of dying
  • hook e2e: a healthy proxy on ANOTHER port is never attached (static URL)

Fix: merged origin/master (e209109) into the branch (15573c3). The merged tree now differs from master by exactly this PR's own two files (+65 lines), so nothing about the side-request change is altered.

Verified locally on the merged tree:

  • tests/issue4982-draining-twin-ladder.test.ts — 7/7
  • tests/claude-native.test.ts hook e2e with ACP_TEST_CLAUDE_NATIVE=1 — pass
  • six side-request suites (side-request-isolation, side-lane-truth-table, side-lane-invariants, websearch-side-request, dsh-title-side-lane, dsh-title-sidecar-handle) — 77/77
  • tsc --noEmit — clean

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

收到,已对你的合入做了独立核验(不采信自述、逐项对过):

核验结果

  1. head 确认:PR head 15573c38 = 「Merge origin/master (e209109)」,且它压在我上一轮合入的 ci-fixes@06ad804ac(merge commit 61f295e7a)之上——两条收敛线都在树里。
  2. diff 范围确认:与 master@e209109b 的净差恰好只有本 PR 两个文件:src/server/side-request.ts +20/-0、tests/side-request-isolation.test.ts +45/-0,合计 +65/-0——与你的描述一致,side-request 逻辑未被任何合并改动。
  3. CI 现状(镜像缓存):新 head 上 30 项检查目前 0 失败,unused-exports 已绿(上轮去掉的多余 export 经多轮合并仍完好);此前红的 test 分片还在跑(13 pending)。

八问(本轮为核验轮)

  1. 是什么问题:上一轮红后你定位为 SQLite cache has no graceful degradation when the driver is unavailable: llm/stream throws `Cannot read properties of un | sqlite 缓存在驱动不可用时没有降级:llm/stream 每回合抛 Cannot read properties of undefined (reading 'prepare')(DSH/Electron 打包环境) #5046/decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018 存储收敛引入的第二写者守卫(StorageSecondWriterError)对旧 harness 的继承红,并自行合入 master 修复。
  2. 什么原因导致的:分支树落后于存储收敛,守卫对同一 sessions/index.db 拒绝第二写者——机制归属合理,且「diff 只剩两文件」这一事实本身就排除了本 PR 代码是变量。
  3. 影响范围与严重程度:仅 CI 门禁;无运行时行为变化。
  4. 怎么修复的:你合入 origin/master@e209109b;我未改动任何代码,只做了上述三项独立核验。
  5. 是否有回归问题:无新增回归面——净 diff 仍是原两文件;本地定向验证结果(issue4982 7/7、claude-native hook e2e、side-request 六套 77/77、tsc 干净)按你的环境为准,全量判定以 CI 重跑为准。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

标签:沿用 bug / hermes / scope/wiring / p2(本轮无新缺陷面,存储守卫家族在 #4599 在档)。

判定:结构核验全部通过,等 test 分片跑完;若全绿即可进入正常 review/合并流程(合并由人执行)。

@elight elight closed this Oct 31, 2026
@elight elight reopened this Oct 31, 2026
@elight

elight commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Re-triggered CI by closing/reopening this PR (no new commit; reopened fires the pull_request trigger in .github/workflows/ci.yml).

Status of the previous run (41242984508, head 15573c38): 13/15 lanes pass — the two originally-red tests (tests/issue4982-draining-twin-ladder.test.ts and the claude-native hook e2e) both pass on the merge. The two lane failures left were pre-existing flakes on master, not from this PR:

lane failing test same test on master?
test (ubuntu-latest, 22, 1) e2e: restart restores k̂ + usage anchor … (#2129) yes — failed on 9d53c22a (run 41206741942) and e209109b (run 41222746623) same day; e209109b passed that lane at 20:15
test (windows-latest, 22, 2) abort x proxy-openai-sse: client abort mid-stream destroys the upstream request timing-sensitive socket-destroy assertion; no source overlap with this PR

The PR's own diff on top of current master is exactly 2 files / 65 insertions (src/server/side-request.ts, tests/side-request-isolation.test.ts); merge-tree against origin/master is conflict-free and the six side-request suites plus tsc --noEmit are green on the merged tree.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

对「剩余两个红是 master 既有 flake」的判定做了独立取证(不采信自述):

核验结果

  1. ubu22-s1 / Restart loses measurement state: buildSession() omits stats fields buildRecord() persists (k̂, usage anchor, baseline origin, localInputEstimate) #2129(k̂ + usage anchor):日志级坐实。拉取了 master run 41222746623(head e209109b = 当前 master tip,分支未再动过)的失败 job 日志:not ok 959 - e2e: restart restores k̂ + usage anchor — the over-raw resend forwards without folds or an EMERGENCY nudge (#2129)——与本 PR 红的是同一测试、同一分片,master 自己就是红的。另一引用 run 41206741942(master)同一分片亦 failure(注:该 run 实际 head 为 8acc980c,你写的 9d53c22a 有出入,不影响结论)。
  2. win22-s2 / abort x proxy-openai-sse:直接读了 tests/wire-exit-matrix.test.ts:219 所在文件——全文 response_format/json_object/json_schema 出现 0 次、tools 出现 0 次。本 PR 的新规则只对「无工具 + 结构化格式」的请求改分类,该测试的请求两者皆无,分类与 wire 路径不受影响——「零源码交集」成立。
  3. diff 范围:master tip 仍是 e209109b(未移动),上轮已验证净差恰好两文件(+65/-0),继续成立。
  4. 新 run(close/reopen 重触发后):镜像缓存当前 0 失败、13 pending,跑完中。

八问(核验轮)

  1. 是什么问题:上一轮 13/15 过后,需判定剩余两个红是否属于本 PR。
  2. 什么原因导致的:两项均为 master 侧问题——Restart loses measurement state: buildSession() omits stats fields buildRecord() persists (k̂, usage anchor, baseline origin, localInputEstimate) #2129 测试在 master tip 自身跑挂(非确定性,同日同 sha 另有通过记录);abort 测试为时序敏感的 socket-destroy 断言,且与本 PR 无源码交集。
  3. 影响范围与严重程度:不影响本 PR 的正确性判定;属 master 侧 flake 噪音(体验/CI 效率层面)。
  4. 怎么修复的:本轮我未改代码,只做了上述四项独立核验;重触发由你完成(close/reopen,无新 commit)。
  5. 是否有回归问题:无——本 PR 净 diff 未变,逻辑未动。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

标签:沿用 bug / hermes / scope/wiring / p2(#2129 flake 属 master 侧,证据已同步 #4599,不在本 PR 立项)。

判定:继承 flake 归属成立(日志级证据);等新 run 出结果——若 ubu22-s1 再次命中 #2129,那是 master/ci-fixes 哨兵通道的事,不阻塞本 PR 的 review。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Verdict: APPROVE — correct, minimal, teeth-verified fix; regression audit clean.

What I verified (independent of the issue-side analysis)

Correctness. The new predicate requestsStructuredOutput (src/server/side-request.ts:80-86) matches exactly the two documented structured-output carriers — OpenAI chat-completions response_format.type ∈ {json_object, json_schema} and Responses-wire text.format.type — and can only fire on a toolless request, because its call site (side-request.ts:106) sits AFTER the #546 tools veto (line 100). Explicit host intent keeps precedence: "title" claims at line 91, requestAgent === "main" vetoes at line 92, both before the new rule. Matched requests then ride the existing #388 verbatim side passthrough: nothing injected, kernel state untouched, no usage sampling.

Tests have teeth. Ran tests/side-request-isolation.test.ts locally at PR head: 36/36 pass. Negative control: checked out master's side-request.ts into the same tree and re-ran → exactly the two new tests fail ("isSideRequest: a toolless structured-output request…" / "e2e: …forwarded without injected tools"), 34/36 pass — confirming the author's fail-on-master claim. The suite pins both gate directions (positive rows + {type:"text"}/null/bare-string negatives + #546-precedence row + explicit-main row), and the e2e control case pins that a toolless NON-structured large-budget request still gets tools injected — the main-turn path is not over-broadened.

Regression audit — existing behaviors on the touched paths:

  • explicit side persona ("title") → unchanged
  • explicit "main" persona → unchanged (vetoes before the new rule; unit-pinned)
  • #2500 server-tool utility call → unchanged (checked before)
  • any tool-carrying request → main turn, unchanged (#546 veto precedes; unit-pinned)
  • toolless NON-structured request (any budget) → main turn, unchanged (e2e control pinned)
  • ≤200-token budget heuristic → unchanged outcome
  • session keying: this class now resolves VERBATIM instead of through the persona-order resolver — consistent with the #2156 doctrine that side requests never claim an anchor

No wire-shape change, no config surface, no kernel/, no persistence change. CI green (mirror cache: failed 0 at head 15573c3).

Behavior change (intended, disclosed)

Old: a toolless request carrying response_format {json_object|json_schema} (or Responses text.format) was classified as a MAIN turn → proxy mode injects the six ACP context tools next to response_format → strict backends reject the pair outright (HTTP 400); lenient backends let the model call context tools mid-extraction-task. New: classified as a SIDE request → forwarded verbatim, zero injection, kernel untouched. This is the fix itself (#5073); every other classification is unchanged per the audit above.

Informational finding (non-blocking)

The side-lane decision happens AFTER restoreOutputBudget runs — src/server/handle.ts:1988 gates only on !demotedSide && !serverToolUtility, not on isSideRequest. A toolless structured call with max_tokens=64000 therefore still records outputBudgetHighWater=64000 on its resolved session before diverting — the same seeding class #1897/#2500 skip for their side shapes. This is NOT a regression introduced by this PR: on master the identical request was a full main turn recording the same high-water (plus snapshot/usage pollution), so the PR strictly improves things; and in the reported topology Hindsight gets its own pfa- session (system-fingerprint fork), so there is no reattach risk at all. Companion open PR #5090 additionally skips restoreOutputBudget for this class and adds an honest log label — if this PR ships, cherry-picking that hunk closes the residual corner (one session id shared between main turns and a structured utility whose budget exceeds the provider cap, plus later starvation). Flagging for the owner, not blocking on it.

Duplicate notice

PR #5090 (opened 2026-10-29, after this branch already existed) fixes the same issue #5073 via the same mechanism plus the extra hardening above. Per 先来后到 this earlier PR takes precedence; the owner should pick one and close the loser (agents may not close PRs). Both are rebased onto current master and green.

中文结构化八问

  1. 是什么问题:继承宿主代理的子进程(如 Hermes Hindsight)发出的「无工具+结构化输出」请求被当成主回合处理,bili 注入的 6 个 ACP 工具与 response_format 同线出现,严格后端直接 400,此类调用全挂。
  2. 什么原因导致的:isSideRequest() 分类器缺少「无工具+结构化输出载体」信号;大 max_tokens(64000)又打穿了 ≤200 的预算启发式,请求落入主管道并被注入工具。
  3. 影响范围与严重程度:所有经 bili 代理、无工具且带 json_object/json_schema(或 Responses text.format)的调用在严格后端上全部失败;带工具的正常 agent 回合不受影响——特定调用类不可用,非会话丢失/缓存泄露,p2。
  4. 怎么修复的:分类器里加一个结构性谓词(无工具+两个已记录的结构化载体之一),复用既有 #388 逐字旁路;不引入新机制,不动 wire/config/kernel。
  5. 是否有回归问题:对触碰路径逐项清点(见上 audit),除有意降级外全部保持;本地负向控制确认仅 2 个新测试翻转。唯一残留是 high-water 记账(master 既有行为,非本 PR 引入,#5090 另行补强)。
  6. 是否破坏缓存:不涉及——逐字转发不改任何内核状态;出站前缀比注入工具时更稳定。
  7. 是否改了设计方向:不涉及——只匹配两个有证据的载体(legacy 裸字符串 response_format、Gemini generationConfig 刻意不匹配),符合 evidence-per-client 纪律。
  8. 是否引入了新的配置:不涉及。

判定:可合(APPROVE)。核心修复正确且经负向控制验证,回归清点干净,diff 仅 2 文件 +65/-0 全部切题;high-water 残留与 #5090 的重复关系已如上披露,取舍由 owner 定。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) Review 完成:已 APPROVE(head 15573c3)——负向控制验证测试有牙(master 分类器下恰好 2 个新测试红)、回归清点干净、diff 仅 2 文件 +65/-0;行为变更已披露(无工具+结构化输出请求从主回合降级为 #388 逐字旁路);非阻塞发现:high-water 记账残留(master 既有,#5090 有补强 hunk);注意与 #5090 重复(先来后到本 PR 优先,关哪个由 owner 定)。

…i#546/ranxianglei#388/ranxianglei#2500

Ship the classification as the exported isStructuredOutputCall predicate with
the ranxianglei#546 no-tools veto built in, so handle() can consult it independently of
isSideRequest and skip restoreOutputBudget for the call — its 64000 budget
sizes a utility response, not a main turn, and must not seed
outputBudgetHighWater (ranxianglei#1897/ranxianglei#2500 class).

Give the ranxianglei#388 side passthrough an honest log label, and extend the e2e to
assert kernel state, stats, snapshot, request counter and high-water are all
untouched, mirroring the ranxianglei#2500 suite. The new high-water assertion fails
without the restore skip and passes with it.
…request

Union of intent resolved by hand in two places: the side-request import line
and the resolveSideLane label ternary (master's ranxianglei#5656 isDshSingleShotSidecar
alongside this branch's ranxianglei#5073 isStructuredOutputCall), plus the ranxianglei#1440 (G)
import-allowlist comment and set. tsc clean; the eight side-lane suites pass
84/84 on the rebased head.
Comment thread src/server/handle.ts Outdated
// #2170 measure 1: the decision itself is resolveSideLane() (pure,
// truth-table-tested); demotedSide ⊆ lane==="side" by construction.
const sideLane = resolveSideLane({ countTokens, responsesCompact, protocol, stripApplied: demotedSide, sideIntent, requestAgent, sideLabel: serverToolUtility ? "server-tool utility call (#2500)" : dshTitleSidecar ? "dsh title-gen sidecar (#2503)" : dshReviewSidecar ? "dsh auto-review sidecar (#4438)" : ccTitleSidecar ? "claude-code title-gen sidecar (#5135)" : undefined });
const sideLane = resolveSideLane({ countTokens, responsesCompact, protocol, stripApplied: demotedSide, sideIntent, requestAgent, sideLabel: serverToolUtility ? "server-tool utility call (#2500)" : structuredOutputUtility ? "structured-output utility call (#5073)" : dshTitleSidecar ? "dsh title-gen sidecar (#2503)" : dshReviewSidecar ? "dsh auto-review sidecar (#4438)" : ccTitleSidecar ? "claude-code title-gen sidecar (#5135)" : undefined });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof. I don't love that our agents decided to have nested ternaries! That's an ugly practice!

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Verdict: APPROVE — the new head (e872e74) implements exactly what the prior review flagged as the single non-blocking finding, and everything else holds.

What changed since the prior review (a828e59)

The author addressed the informational finding directly:

  • private requestsStructuredOutput → exported isStructuredOutputCall(parsed) with the #546 no-tools veto built INTO the predicate (src/server/side-request.ts:88-90), mirroring isServerToolUtilityCall, so a caller consulting it independently can never demote a tool-carrying turn.
  • handle.ts:1982 now computes structuredOutputUtility; the gate at handle.ts:1996 becomes if (!demotedSide && !serverToolUtility && !structuredOutputUtility) — the utility's 64000 budget no longer seeds outputBudgetHighWater (the #1897/#2500-class residual I flagged).
  • Honest log label "structured-output utility call (#5073)" added to the resolveSideLane sideLabel chain (handle.ts:2180); mutually exclusive with the server-tool label (that shape requires tools, this one vetoes them).
  • Tests: new unit rows pin the predicate's self-contained veto (tool-carrying → false, {type:"text"}/null/non-object → false); a resolveSideLane row pins the label AND byte-stability of the historical reason strings when no label is passed; the e2e now asserts kernel state / stats / snapshot / request counter / high-water are all untouched, with the high-water assertion failing without the restore skip (author's claim — independently confirmed below).
  • Barrel export in src/server.ts + side-lane-invariants allowlist updated accordingly.

Verification (independent)

  • Local at head e872e74: tests/side-request-isolation.test.ts + tests/side-lane-invariants.test.ts → 53/53 pass; npm run typecheck clean; zero stale references to the old predicate name.
  • Negative control: checked out base (bfabcd1) src/server/handle.ts into the same tree → exactly ONE failure: the extended e2e, expecting high-water 1024, actual 64000 — i.e. the restore-skip is load-bearing and the test has teeth. Restored → green again.
  • CI (mirror cache, head e872e74): 30 checks, failed 0, pending 0.

Regression audit (delta vs prior review)

  • Tool-carrying requests (any budget/format): unchanged — the veto now lives inside the predicate, unit-pinned (tools: [{}] → false).
  • All other side classes (dsh title/review, cc-title, server-tool, ≤200 heuristic, explicit personas): untouched code paths.
  • Log lines: new label only for the new class; historical reason strings byte-stable (unit-pinned).
  • Barrel/invariants: additive only.
    Round-1 audit conclusions (persona precedence, #546 ordering, verbatim keying per #2156, passthrough semantics) all still hold — the matching logic is unchanged, only name/export/veto-placement moved.

Behavior change (intended, disclosed)

Old (master): a toolless response_format {json_object|json_schema} (or Responses text.format) request was a MAIN turn — six ACP tools injected beside response_format (strict backends 400) AND its large max_tokens seeded outputBudgetHighWater. New: classified SIDE — forwarded verbatim via #388, zero injection, kernel state/stats/snapshot/counter untouched, and its budget no longer seeds the high-water (restoreOutputBudget skipped, #1897/#2500 parity). Both halves are the fix plus the hardening requested in the prior review.

Non-blocking note — one line of lockfile churn (fix prepared, could not be pushed)

The master-merge commit rewrote one metadata line in package-lock.json (dropped "hasShrinkwrap": true from the @earendil-works/pi-coding-agent dev-dep entry). Unrelated to the fix. I prepared a one-line revert commit (efa3f384e) but cannot land it: the head branch lives in the author's fork, which this account has no write access to (the repo 404s for it). Functionally inert for this project (npm ci resolves identical versions; the package is aliased to a stub in the bundle), so this does NOT block — but please drop that line before merging (or grant ranxianglei push on the fork and I'll land it).

Duplicate notice (unchanged)

PR #5090 fixes the same issue #5073 via the same mechanism; the two have now converged to near-identical shape. Per 先来后到 this earlier PR takes precedence; the owner picks one and closes the loser (agents may not close PRs).

中文结构化八问

  1. 是什么问题:继承宿主代理的子进程(Hindsight)的「无工具+结构化输出」调用被当主回合处理——注工具致严格后端 400,且其大预算污染 outputBudgetHighWater。
  2. 什么原因导致的:分类器缺「无工具+结构化载体」信号、大 max_tokens 打穿 ≤200 启发式;且旁路判定晚于 restoreOutputBudget,预算记账先于分流发生。
  3. 影响范围与严重程度:该类调用在严格后端全挂(p2,特定调用类不可用);high-water 污染为窄角场景(同一 session id 混用主回合与该类调用+预算超 provider 上限+后续饥饿恢复)。
  4. 怎么修复的:导出自含 #546 否决的结构化谓词(对齐 #2500 server-tool 模式),isSideRequest 复用之走 #388 逐字旁路;handle() 独立查询该谓词跳过 restoreOutputBudget 记账;日志加诚实标签。
  5. 是否有回归问题:无——带工具请求、其余 side 类、显式 persona、历史日志 reason 串逐项清点保持并有测试钉住;本地负向控制确认 restore-skip 有牙(摘掉后恰好 1 个 e2e 红)。唯一残留是 lockfile 一行漂移(非功能,见上,请合前删掉)。
  6. 是否破坏缓存:不涉及——逐字转发不改内核状态,e2e 钉住 state/stats/snapshot/counter/high-water 全部不变。
  7. 是否改了设计方向:不涉及——谓词匹配逻辑与上轮一致,仅改名/导出/否决内置;只认两个有证据的载体(evidence-per-client)。
  8. 是否引入了新的配置:不涉及。

判定:可合(APPROVE)。核心修复+上轮发现的高水位加固均已落地并经独立验证;仅剩 lockfile 一行漂移待作者合前删除(非阻塞)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) 复审完成(head e872e74):APPROVED(review #5790378937)——作者新提交 a828e59 已落地一轮复审指出的高水位加固(谓词自含 #546 否决+跳过 restoreOutputBudget+诚实日志标签);本地定向验证 53/53 绿、负向控制确认新 e2e 有牙、typecheck 干净、CI 30/30 全绿。唯一残留:master 合并带入的 package-lock 一行漂移(hasShrinkwrap)——作者 fork 无写权限无法代推,已在 review 中请作者合前删除(非阻塞)。重复 PR #5090 仍待 owner 二选一。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 复审完成(head e872e74):APPROVED —— review #5790378937。

做了什么:作者新提交 a828e59 恰好落地了一轮复审指出的唯一非阻塞发现(谓词导出为自含 #546 否决的 isStructuredOutputCall、handle() 跳过 restoreOutputBudget 记账、诚实日志标签、e2e 扩展钉住 high-water)。我独立复核:本地定向套件 53/53 绿 + 负向控制确认新 e2e 有牙(摘掉 restore-skip 恰好 1 个红)、typecheck 干净、CI 镜像缓存 30/30 全绿。回归审计:带工具请求/其余 side 类/显式 persona/历史日志 reason 串逐项保持。

两个待 owner 事项:① master 合并带入 package-lock 一行漂移(hasShrinkwrap),修复 commit 已备好但作者私有 fork 无写权限无法代推——已在 review 中请作者合前删除(非阻塞);② 重复 PR #5090 同机制同 issue,先来后到本 PR 优先,请 owner 二选一(agent 不关单)。

@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6482 (merged) — closing as superseded.

@ranxianglei ranxianglei reopened this Nov 14, 2026
ranxianglei pushed a commit to Louie0806/billion-context that referenced this pull request Nov 14, 2026
…Output

The helper is only called by isSideRequest() inside the same module; no
other file imports it, so the unused-exports gate rejects the leading
export. Behavior is unchanged.

(cherry picked from commit 7a29d54)
ranxianglei pushed a commit to Louie0806/billion-context that referenced this pull request Nov 14, 2026
Review supplement on 7a29d54 (ranxianglei#5074): every classification rule in this file carries its issue number as a comment anchor (ranxianglei#2500/ranxianglei#2503/ranxianglei#3149/ranxianglei#4438); the two comments added by ef508e9 did not, so the rule's provenance was not greppable. Comments only - no behavior change.

(cherry picked from commit 17e82b7)
ranxianglei added a commit to Louie0806/billion-context that referenced this pull request Nov 14, 2026
…nion in the lane-invariant pins

The 5074 pick concatenated the pick-side comment lines onto the master-side
comment of the (G) pin without newlines, commenting out the test( line and
breaking the file.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Acknowledged — verified before replying: batch PR #6482 merged 2026-11-14T01:11Z, and current master (36a04a7986) carries the fix in both src/server/side-request.ts (exported isStructuredOutputCall) and src/server/handle.ts (the restoreOutputBudget skip) — so this PR is indeed fully superseded.

Left open for you to close (agents don't close): this PR #5074 and its duplicate #5090. No further action needed from my side — the lockfile line I flagged was moot once the batch landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hermes 改动范围:内核之外的主机侧接线(src/agent 适配器、server 路由、注入拦截)/范围兜底/客户端标签 p2 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hermes lane: proxy adds ACP tools to toolless structured-output requests from child processes, which strict backends reject (400)

2 participants