rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:KrimsonSun/dsh-result-check
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
A DeepSeek Harness plugin that checks the agent's final answer against what its tools actually returned, before the turn ends. When the two disagree, it sends the model back once with a short note saying what to fix.
It runs two checks. Both are plain code, with no extra model call:
| Check | Fires when | Example |
|---|---|---|
| Unreported tool failure | A tool call failed, no later call in the turn succeeded, and the answer never says anything failed | web_fetch returned HTTP 503 and the answer summarises the page anyway |
| Unsourced number | The answer states a number that no tool output, tool argument or user message in the session contains, at the precision the answer writes it, and that the answer's other numbers do not account for either (one arithmetic step, a table total or share, or working it writes out) | The tool reported AC: DDX41 392 / WT 258 and the answer's table says 469 / 181 |
When a check fires, the model gets one more step with a note like this:
[result-check] Before you finish, check your answer against this session's tool output. ...
These numbers in your answer appear in no tool output, tool argument or user message of this
session: 469, 181.
For each one, say which output it comes from or how you derived it, or correct it. Do not change
a number that is right.
Then give your final answer again.
The note appears in the conversation as a one-line notice, for example
Result check: 2 unsourced numbers.
This plugin comes out of AiScientist, a research agent for biomedical data. There, telling the model in its prompt not to misreport results did not work reliably. Checking the answer in code did:
This plugin brings both rules to any dsh agent, in a general form.
It works best for agents whose tools return data and whose answers report that data: analysis, benchmarking, monitoring, research over tool output. There a wrong or invented number is the error that matters, and most numbers in the answer come straight from a tool.
On DeepSeek analysis tasks it sent back about 1 run in 8, mostly to have the model explain a correct multi-step number, and it caught most changed numbers (see below). For a general coding agent it stays mostly quiet (about 1 turn in 50), but it also catches less: answers there are full of estimates, general knowledge and multi-step arithmetic, which the check has to let through or flag as unsourced.
Besides the unit and agent-loop tests, the plugin was tested two ways: live in dsh with DeepSeek models, and offline over real Claude Code sessions.
Twelve data-analysis tasks, run through dsh headless with the plugin on: single-cell counts, a
DE gene table, an RNA-seq pipeline, an access log, a weekly service report, disk usage, a
benchmark, training runs, a clinical trial, an income statement, sales data and a Chinese survey.
Tools are the shell, file reads and a local MCP data server. Several tasks hold traps: a benchmark
config that crashed, a metrics call that times out, a training run the tracking server cannot
find, a failed pipeline step next to an old report, and condition and reference labels that are
easy to swap. Each version ran 60 times, deepseek-flash 3 times and deepseek-v4-pro twice per
task. Every run records the first answer, which is what the user gets without the plugin, and the
answer after the note. Each answer was graded against the task's ground truth by Claude
subagents, which checked every computed value with Python. eval/deepseek/ has the tasks, the
harness and the rubric.
| 0.2.0 | 0.3.0 | |
|---|---|---|
| First answers with a problem | 2 of 60 | 2 of 60 |
| …made-up numbers or hidden tool failures | 0 | 0 |
| Runs sent back | 20 (33%) | 7 (12%) |
| Numbers flagged | 37, 1 a real error | 8, 1 a real error |
| Answers the note made worse | 0 | 0 |
| Changed numbers caught | 88–89% | 89–90% |
deepseek-flash answer had a rounding-level mistake
(0.76264 for 0.762633, fell 4.1% for 4.05%), which the plugin flagged and the model fixed,
and one ranked wrongly while every number was right, which the plugin cannot see.128.51 from 541.38 − 412.88), a unit constant
(1024), a step on two cells of one table row cited below the table, and a chained equation.Both checks replayed offline over 2,598 turns that called a tool, from Claude Code transcripts on
one developer's machine: mostly software and infrastructure work, with some research, writing and
finance. eval/replay-claude-code.ts is the script. The replay follows dsh where the two
harnesses differ (see the script's header).
| 0.1.0 | 0.2.0 | 0.3.0 | |
|---|---|---|---|
| Turns sent back | 169 (6.5%) | 53 (2.0%) | 50 (1.9%) |
| …for a tool failure | 36 | 1 | 1 |
| …for numbers | 137 turns, 282 numbers | 53 turns, 81 numbers | 50 turns, 67 numbers |
| Changed numbers caught (last digit + 1) | 51% | 48% | 48% |
| Changed numbers caught (value × 1.2) | 56% | 53% | 53% |
3.6 usually appears somewhere among the
session's thousands of numbers. Long sessions catch less for the same reason. Coding sessions
hold far more numbers than the DeepSeek tasks, hence about 50% here against 89% there.From a release tarball or a checkout (build first: npm install && npm run build):
dsh plugin --profile <name> add ./dsh-result-check
dsh --profile <name>
From GitHub. The prepare script builds the plugin on install, so pnpm asks you to allow it once
(see the dsh docs, "Install from GitHub"):
dsh plugin --profile <name> add github:KrimsonSun/dsh-result-check#<commit>
For a quick try with a dsh source checkout, add a --patch overlay that names the built file:
# result-check.yml
- insert:
- id: result-check
name: /absolute/path/to/dsh-result-check/lib/index.js
pnpm dsh web --patch result-check.yml
Every key is optional. To change one, override the row by id in your profile's
cordis.patch.yml. A later layer replaces the whole config, so restate every key you set.
- id: result-check
config:
failureResolvedBy: same-tool
ignoreTools: ['read', 'glob']
| Key | Default | Meaning |
|---|---|---|
checkFailures |
true |
Run the unreported-failure check |
checkNumbers |
true |
Run the unsourced-number check |
numbersNeedToolCall |
true |
Check numbers only in turns that called a tool (plain chat answers are left alone) |
minIntegerDigits |
3 |
Integers with fewer digits are not checked |
failureStatuses |
error, failed, timeout, unavailable, dependency_missing, cancelled, blocked, … |
JSON status values that mean a tool failed; anything starting with error, fail or blocked also counts |
ignoreTools |
[] |
Tool names (* wildcards) whose failures are ignored |
ignoreErrorCodes |
*ABORTED*, *CANCELLED, *CANCELED, UNKNOWN_TOOL, INVALID_ARGS, TOOL_ACTIVATION_FAILED, AUTO_REVIEW_DENIED, DECLINED |
dsh error codes (* wildcards) for calls that never produced a result: cancelled, unknown tool, invalid arguments, declined |
failureResolvedBy |
any-tool |
A failure is dealt with once a later call succeeds: of any tool, or with same-tool only of the same tool. Use same-tool for pipelines where every tool's result is reported |
allowDerived |
true |
Accept a number that one arithmetic step on other numbers in the answer gives |
derivedScope |
paragraph |
Where those numbers may come from: the same paragraph, or the whole answer (quieter, catches less) |
skipSubagents |
false |
Leave subagents unchecked |
maxNudgesPerTurn |
1 |
Most times one turn is sent back |
maxListedNumbers |
8 |
Most numbers named in one note |
A wrong flag costs the user an extra step and teaches them to ignore the note. A missed problem costs what it cost before the plugin existed. So when the reader is unsure, it stays quiet.
A tool call failed when dsh marks its result as an error, or when the result is a JSON object
whose status is a failure value. That covers MCP tools and most script tools. A shell command that
exits non-zero is not a failure, because the shell tool reports it as a normal result. A call
dsh rejected before running it (see ignoreErrorCodes) is neither a failure nor a success.
The failure counts as dealt with once a later call in the turn succeeds: the agent saw it and moved on. The answer counts as mentioning it when it says something failed, in English or Chinese ("failed", "could not", "timed out", "returned 404", "no data", "失败", "无法", "超时", "缺失", …).
A number is checked only when the answer states it as a value:
0.873), integers of 3+ digits (1,708), percentages (12.5%, and
percentage points such as +26.4 pp or 11.5 个百分点), with or without a short unit
(1530ms, 3.2GB, 1.6x), in English or Chinese text (共1708个细胞).app.py:120-140,
`f` (2867), (891-894)), versions, dates, times, #123 references, phone numbers and
other hyphenated digit groups, identifiers (H100, x86_64, ISO-8601, HTTP 404), section
and step numbers, list numbering, years, round figures (5000, 50%), hedged or bounded
numbers (about 1700, p < 0.05, 约1500, 300左右, 300+), examples (e.g. 150 ms,
比如 150 ms) and confidence levels (95% CI).A number has a source when some number in a tool output, tool-call argument or user message of
the session rounds to it at the precision it is written. 0.873 is covered by 0.87312, 1708 by
1707.6, 12.5% by 0.125, and 0.000312 by 3.12e-4. Sources are read loosely: numbers inside
identifiers, JSON, tables and either comma reading all count. An extra source can only prevent a
flag, never cause one. The plugin's own notes are never counted as sources.
A number with a unit also has a source in another unit: 15.6 GB is covered by a byte count
(decimal or binary), 125 MB by 124763103, 2.7 hours by 9731 seconds, 1.63M by 1630412,
42.7万 by 427113, and $18.32M by 18,324.1 from a table kept in thousands.
A number is derived when the answer's other numbers give it:
+ − × ÷) on two numbers in the same paragraph: 4 × 96 = 384 GB, or 5.72 TiB left
next to 594.28 of 600 TiB. A percentage may also be the relative change of two numbers less
than a factor 2 apart (p95 is 9.5% worse, 97.1 vs 88.7 ms) or a complement (the other five take 23.7% next to 76.3%);three services together: 30,456,293 below a table of
the three, 地铁或公交合计 1013 人);3,987 + 1,764 + 258 + 2,655 = 8,664, 1.3% (1/80). Working that does not give the number
keeps it flagged, even when some other combination happens to match.Only numbers that are sourced themselves, or too small or round to be checked, may be used, so
made-up numbers cannot vouch for each other (469, 181 and their sum 650 are all flagged, and
so is a table total over made-up rows). A derived number can be used for the next step.
9,005 + 7 + 12), or
from tool numbers the answer does not repeat, are flagged. The note asks the model to show the
working, so a right answer gets one sentence added, not rewritten.541.38 − 412.88 does not account for 128.51.engines.dsh: >=0.2.0 <0.3.0.npm install
npm test # pure-logic tests, no dsh needed
npm run build # lib/index.js
npm run test:dsh -- /path/to/deepseek-harness
node eval/replay-claude-code.ts [~/.claude/projects]
test:dsh copies the plugin into a dsh source checkout (after pnpm install there). It runs the
agent-loop tests against dsh's scripted mock model and type-checks the plugin under dsh's settings.
eval/replay-claude-code.ts replays both checks over local Claude Code transcripts and prints how
often a turn would be sent back and how many changed numbers are caught (Node 23.6+). It reads the
transcripts and writes nothing.
eval/deepseek/ runs the plugin in dsh with a DeepSeek model on the twelve analysis tasks; its
README covers setup, the grading rubric and how to compare two versions on the same answers.
The rules and their rationale come from AiScientist (Copyright (c) 2026 Chen Lab, University of
California, Irvine; MIT License). There they are agents/step_numbers.py and the step acceptance
rules. This plugin is a separate TypeScript implementation for dsh.
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm-agents、deepseek-harness。