Repository navigation
kernel: teach the strict-JSON serialization contract in the canonical compress copy (#2587) - #2622
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2855-pr.2622.2c16969This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2622.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 结论:方向正确、代码自洽,但当前 head 有 2 个合入前阻塞项——暂不可合。 先对齐编号:GitHub PR 是 #2595(head 结构化八问1. 是什么问题:把 kernel 默认 compress 工具/nudge 文案重写为 strict-JSON 契约(修 #2587——#2579 实测坏 JSON 的提示层诱因本体)。7 处规范面统一改为「参数按 strict JSON 解析,未加引号的值 / 字符串内未转义 2. 什么原因导致(两个阻塞项的根因):
3. 影响范围与严重程度:功能不坏。已静态排除确定性文案回归——master 上没有 host override 层(grep 无 4. 怎么修的(建议动作):① rebase 到当前 master;② 5. 是否回归问题:逐项过——schema 结构(anyOf array|string)、 6. 是否破坏缓存:机制不变(缓存/重试/游标/去重键均未触碰)。措辞切换对长会话是一次性 system 块改写(前缀缓存一次性失效)——文案修复固有后果,#2588 与本 PR 谁先合谁触发这一次,后合者字节相同不再二次触发。 7. 是否改设计方向:无转向。纯文案层,方向与 #2579/#2588 完全一致(strict-JSON 前置、对象数组优先)。 8. 是否引入新配置:无。无新 env/config/默认值。 判定暂不可合。 门槛:red 的 CI 必须先转绿。最可能的红因是环境/注册表抖动——master 在本分支切出之后才合了 #2616(ci-npm-registry-retry),本 PR 那次 CI 很可能撞上修复前的注册表抖动;rebase 推新 head 会触发含 #2616 的全新一轮 CI,是判定红因的权威依据,若仍红再定向抓具体失败测试。 我现在就代为执行 ① rebase + ② 版本补 0.0.113(机械、安全、单行冲突),force-push 回 PR 分支触发新 CI,然后按 CI 结果跟进。 |
[bot] 🏷 已执行机械修复并推回 PR 分支。 上文八问结论不变(暂不可合→现已解除两个阻塞项的代码侧部分),这里是执行记录: 做了什么
核对结果(vs 当前 master)
剩余门槛(CI)
一句话:代码侧两阻塞项已清,现在只等 |
|
Windows CI triage for acbea29 (and fix c8a4178) The two red
Root cause — the #1305 class, exactly as documented in
Fix: c8a4178 adds one attribute line Ubuntu + all e2e lanes were green on acbea29; the kernel change itself (strict-JSON compress copy, kernel 0.0.113) has no platform-specific surface. |
… compress copy (#2587) The kernel-default compress surface framed the string form as 'plain text … no JSON structure, no escaping' with UNQUOTED ref-header examples ('m00150–m00220 optional topic'). Models then streamed content values that are not valid JSON — ~4% of compress calls on strict-JSON hosts (#2579/ #2580): bare unquoted values with real newlines, or unescaped quotes inside strings — and the host rejects the tool input, failing the WHOLE turn. Canonical text now states the contract on every surface the model sees: tool description, content param, line-form item, system-prompt TOOLS section, ONE_CALL_HINT, the gentle-nudge hint line, and the lean pack: - strict JSON parsed before anything runs; unquoted values or unescaped quote/newline inside any string fail the whole call - PREFERRED flips to the object-array form with a pasteable skeleton ({"content":[{"startId":"m00122",…}]}) — short strings, fixed shape - the ONE-string form stays accepted but is now described as what it is: a quoted JSON string with header lines and markdown inside the quotes - all 'plain text / no JSON escaping / no JSON structure / lossy gateways' phrasing deleted (it taught exactly the broken output) Schema unchanged (anyOf array|string); parser unchanged; both forms still accepted. kernel 0.0.112 → 0.0.113. Wire-contract goldens regenerated — description text only, structure byte-identical. Pinned tests updated to the new contract assertions; fixture refreshed.
c8a4178 to
dd83e91
Compare
[bot] 🏷 先纠正一个我的失误:前两轮我把 PR #2595(分支 你的 Windows 诊断我逐条核实过,成立:
但有关键新事实:这个 CRLF 修复已经合进 master 了(在你这条 triage 之前/同期由另一路完成):
另有一个必须处理的问题:#2587 现在有两个 open PR——#2595 与 #2622 是同一改动的两份实现,都基于旧 base 关键判断(浓缩):
建议(请拍板):
第 2、3 步是纯机械操作,我可立即执行并 force-push 到 |
|
Rebased onto master 7c993f9 (head dd83e91): dropped my earlier Local re-verify after rebase: kernel suite 1284/1284; root first-sight-drain-wire + one-call-payload + wire-contract 23/23. CI on dd83e91 all green (main CI + all e2e lanes). Diff is 13 files +67/−66: semantic change = 7 copy spots in |
[bot] 🏷 已独立复核,#2622 现在可合并。 我拉了新 head 结构化八问(对本 PR 的最终结论):
判定:可合并——CI 26/26 独立核实全绿、分支干净 rebase、diff 收敛到「每行都服务于 #2587」。合并动作按规矩留给你(human-only)。 剩一件收尾:重复 PR #2595 仍是 open(同一 #2587 的另一份实现,head |
|
Closing in favor of a redo with a minimal-diff approach: keep the original ONE-string line-form wording and swap only the JSON-poisoning phrases ('no JSON escaping', 'plain text survives lossy gateways best') for short escape hints — no wholesale rewrite. The strict-JSON root-cause fix (#2587) is preserved; #2591 salvage stays as the backstop. |
…pe hints (ranxianglei#2587) Minimal-diff redo of ranxianglei#2622 per review: the ONE-string line-form stays the PREFERRED shape everywhere; only the phrases that taught models to write invalid tool-call JSON are replaced, each delta under ten words: - compress-tools.ts content param: '(plain text survives lossy gateways best; …)' -> '(a valid JSON string: internal quotes \" and newlines \n; …)' - compress-tools.ts line-form entry: 'verbatim (no JSON escaping)' -> 'verbatim (a JSON string: quotes \", newlines \n)' - COMPRESS_TOOL description: '(no JSON structure, no escaping; …)' -> '(a valid JSON string — internal quotes \", newlines \n; …)' - TOOLS system-prompt example: '(plain text survives lossy gateways best)' -> '(a valid JSON string: \" and \n)' - nudge ONE_CALL_HINT / gentle 💡 line / lean pack: 'plain string' -> 'JSON-escaped string'; '(most robust through lossy gateways)' -> '(a valid JSON string: \" and \n)' Wire-contract goldens + prompt-function-default fixture regenerated. kernel 0.0.112 -> 0.0.113.
kernel-change: this PR modifies
kernel/**(canonical compress copy). Kernel version bumped 0.0.112 → 0.0.113; wire-contract goldens regenerated viascripts/update-wire-contract-goldens.ts; both test layers green (npm --prefix kernel test1284/1284, affected root suites + tsc clean). Implements #2587 (owner-directed: closes the interim-host-override path in favor of the canonical fix — #2588 was closed unmerged by owner decision). Root cause evidence: #2579, #2580.What changes
The kernel-default compress surface framed the string form as "plain text … no JSON structure, no escaping" with unquoted ref-header examples (
'm00150–m00220 optional topic'). Models then streamed content values that are not valid JSON — ~4% of compress calls on strict-JSON hosts: bare unquoted values with real newlines (A-class), or unescaped quotes inside strings (B-class) — and the host rejects the tool input atmessage_stop, failing the whole turn before any lenient parsing runs. On the Anthropic lane the tool channel is the only channel (text-marker parsing is responses-only), so the tool description's advice was actively harmful there.Seven canonical spots now state the serialization contract explicitly:
kernel/src/compress-tools.tsCOMPRESS_PARAMETERS.properties.content.description"written\", newline written\n; array (PREFERRED) vs ONE-string both described as JSON valueskernel/src/compress-tools.tsline-form item\", newlines written\n"kernel/src/compress-tools.tsCOMPRESS_TOOL.description{"content":[{"startId":"m00122","endId":"m00127","summary":"...","topic":"..."}]}; string form kept but described as a quoted JSON string; flat form unchangedkernel/src/compress-tools.tssystem-prompt TOOLS sectionkernel/src/nudge-text.tsONE_CALL_HINTkernel/src/nudge-text.tsgentle-nudge 💡 linekernel/src/packs.tsleanparamDescriptions.contentUnchanged: schema structure (
anyOfarray|string), the parser (both forms, plus lenient recovery, still accepted), tool names, all other prompts. The host serves kernel text on every surface (wire injection, plugin manifest → MCP, opencode native/V2), so this single change lands everywhere with no override layer — independent acp-kernel consumers get it too.Golden regeneration rationale
tests/golden/wire-contract/{bili,kernel,manifest-default,manifest-optin}.json— 48 description lines swapped, structure byte-identical, zero occurrences of the old phrasing remain (ONE plain string,no JSON escaping,no JSON structure,lossy gateways— repo-wide grep clean outside this commit message).Test updates (pinned-wording tests)
kernel/tests/compress-schema-contract.test.ts: "stringified-array form documented" → asserts the strict-JSON contract ("strict JSON rule"); header examplem00150–m00220still pinned.kernel/tests/nudge-text.test.ts: static-hint signature "ONE call, ONE string" → "never split the batch across separate calls" (the hint's invariant tail — unambiguous against the gentle line's legitimate "in ONE call —" phrasing).kernel/tests/fixtures/prompt-function-default.txt: TOOLS-section compress line refreshed to the rendered new text.tests/one-call-payload.test.ts: same signature swap; addsstrict JSONassertion to the 分析缓存泄露问题又一个日志 #2302 static-hint shape test.Verification
npm --prefix kernel test: 1284/1284.one-call-payload+wire-contract-inventory+search-context-cross-session(feat: 支持search_context显式查询历史 session #841 drift guard — BILI vs kernel byte-identity holds without any host override) +compress-tool: 11/11;wire-contract+wire-contract-golden: 21/21;tsc --noEmitclean.\"/\nescape teaching.Closes #2587. Evidence: #2579 (stats + character-level attribution), #2580 (independent A-class reproduction). Salvage-side backstop remains orthogonal in #2591.