Repository navigation
Replies: 3 comments
Confirmed on Windows + 0.2.1-rc.5, with source-level root causeSame failure mode, different platform and build from the original report. Adding the source location because it was not identified above. Environment
Observed errorsIdentical shape to the original report — reviewer prose reaching Also reproduced the DSML variant: All four of these occurred within a single session, on the same route, across different tools (including Source-level root cause (new information)
function parseDecision(text) {
const value = JSON.parse(text); // no try/catch, no fence stripping
if (value === null || typeof value !== "object" || Array.isArray(value))
throw new Error("auto-review: reviewer output must be one JSON object");
...
}Scanning the module for mitigations returns nothing:
Why the reviewer emits prose (mechanism, not just symptom)The review request carries the recent conversation as a function reviewUserText(snapshot) {
return [
"ENVIRONMENT", json({ cwd: snapshot.cwd }),
"PROJECT_INSTRUCTIONS", json(snapshot.projectInstructions),
"FILTERED_HISTORY", json(snapshot.history), // <-- assistant messages included
"PENDING_ACTION", json(snapshot.action)
].join("\n\n");
}The reviewer sees the tail of the conversation and continues it in the same voice instead of emitting the single JSON object. This explains the observed pattern better than a generic "model ignores instructions": the leaked fragments match the style of the immediately preceding assistant message, and the failure rate grows with history length and with non-English content. Two additional structural gates make recovery impossible even when the model does emit JSON: // exactly one text block, everything else must be reasoning
if (final?.type !== "text" || blocks.slice(0, -1).some((b) => b.type !== "reasoning"))
throw new Error("auto-review: reviewer must emit zero or more reasoning blocks followed by exactly one text block");
// exactly 2 or 3 top-level members
if (topLevelMemberCount(text) !== keys.length)
throw new Error("auto-review: reviewer output repeats a JSON member");Any extra field, second text block, or tool-call block is fatal. Failure path never reaches human approvalconst review = await classifyRisk(...).then(
(decision) => ({ ok: true, decision }),
(error) => ({ ok: false, error })
);
if (!review.ok) return failed(exec, review.error); // -> terminal deny
Suggested minimal fix
Happy to test a patch on Windows if useful. |
A distinct sub-case: the reviewer produced a valid decision, wrapped in a Markdown fenceEvery error above is prose, Environment
OccurrencesThe V8 message reproduces exactly, which pins the block content to JSON.parse('```\n{"risk":"medium","decision":"deny","reason":"x"}\n```')
// SyntaxError: Unexpected token '`', "```\n{"risk"... is not valid JSONLocal frequency179
The fence variant is 2 of the 12 parse failures; the other 10 are prose prefixes ( Minimal fix that cannot widen authorizationProse, DSML, and block-shape need a retry or repair step first. A fence needs only a deterministic unwrap before the existing validation in function parseDecision(raw: string): AutoReviewDecision {
const text = raw.trim()
.replace(/^```[A-Za-z0-9_-]*[^\S\n]*\n?/, '')
.replace(/\n?```\s*$/, '')
.trim()
const value: unknown = JSON.parse(text)
// …unchanged: single object, duplicate-member count, fixed risk/decision combinations
}A fence is transport wrapping, not decision content, so removing it cannot turn a deny into an allow: every combination check still runs afterwards, and anything still unparsable keeps today's fail-closed Related threads: #10954 (failure taxonomy; already asks for fence stripping / extraction / retry), #8123 (prose + |
补充:上游
|
| 位置 | 现状 |
|---|---|
parseDecision() L608-634 |
对 reviewer 的 text block 直接 JSON.parse(text),失败即抛,无重试 |
readDecision() L637-661 |
要求"零或多个 reasoning block + 恰好一个 text block",随后同样硬解 |
apply() L737 |
if (permissionPresets.current(agent.session) !== AUTO_PRESET) —— 在 try 之外,没有 catch |
apply() L758 |
if (!review.ok) return failed(exec, review.error) —— 直接判 deny |
与 0.2.0-rc.2(desktop / Windows)对比,这四处逻辑一字未变。10-17 的 fix(auto-review): preserve Auto during application shutdown 只补了 ctx.root.fiber.state === FiberState.ACTIVE(关闭应用时别改策略),没有覆盖运行时读取失败这条路径。
2. 一份可应用的补丁(+27 / −3)
分支:jonhate/deepseek-harness@fix/auto-review-resilience(commit 7b07626)
对比链接:jonhate/deepseek-harness@master...fix/auto-review-resilience
改动只有两点:
permissionPresets.current()包try/catch—— 投影不可用时视为"非 Auto",走next()交回既有审批链;- reviewer 失败先重试一次,仍失败则按审批策略降级:
ask下转人工确认,never下保持硬拒绝。
const attempt = () => classifyRisk(ctx, agent, exec, signal, shown).then(
decision => ({ ok: true as const, decision }),
(error: unknown) => ({ ok: false as const, error }),
)
let review = await attempt()
if (!review.ok && !isAborted(lifecycle.signal)) review = await attempt()
if (isAborted(lifecycle.signal)) return { kind: 'cancel' }
if (!review.ok) {
return ctx.approval.overrideOf(agent.session) === 'never'
? failed(exec, review.error)
: askUser(exec, 'auto review unavailable')
}allow / deny 判定、风险分级、REVIEW_POLICY、快照构造、PTC 处理均未改动;正常路径零额外开销;never 下仍是硬拒绝。esbuild 语法校验通过,git apply --check 在干净的 master 树上通过。
注:本仓库当前对外部 PR 关闭(
POST /repos/deepseek-ai/deepseek-harness/pulls返回 404,Issues 亦关闭),所以只能以分支形式提供补丁。
3. 一条可落地的绕过:把并发降下来
auto-review 给每个工具调用各发一次 reviewer 请求且互不排队,而 agent-loop 的 maxParallelToolCalls 默认是 10。对并发受限的 provider(本机反代 max_in_flight 3 / max_in_flight_global 2)就是 503 雪崩(实测 8 并发 → 5 个 503)。改成 2 后,Unterminated string 的出现频率明显下降:
- id: agent-loop
name: "@deepseek-ai/dsh-agent-loop"
config:
agents: []
maxParallelToolCalls: 24. sessionProjections in inactive context 的一条稳定触发路径
应用运行期间修改 ~/.dsh/profiles/desktop/cordis.patch.yml(profile 热重载)→ 下一个 turn 起所有工具报裸错(没有 Auto review of tool ... 前缀),重启应用、切换模型都不恢复,在 UI 里切权限预设也救不回来,只能弃用该会话。改配置前先完全退出应用可以避免。
复现环境
dsh 0.2.0-rc.2 desktop / Windows 11 x64 / Electron 44.0.0,preset auto、approval ask、sandbox danger-full-access。reviewer 被截断的观测为 Unterminated string in JSON at position 15 / 23 / 26 / 31,与 #8123 中 KoishiMint 给出的 23ch / 26ch / 31ch 完全对应。
Uh oh!
There was an error while loading. Please reload this page.
Bug Report: Auto Review Failures Permanently Block Tool Execution
Environment
df71bd356c39b338b4269c1ab97fdb7f78e7243e@deepseek-ai/dsh-ptc-runtime-node,lib/process.js(bindingFailure)Summary
When Auto Review is enabled, internal tool calls such as
tools.skill()consistently fail during the auto-review stage. The error messages vary, but all indicate that the reviewer's output violates the expected protocol. The underlying tool is never executed, as confirmed byits body was not executed.The exact same call succeeds immediately when the permission mode is changed to workspace-write or full access. This isolates the failure to the auto-review pipeline rather than the tool implementation, skill files, or file permissions.
Reproduction Steps
web-research-fallback.run_code:Isolation Test
The following results were collected using the same tool call, including a comparison on the same model:
Observed Errors
All errors occurred during Auto Review:
ToolCallError: Auto review of tool "skill" failed; its body was not executed: Unexpected token '我', "我先检查源 skil..." is not valid JSONUnexpected token '是', "是**同一类工具调用..." is not valid JSONauto-review: reviewer must emit zero or more reasoning blocks followed by exactly one text blockUnexpected token '<', "<||DSML|| ..." is not valid JSONauto-review: reviewer output does not match the risk/decision protocolUnexpected token '两', "两次测试结果我还需要..." is not valid JSONIn error #4, the reviewer output contained the raw DSML tool-call marker
<||DSML||, which was passed directly toJSON.parseas body text.Key Observations
Hypothesis
The auto-review pipeline does not sufficiently constrain or normalize the reviewer model's output before parsing it—for example, through JSON mode, strict schema validation, or removal of reasoning/tool-call markers. At the same time, the parser appears to have no tolerance for malformed output. Together, these conditions systematically block reviewed tool execution.
Expected Behavior
Impact
Auto Review is currently unusable on this machine: every reviewed tool call fails, forcing the user to switch permission modes or use manual workarounds.
I searched the official Discussions for
Auto review,Unexpected token,ToolCallError, andvalid JSON. I found no matching public reports as of 2026-10-31.环境
df71bd356c39b338b4269c1ab97fdb7f78e7243e@deepseek-ai/dsh-ptc-runtime-node,lib/process.js(bindingFailure)问题概述
开启自动审查后,
tools.skill()等内部工具调用在自动审查阶段持续失败。报错信息各不相同,但都表明审核器的输出不符合预期协议。底层工具从未真正执行,its body was not executed可以证实这一点。将权限模式切换为工作区内修改或完全权限后,完全相同的调用立即成功。因此可以将故障隔离在自动审查链路,而不是工具实现、技能文件或文件权限。
复现步骤
web-research-fallback。run_code调用:隔离测试
以下结果均来自同一工具调用,其中包括同一模型下的模式对照:
观察到的报错
以下报错均发生在自动审查阶段:
ToolCallError: Auto review of tool "skill" failed; its body was not executed: Unexpected token '我', "我先检查源 skil..." is not valid JSONUnexpected token '是', "是**同一类工具调用..." is not valid JSONauto-review: reviewer must emit zero or more reasoning blocks followed by exactly one text blockUnexpected token '<', "<||DSML|| ..." is not valid JSONauto-review: reviewer output does not match the risk/decision protocolUnexpected token '两', "两次测试结果我还需要..." is not valid JSON在第 4 条报错中,审核器输出包含原始 DSML 工具调用标记
<||DSML||,该标记作为正文被直接传入了JSON.parse。关键观察
原因推测
自动审查链路在解析审核模型输出前,没有充分约束或规整化其格式,例如未使用 JSON 模式、严格的 Schema 校验,或未移除推理内容和工具调用标记。同时,解析器似乎完全不容忍格式错误。两者叠加,系统性地阻断了需要审核的工具执行。
期望行为
影响
自动审查目前在这台机器上完全不可用:所有经过审核的工具调用都会失败,用户只能切换权限模式或采用手动兜底方式。
我已在官方讨论区检索
Auto review、Unexpected token、ToolCallError和valid JSON,截至 2026-10-31 未发现同类公开报告。All reactions