fix(compress): remove JSON-string content form (array-only) per #273 - #274
fix(compress): remove JSON-string content form (array-only) per #273#274ranxianglei wants to merge 1 commit into
Conversation
The compress tool's content param accepted a JSON-encoded string as a fallback for non-strict-tool providers that stringify array arguments. Per #273, remove it entirely: - CompressParams.content: Type.Union([Array, String]) -> Type.Array(RangeSpec) - normalizeRanges: pure array validation; non-array content (incl. a JSON-encoded array string) now throws a clear 'must be an ARRAY' error - drop tailRepair / repairContentTail / jsonParseError / describeDiagnostics and the now-unused parseCompressArgs + CompressParseDiagnostics imports - tests: remove compress-tail-repair.test.ts; compress-retry.test.ts now asserts a well-formed JSON-string is rejected (isError:true) - CHANGELOG: note the removal under Unreleased Tradeoff: non-strict providers that stringify the array arg are now rejected at pi's schema layer instead of being parsed by the fallback.
📦 Built Extension ArtifactBranch: Option A — Install from npm PR tag (recommended)pi install npm:billion-context-pi@pr-274Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pi-pr274.tgz
pi install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 收到,正在 review 这个 PR( |
[bot] 🏷 Review 完成,结论:LGTM,建议合并(merge 按规则由人来操作)。 验证(本地全跑过)
逻辑核对(src/compress-tool.ts)
测试改动
一处行为取舍(已在 issue 确认方向) 可选 nit(非阻塞,pre-existing) 综上:改动干净、验证齐全、行为符合预期,建议合并。 |
背景
Issue #273:压缩彻底取消 json 格式。
compress工具的content参数此前是一个 union:既接受数组,也接受「JSON 编码的字符串」(当初为兼容非严格工具 provider 把数组参数字符串化而加的兜底,见 session 01a00a38 / #253)。本 PR 彻底移除该 JSON 字符串形式。改动
src/compress-tool.tsCompressParams.content:Type.Union([Array, String])→Type.Array(RangeSpec)normalizeRanges:改为纯数组校验;非数组content(含 JSON 编码的数组字符串)现在直接抛错(pi 标isError:true,计入失败上限)tailRepair/repairContentTail/jsonParseError/describeDiagnostics,以及不再使用的parseCompressArgs+CompressParseDiagnostics导入tests/compress-tail-repair.test.ts:整体删除(测的是被移除的字符串兜底)tests/compress-retry.test.ts:删掉「接受 JSON 字符串」用例;保留并改写「非数组 → 抛错」用例,现在喂一个合法的 JSON 数组字符串以证明它同样被拒CHANGELOG.md:Unreleased 段记录本次移除权衡(已在 issue 里跟 @ranxianglei 确认方向)
移除后,会把数组参数字符串化的非严格工具 provider(如 vLLM openai-completions)会在 pi 的 schema 校验层被拒(
content必须是 array),不再进兜底解析。按「彻底取消」的字面要求这么做。验证
npm run typecheck✅npm test✅ 450 pass / 0 fail / 3 skippednpm run build✅(dist 已无tailRepair等残留)