Repository navigation
fix: retry MALFORMED_RESPONSE on DSH built-in DeepSeek routes (#2605) - #2610
Conversation
Both bili-owned dsh patch carriers (dsh.bundle.patch.yml and the launcher .bili-acp.patch.yml overlay) now add MALFORMED_RESPONSE to the built-in DeepSeek routes' retry whitelist. Each row restates every default code because a cordis patch replaces the targeted row's whole config rather than deep-merging it. Rows carry mode: normal only, so DSH's default budget/backoff (5 retries, 500ms->10s, jitter 0.1) flows through unchanged. Rows absent on other DSH versions are skipped with a warning, never a boot failure.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2823-pr.2610.d3b410aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2610.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 收到,开始审 PR #2610(fix #2605)。已拉取分支核对:
|
The runLaunch-dsh overlay test still anchored 'auto: false' at end-of-file ($ in multiline mode), which the #2605 retry rows below it broke: the assertion failed on the new .bili-acp.patch.yml content. Mirror the update already made at the writeDshAcpPatch test (drop the EOF anchor, pin both llm-deepseek / llm-deepseek-account retryableCodes rows, keep $ on the final row).
dsh.bundle.patch.yml ships in the npm package but had no unit teeth: an absent or drifted retry row is warn+skip at dsh boot, so the real-dsh e2e stays green either way (the overlay lane was pinned by launcher.test.ts). Pin both rows' exact code lists in the bundle file and assert the launcher overlay carries byte-identical rows, so a future drift on either carrier fails fast locally.
[bot] 🏷 PR #2610 review 完成(含两个直接修掉的小问题)— 结构化八问 ① 是什么问题:dsh 桌面端走内置 DeepSeek 路由(llm-deepseek / llm-deepseek-account)时,模型采样偶发产出畸形 tool-call 参数 JSON(缺一个引号即可),DSH 适配器 finalize 时 ② 什么原因导致的:DSH ③ 影响范围与严重程度:仅 bili dsh 通道( ④ 怎么修复的:两个载体( ⑤ 是否有回归问题:逐项审过既有行为——compaction-basic
⑥ 是否破坏缓存:不涉及——bili 侧缓存/重试/游标/去重键零改动;DSH 侧仅新增 MALFORMED_RESPONSE 的重试资格,prompt_cache_key 机制不受影响。 ⑦ 是否改了设计方向:不涉及——完全复用现有 patch 载体机制,与 compaction-basic ⑧ 是否引入了新的配置:不涉及(config surface N/A,无新字段/env/flag)。 行为变更披露(有意):内置 DeepSeek 两路由上 判定:代码与行为审查通过,小问题已就地修完;head |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.216-master.98fb91c # this exact build
npm install -g billion-context@master # always the newest merged build
|
|
Heads-up: master (98fb91c) is red on both Windows test combos — run 38034641775,
Ubuntu is green. First seen on my PR #2619 CI; verified it reproduces on master own CI run of the same commit, so it came in with this merge rather than that PR. Repro at a glance: |
|
Root cause of the Windows-only failure — confirmed locally with core.autocrlf=true (same as the windows runners):
tests/issue2605-dsh-retry-patch.test.ts:26-29 With CRLF every The repo already fixed this exact class of bug for the golden snapshots in .gitattributes (#1305): |
…2605) tests/issue2605-dsh-retry-patch.test.ts reads the patch file raw and byte-matches multi-line rows; Git-for-Windows autocrlf=true converts it to CRLF at checkout, failing both windows CI shards on every run since #2610 landed (master red at 98fb91c, run 38034641775). Same mechanism as the #1305 golden pin above. In-passing fix carried on #2625.
…t includes (ranxianglei#2631) ranxianglei#2605's bundle test asserts byte-exact multi-line literals against the shipped dsh.bundle.patch.yml; Git-for-Windows checks it out CRLF (autocrlf) and the includes fail on every Windows leg since ranxianglei#2610 merged — master's test (windows-latest, 22|24) legs have been red since 07:30Z, blocking every PR's required checks (ranxianglei#2631). Same failure class as ranxianglei#1305 (golden JSONs): pin eol=lf in .gitattributes, and belt-and-suspenders normalize CRLF after read in the test so checkouts that bypass gitattributes still pass.
Closes #2605
What & why
DSH's default retry whitelist (
DEFAULT_RETRYABLE_CODESinpackages/llm/llm/src/retry-policy.ts) omitsMALFORMED_RESPONSE. The DeepSeek adapter finalizes every streamed tool call with aJSON.parse(content.arguments)check (llm-deepseek/src/translate.ts); when the model occasionally emits argument JSON with the opening quote of the first value missing (a sampling flake — the issue shows 17/18 calls legal, longest 10,957 chars fine), that validation raisesMALFORMED_RESPONSE, which is not in the whitelist ⇒ zero retries ⇒ the whole turn dies and the answer is never delivered.Fix
Both bili-owned DSH patch carriers now add
MALFORMED_RESPONSEto the built-in DeepSeek routes' retry whitelist:dsh.bundle.patch.yml— the profile-bundle lane (dsh plugin --profile <name> add billion-context).bili-acp.patch.ymlwritten bywriteDshAcpPatch(src/launcher.ts) — thebili dshlane; without this, launcher-only profiles without the bundle would keep the bugEach row targets
llm-deepseekandllm-deepseek-account(the two built-in route entries from@deepseek-ai/dsh-base; ids are stable across versions) with:Key mechanics:
configrather than deep-merging it (applyEntryPatches,vendor/include), so each row restates every default code plusMALFORMED_RESPONSE— dropping any default code would silently remove its retries. The comment in both files pins this for future editors.mode: normalonly and omitmaxRetries/backoff on purpose, so DSH's defaults flow through unchanged (5 retries, 500ms→10s, jitter 0.1).retry-policy.tsis byte-identical from dsh v0.1.1-rc.2 through master (verified by tag-tree diff), so the static rows are safe on all realistic DSH versions.cordis.patch.ymlapplies after the bundle layer (last write wins per row); the launcher overlay applies last, consistent with howcompaction-basic → auto: falsealready behaves there.Behavior change (intended, disclosed)
For all bili dsh-lane users, on the built-in
llm-deepseek/llm-deepseek-accountroutes only:MALFORMED_RESPONSEretries+MALFORMED_RESPONSE -[])Extra provider requests happen only on the rare malformed event; each retry re-runs the failed step inside the same open turn over the same durable history (failed partial output never reaches the model).
Config surface
N/A — no new bili config fields, env vars, or CLI flags. The change sets values on DSH-side entries through bili's existing patch carriers; the override path is DSH's own profile
cordis.patch.yml.Verification (real dsh 0.2.0-rc.2, hermetic prefix install)
tests/e2e/e2e-native-dsh.test.ts2/2 pass andtests/e2e/e2e-native-dsh-persona.test.ts1 pass + 1 pre-existing env skip (headless Auto-permission surface, unrelated to this change) — boots real dsh 0.2.0-rc.2 with the patched layer mounted; an invalid row would fail schema validation at bootapplyEntryPatchesfrom the installed packages, real base→headless→bili layering): both rows resolve to exactly the intended config, zero "entry not found" warningsRetryPolicySchemastandard-schema validation: OK; negative control (empty list) rejected as expectedresolveRetryPolicy: resolved ={mode: normal, maxRetries: 5, retryableCodes: [5 defaults + MALFORMED_RESPONSE], initialDelayMs: 500, maxDelayMs: 10000, jitterRatio: 0.1}writeDshAcpPatchtests updated to pin the exact code list (teeth kept) and pass