Repository navigation
fix: serve strict-JSON compress serialization guidance on all host surfaces (#2579) - #2588
ranxianglei wants to merge 2 commits into
Conversation
…rfaces (#2579) Models intermittently emit invalid JSON for compress content (bare unquoted values; unescaped quotes/newlines inside strings) because the served tool descriptions and nudge text exemplify unquoted ref headers and frame the line form as 'no JSON escaping'. Rewrite every host-served copy of that guidance - tool descriptions for all four wire shapes (proxy injection + plugin manifest + MCP), the content param, the line-form item, the google param - to state the strict-JSON contract with a paste-ready object-array skeleton, keep the string form legal but explicit that it is still a quoted JSON string, and append a short [JSON validity] note to every rendered nudge and the post-compress remaining-ranges tail. The opencode native/V2 in-process registrations now use the overridden compress entry too. The canonical text lives in kernel/** (owner-gated); this is a temporary host-side override until the kernel default is updated via the follow-up issue. Goldens tests/golden/wire-contract/{bili,manifest-default,manifest-optin}.json regenerated via scripts/update-wire-contract-goldens.ts: description text only, no schema structure change; kernel.json untouched.
a67901d to
3f351c7
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2793-pr.2588.4214ec2This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2588.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ess override The 'no other tool may change' guard compared every BILI array entry against the kernel default; the #2579 fix intentionally rewrites the compress description/params host-side, so compress is now excluded from the rest-comparison and positively asserted to carry the strict-JSON contract (exact text pinned in tests/compress-json-surface.test.ts).
PR #2588 review — serve strict-JSON compress guidance on all host surfaces (#2579) 结论先行:代码正确、边界干净、新测试有牙。CI 的唯一红灯是一个测试期望回归,已在分支上被 commit 按八问:
行为变更披露(旧→新):① 下发的 compress 工具/参数描述:旧 PREFERRED =「plain string,no JSON structure/escaping」,新 PREFERRED = 对象数组且所有形式声明严格 JSON 转义规则(schema 结构不变)。② 每条 nudge / post-compress 尾注新增固定 判定:代码与边界 OK;CI 红灯已修复并验证(原失败分片 PR: #2588 |
收到「上游 PR 冲突」唤醒。先查证再动手 —— 结论:当前无真实冲突,我未做任何 rebase / push。 按八问:
判定:master 未动、head 为干净后代、GitHub 判 |
|
Closing per owner decision: the host-side override layer is an interim band-aid (double maintenance across ~10 serving surfaces). The fix moves to the canonical kernel text (#2587 scope) — same strict-JSON contract wording, PREFERRED object-array form, explicit escaping rules — so every consumer (host wire/manifest/MCP/opencode + independent acp-kernel consumers) gets it from the source. Salvage PR #2591 is orthogonal and stays. |
The kernel defaults still carried the pre-#2579 framing — "no JSON escaping", unquoted 'm00150–m00220 topic' header exemplars, ONE plain string PREFERRED, "lossy gateways" — the prompt-layer inducement behind the malformed compress calls measured in #2579 (~4% of calls: bare unquoted values / unescaped quotes). Rewrite all default surfaces to the strict-JSON contract already shipped host-side in #2588: - COMPRESS_PARAMETERS.content.description: strict JSON up front; PREFERRED = object array; string form kept legal but quoted-JSON-explicit - line-form item description: entry is still a quoted JSON string value - COMPRESS_TOOL.description: STRICT JSON clause + paste-ready skeleton, byte-identical to #2588's COMPRESS_TOOL_DESCRIPTION_FIXED - system-prompt tools section: same direction (no #2588 counterpart) - COMPRESS_TOOL_GOOGLE content.description: same contract, anyOf-free form - ONE_CALL_HINT + gentle nudge line: object-array-first, quoted-string alternative, no lossy-gateway framing - lean-pack paramDescriptions.content: same contract - kernel version 0.0.111 -> 0.0.112 (CI-enforced) - tests pinning the old wording updated (one-call-payload, compress-schema-contract, nudge-text, first-sight-drain-wire marker) - goldens regenerated via scripts/update-wire-contract-goldens.ts (description text only — no schema structure change) Schema and parser semantics unchanged: all three content forms (array / one string / flat) parse exactly as before.
Closes #2579
背景
DSH 侧偶发「tool input is invalid JSON」整轮失败(~4% 的 compress 调用,issue 内 30 会话统计)。issue 证据确凿:坏 JSON 是模型流式输出本身(10/10 chunk 逐字节一致),诱因在提示/示例层——下发给模型的 compress 工具描述与 nudge 文本用不带引号的 ref header 举例(
'm00150–m00220 optional topic' header line),并把字符串形式描述成no JSON escaping/no JSON structure。模型照抄 ⇒ A 类(content 写成裸 token);引用代码时转义不一致 ⇒ B 类(字符串内未转义引号提前闭合)。修法(宿主层,不动 kernel/)
规范文案住在
kernel/**(owner-gated,Kernel Boundary),本 PR 在宿主下发面做临时 override:src/compress-tool.ts:重写四种 wire shape(anthropic/openai/responses/google)的 compress 工具描述、content参数、line-form item、google 参数——严格 JSON 契约前置(未加引号的值 / 字符串内未转义的\"、换行会使整个调用失败),PREFERRED 改为对象数组并给可粘贴骨架{"content":[{"startId":"m00122","endId":"m00127","summary":"...","topic":"..."}]},字符串形式保留但写明仍是带引号的 JSON 字符串;删除全部no JSON escaping/no JSON structure/lossy gateways措辞。[JSON validity]注记(withCompressJsonNote/COMPRESS_JSON_NOTE)。覆盖:proxy wire 注入、plugin manifest(dsh/pi/omp/opencode/kimi/hermes/zcode native plugins)、MCP tools/list。
行为变更披露(旧 → 新)
content仍为 anyOf:[array,string],字段未增删改名,解析路径不变)。[JSON validity]后缀(纯提示词增量,不改指令语义)。Golden 再生成(#1304)
tests/golden/wire-contract/{bili,manifest-default,manifest-optin}.json经scripts/update-wire-contract-goldens.ts再生成:仅上述描述文本变化(合计 29+/29-),kernel.json字节级未变(kernel 未动)。理由即本 PR 目的:#2579。测试
新增
tests/compress-json-surface.test.ts(4 用例:全部 8 个下发面声明严格 JSON 契约且旧措辞清零、line-form item 携带带引号值规则、广告示例自身可被严格JSON.parse、注记字节稳定)。定向套件全绿:wire-contract* + dsh-native/dsh-acp + absorb/ccr-plugin + basic + acp-status + one-call-payload + opencode-native/v2 + compress-* 等 ~250 用例;typecheck / build / check:unused-exports 干净。全量回归交给 CI。边界与后续
kernel/src/compress-tools.ts:99/:108/:153/:255、nudge-text.ts:246/:327、packs.tslean-pack)仍带旧措辞——已立 kernel 默认 compress 文案仍引导非法 JSON(#2579 的内核侧后续) #2587(来源标记 compress 的 content 偶发非法 JSON,导致 DSH 整轮失败(实测 0.1.189) #2579),待 owner 批准后走 Kernel Boundary 流程统一改内核默认值,届时移除宿主 override。MALFORMED_RESPONSEfail-fast 且不纳入重试集合是 DSH 自身设计(解释了为何表现为整轮失败而非静默重试);建议 DSH 侧评估将其纳入可重试集合——非 bili 范围,不代为立项。自动合并门禁:涉及 wire-visible 表面 ⇒ 人工审核。