Repository navigation
fix: extend strict-echo repair to the Responses wire (#1479) - #1482
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1426-pr.1482.3b0e557This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1482.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Picking up this PR review. Fetched
Running the full pass now: original-issue (#1479) direction check → regression inventory on the touched paths → code/invariant review → test-quality check → local pre-flight (typecheck/test/build). Will report a per-behavior verdict + merge recommendation next. |
[bot] 🏷 PR #1482 审查结论:可以合并(需人工合并,不适用 auto-merge) ① 方向(原 issue #1479) — 根因确认成立。#762 的 strict-echo 修复只覆盖 chat-completions( ② 回归审查(逐项既有行为 + 结论)
③ 代码审查
④ 测试有效性
⑤ diff 整洁度:5 文件全部与本 PR 目的直接相关,无跑题文件、无生成物/锁文件连带、无大段空白重排;无 version bump(content 分支正确);config surface 零变更。✓ 本地 pre-flight(PR head 新鲜基座验证(master 已前进 5 个 commit,含并发的 #1474 行为变更披露(策略要求)
自动合并判定:按 §7.4,此 PR 属跨两种压缩模式的 wire/message-shape 变更(向出站 Responses body 注入 item)→ 必须人工合并,不适用 auto-merge。但所有检查在新基座上全绿、diff 干净、引用 遗留/已知限制(非 bug,不另行立项):空 reasoning 对 DeepSeek thinking 是被接受的形式(hermes-agent #15527);若未来出现要求回传真实 reasoning 内容而非"存在性"的网关,空 echo 不满足——但没有实证案例,且 learn-on-400 只对已因缺 reasoning 而 400 过的网关生效,故不构成本 PR 缺陷。选项 2(fold 保留 provider 真实 reasoning)是更重的 kernel-view 手术,选项 1 已彻底解决报告的 400,维持不实现。 需要的话我可以把已验证的 rebase 版本 force-push 到 中文摘要:修复了 strict-echo 修复缺失 Responses 线(及 loop 重试路径)导致的 fold 后 |
#762's blank-echo injection only covered chat-completions bodies: normalizeStrictEchoReasoning ran in prepareOpenai only, and normalizeStrictEchoBody no-opped on Responses bodies (input[]). After a compress fold, a Responses-wire request whose assistant run lost its reasoning item was rejected by strict-echo gateways with reasoning_content_missing, while the #684 canary simultaneously fired on healthy [reasoning, message, function_call] turns (immediate-precedence check). - strict-echo.ts: new normalizeStrictEchoResponsesInput injects one blank {type:"reasoning", summary:[{type:"summary_text", text:""}]} item at the start of each assistant run carrying a tool call but no reasoning item (same gate as the chat path: isStrictReasoningEcho + at least one reasoning item present); normalizeStrictEchoBody now patches input[] as well as messages[]. - server.ts prepareResponses: repair rebuiltInput before forwarding, ahead of the canary so a repaired body does not self-fire it. - loop core.ts: every buildRequest body (main re-request plus the truncation/degenerate retries, which were never normalized) goes through the same gate. - canary warnResponsesReasoningPairs: immediate-precedence -> run-based counting, reporting the orphaned function_call ids. Behavior change: it now fires LESS often - the false positives on healthy turns are gone; log prefix 'reasoning-pair-violated' kept for grep continuity. Fixes #1479
34b2970 to
e28746c
Compare
- custom_tool_call_output joins the run-item set in normalizeStrictEchoResponsesInput (and the test helper): an interleaved [call, output, call] layout no longer splits a reasoning-bearing run into a false orphan (latent today — bili and codex emit grouped layouts — but the same class the PR repairs). - WIRE_RULES gains WC-009 (responses: thinking-mode providers reject resent assistant runs with no reasoning item, 400 code 11155) with a validation-parity clause in validateResponsesBody and a gate probe — the permanent-ledger discipline (#762/#1479 provenance).
|
Deep-review verdict: MERGEABLE — plus two review fixes landed at
Review evidence (delegate + verified): repair is insert-only and reference-preserving; #283 intact (insert-before, never append); idempotent; all four loop retry sites normalized (chat-wire retries were previously unnormalized too — bonus fix); both compression modes covered ( Gates on Non-blocking follow-ups noted for the record: incremental-mode ( |
…1479) Review follow-up to 1d5ff03: the inRun-set completion updated the repair (src/strict-echo.ts), the e2e helper, and the WC-009 parity fake, but missed the runtime canary warnResponsesReasoningPairs (src/server.ts). There a custom_tool_call_output still broke the run, so an interleaved [reasoning, function_call, custom_tool_call_output, function_call] split into a false orphan: the canary would fire reasoning-pair-violated on a healthy turn while the repair correctly stayed silent, and it would disagree with the WC-009 fake. Add custom_tool_call_output to the canary in-run no-count branch (mirrors the other three sites) + a regression test pinning canary/repair/WC-009 parity (mutation-verified: reverting the line reddens the test). Green: typecheck / 2921 pass 0 fail 12 skip / build.
[bot] 🏷 复核 先确认你落的两个修复都正确:
但复核发现修复①只改了 4 处 run 定义里的 3 处,漏了运行时哨兵。 全仓只有两处真正建模"strict-echo assistant run":repair( 已在分支上直接补掉(commit
基座新鲜度:PR 现在基于 v0.1.160( 结论:仍为 MERGEABLE(按 §7.4,wire/message-shape 变更跨两种压缩模式 → 人工合并,不适用 auto-merge)。两处落地的修复正确,我补上的哨兵遗漏也已修好并验证,canary/repair/WC-009 现完全一致。 中文摘要:复核了你落的两个修复(repair inRun 补全 + WC-009 入账)均正确,但发现修复①漏改了运行时哨兵 |
What & why
#762's strict-echo repair was chat-completions-only:
normalizeStrictEchoReasoningran inprepareOpenaionly;normalizeStrictEchoBody(the loop re-request path) guarded onArray.isArray(body.messages)and no-opped on Responses bodies (input[]);prepareResponsesnever normalized at all.So after a compress fold, a Responses-wire request whose assistant run lost its reasoning item went out un-repaired and strict-echo gateways rejected it with
reasoning_content_missing(issue log: 7/7 rejections were round-2 re-requests right after a fold;strict-echo: injectedfired 0x whilereasoning-pair-violatedfired 798x). Meanwhile the #684 canary used an immediate-precedence check that also flagged healthy[reasoning, message, function_call]turns — most of that 798x noise.Changes
normalizeStrictEchoResponsesInput(input, enabled, log, sessionId): walks the flat input as assistant runs (reasoning/message(assistant)/function_call/custom_tool_call/function_call_output); for each run carrying ≥1 tool call and 0 reasoning items it injects one blank{type:"reasoning", summary:[{type:"summary_text", text:""}]}item at the run start. Same gate as the chat path:isStrictReasoningEcho(learned 400 flag or deepseek origin/model) and at least one reasoning item present anywhere (thinking-session criterion — non-thinking sessions stay byte-identical). No-op returns the same array reference.normalizeStrictEchoBodynow patchesinput[]as well asmessages[], so the single loop call site covers both wires.prepareResponses— repairsrebuiltInputbefore forwarding, gated by the sameisStrictReasoningEcho(session, upstreamOrigin, modelIdOf(parsed)), ordered ahead of the canary so a repaired body cannot self-fire its own sentinel (same rationale as the DeepSeek thinking mode: residual "reasoning_content must be passed back" 400 on the first post-fold request (0.1.109 / acp-kernel 0.0.69) — the forwarded body is not persisted #762 comment inprepareOpenai).buildRequestbody now goes throughwithStrictEchoRepair, including the truncation-continuation and degenerate-turn retries, which were never normalized even for the chat wire (same root cause, closed here).warnResponsesReasoningPairs— rewritten from immediate-precedence to run-based counting (a run with tool calls but no reasoning = violation), reporting the orphanedfunction_callids per issue option 3.Behavior changes (old → new)
reasoning-pair-violatedsentinel fires LESS often: old = everyfunction_callnot immediately preceded by a reasoning item (flagged healthy[reasoning, message, function_call]turns — the issue's chronic-noise complaint); new = runs with tool calls but no reasoning item at all. Log prefix kept for grep continuity; message format changed to name the offending call ids.Config surface
None. No config fields added/renamed/re-semantics'd; the existing
isStrictReasoningEchogate (learned flag + deepseek statics) is reused unchanged.Tests
tests/reasoning-echo.test.ts: unit coverage for the new injector (disabled/no-reasoning/healthy → same array ref; orphan run → exactly one blank at run start, all other items reference-equal, input not mutated; multi-orphan;normalizeStrictEchoBodyoninput[]), plus the canary tests rewritten for run-based semantics (healthy turns silent, orphaned runs warn + named).tests/loop-strict-echo-responses.test.ts(new): full arc through the real proxy on the Responses wire — request 1 ships the orphan run and 400s (sentinel fires once, pre-repair), the 400 learns the flag, request 2's main-path forward carries the blank echo, and the loop re-request (whose compress ack pair forms its own run) carries it too; asserts zero orphan runs in both repaired bodies.Pre-flight on this head:
npm run typecheckclean ·npm test2918 pass / 0 fail / 12 skip ·npm run buildOK (dist-import-annotations OK).Fixes #1479