Skip to content

docs+feat: #1518 — dsh interop note + observe-only telemetry for malformed tool-call args - #1521

Closed
ranxianglei wants to merge 3 commits into
masterfrom
2026-09-27_dsh-malformed-args-retry-note
Closed

ranxianglei wants to merge 3 commits into
masterfrom
2026-09-27_dsh-malformed-args-retry-note

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Refs #1518 (issue stays open as investigation).

One issue, one PR, three clearly-separated commits. Rebased onto current master (8293a54) after the owner flagged a conflict — master had moved on both fronts since the branch base: the client deep-dives were reorganized OUT of README.md/README.zh-CN.md into new CLIENTS.md/CLIENTS.zh-CN.md files, and src/plugin.ts gained ~200 lines of unrelated work (#1684 dsh-acp-invocation-session et al.). Resolution: interop bullet relocated into the dsh sections of CLIENTS.md/CLIENTS.zh-CN.md (text unchanged); one addition/addition conflict in pipePluginJson resolved by union (master's #1595 diagnoseSuccessWithoutUsage line + this PR's observe block, both kept).

Part 1 — docs (commit cab6d7e)

One bullet each in the dsh sections of CLIENTS.md / CLIENTS.zh-CN.md (mirrored en/zh): plugin-mode compress args are model-generated and host-parsed strictly; the observed escape-error class is semantic (structural-vs-content quote judgment), unrecoverable by any syntactic salvage ladder, and bili passes plugin-mode responses verbatim (no seat at the parsing table). Hosts that fail-loud on such args (MALFORMED_RESPONSE) should add that code to their retry whitelist (retryPolicy.retryableCodes on DSH) — escape errors are sampling noise, one extra full call usually succeeds. Root fix (provider constrained decoding, e.g. DeepSeek Beta tools[].function.strict, Chat Completions wire only) is a host/provider work item.

Part 2 — feat: observe-only diagnostics (commit dae0e29)

Closes the visibility gap named in the issue: in plugin mode the host parses tool-call args at its terminal and bili previously had ZERO trace of what the host was about to reject (the reporter had to reconstruct argument deltas by hand out of 77 zstd-framed session logs).

What it does:

  • Extends the existing per-event sniff pass in the plugin verbatim pipes (pipePluginChatWithStrip openai/anthropic/google, pipePluginResponsesWithStrip, non-streaming pipePluginJson) to accumulate the final argument STRING per model-emitted tool call.
  • At clean stream end (and for non-streaming bodies), strict JSON.parses each accumulated arg; on failure logs ONE warn per bad arg: [plugin] [<session>] malformed tool-call args forwarded verbatim (<protocol>, tool=<name>, len=<N>, err@<pos>): <V8 error class> (#1518 observe-only) — the same V8 taxonomy the reporter computed on the 21 production failures (position/line-col/embedded-snippet suffixes stripped, so no payload content is ever echoed into the log).

Hard guarantees (each pinned by test):

Tests: new tests/malformed-toolcall-args-observe.test.ts, 10 tests — malformed + clean + empty-args + proxy-lane-gate cases across all four shapes (openai chat SSE, anthropic SSE, responses SSE, non-streaming JSON openai/responses), asserting both the warn line contents AND verbatim passthrough of the offending bytes.

Part 3 — in-passing fix for pre-existing master breakage (commit a34f790)

Labeled, separate commit: tests/issue1086-chain-self-exemption.test.ts line 728 called bare rmSync(...) without importing it (ReferenceError — the file imports rmrf from tests/tmp-rm.ts, used by all 10 sibling cleanup sites; rmrf also carries the #1646 CI ENOTEMPTY retry that a bare rmSync lacks). Reproduced identically on pristine master 8293a54 before touching it. One-word fix: rmrf(root).

Preflight (rebased head a34f790, atop master 8293a54)

  • npm run typecheck — clean
  • npm test — full suite green after the Part 3 fix (pre-fix run: 3268 pass / 1 fail, the fail being exactly the pre-existing breakage above; post-fix single-file run 21/21; final full-suite confirmation in the issue reply)
  • npm run build — success

Behavior changes

None on the wire. New log lines only (warn level, one per bad arg, plugin mode only). No config surface added. No version bump.

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-27_dsh-malformed-args-retry-note (a34f790)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1650-pr.1521.d9d2797

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1521.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

PR #1521 复核完成(分支已拉取本地核对,未重做工作)。结论:可以合并。

核对项

  • 分支 vs 描述:2026-09-27_dsh-malformed-args-retry-note,head 2515078f(与 GitHub API 完全一致)。单 commit,仅 README.md + README.zh-CN.md,+20/-2 —— 与 PR 描述的 preflight 逐字相符。
  • behind 状态:mergeable_state=behind,但 master 自本 PR base(8c41b0e9)以来没有触碰过这两个 README 文件(base..master 对两文件的 diff 为空)—— behind 纯属无关提交(feat: inherit refs/blocks/lineage across resume forks (#1486) #1519 resume-ref-inheritance、v0.1.163 release 等),合并无任何文本冲突风险。
  • CI(head sha 2515078):12/12 check runs 全绿 —— test 四平台矩阵(ubuntu/windows × 22/24)、build-artifact、version-guard、codex/dsh/opencode/pi 四条真实 lane 的 fake-upstream e2e、hermetic registry e2e。

内容审核(对照 #1518 调查结论逐项验证)

后续

一句话中文摘要:这是纯文档的 dsh 互操作注记(README en/zh 各一条,+20/-2),内容与 #1518 调查结论逐项核对无误、CI 12/12 全绿、与 master 无冲突,可以合并。

@ranxianglei ranxianglei changed the title docs: dsh interop note — retry on malformed tool args (#1518) docs+feat: #1518 — dsh interop note + observe-only telemetry for malformed tool-call args Sep 28, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

冲突

@ranxianglei
ranxianglei force-pushed the 2026-09-27_dsh-malformed-args-retry-note branch from 0bf179a to a34f790 Compare September 29, 2026 14:52
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 冲突已解决,分支已 rebase 到当前 master 并 force-push。

冲突根因

分支 base(8c41b0e)之后 master 走了 8293a54,两处漂移同时撞上本分支:

  1. README 重组:master 把客户端深入章节从 README.md / README.zh-CN.md 移入新文件 CLIENTS.md / CLIENTS.zh-CN.md(dsh 章节随之搬家)。本分支的互操作注记 bullet 原插在旧 README dsh 小节,[plugin 模式] compress 参数出现 JSON 转义错误时无任何兜底,整个 turn 失败 #1518 stage 1 之后 master 该区域已被整体替换 → 文本冲突。
  2. src/plugin.ts 漂移:master 在同文件加了约 200 行无关工作(fix(dsh): /acp and /acp-cache target the invoking session via the host-passed invocation (#1677) #1684 dsh-acp-invocation-session 等),其中 pipePluginJson 与本分支在同一位置各自新增了代码(addition/addition):master 侧是 nudge: no-usage recovery leaves stale reference after network or 5xx failure #1595 的 diagnoseSuccessWithoutUsage(session, "plugin-json") 诊断行,本分支侧是 stage 1 的非流式畸形参数观察块。

解决方式(不改变任何原 commit 语义)

顺手小修(独立标注 commit a34f790)

全量测试暴露一个 master 上已存在的测试损坏(与本 PR 无关,先在干净 master worktree 复现确认):tests/issue1086-chain-self-exemption.test.ts:728 调用了裸 rmSync(...) 但文件从未 import 它(ReferenceError;同文件其余 10 处清理点用的都是已 import 的 rmrf,且 rmrf 带 #1646 的 CI ENOTEMPTY 重试)。一词修复:rmrf(root)。

验证(rebased head a34f790)

  • npm run typecheck — clean;npm run build — success(dist-import-annotations OK)
  • npm test — 3269 pass / 0 fail / 12 skipped(gated e2e)。过程说明:修复前首跑 3268/1,那 1 个 fail 正是上述 master 既有损坏;修复后一次全量跑里出现过一次 fix-437-idle-timeout(时序敏感用例)单发失败,单独重跑 3/3 通过且本 diff 完全不触碰 fetch-util/idle-timeout 路径,判定为负载抖动 flake;最终确认跑全绿。
  • GitHub CI @ a34f790:12/12 success。

行为变更声明

无新增。wire 零变化(转发字节逐字节不变,#1039 契约);仅新增 plugin 模式 warn 级日志(每个坏参数一行);无 config surface;无 version bump。PR 描述已同步更新(rebase 说明 + Part 3 + 新 preflight 数字)。

中文摘要:解决了 master README 重组与 plugin.ts 漂移造成的双重冲突(bullet 搬到 CLIENTS*.md、plugin.ts 取并集保持双方语义),顺手修掉一个 master 既有的测试 rmSync 未导入损坏,本地全量测试与 CI 均全绿,可以合并(合并操作由你执行)。

@ranxianglei ranxianglei closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant