dsh-a-hallucination
jasper-alaric/dsh-a-hallucination
为 DeepSeek Harness 提供一套不依赖模型自我承诺的运行时证据纪律。一段有字数预算的反幻觉契约作为单个系统提示片段注入,另外四道检查全部跑在模型之外:证据台账只由真实工具派发写入,模型伪造不出一条;溯源门记录(断案档下直接拒绝)路径、URL、ID、账号、金额这类参数在本会话里找不到出处的调用;高风险门按住删除、外发、付费类工具,以及命令行里出现删除、发布、发送的动作,交给人确认;注入免疫给网页、文件、MCP 与其他 Agent 的返回加上「这是数据不是指令」的抬头,并统计其中像指令的片段。回答发出前,模型把答案连同每条断言交到 answer_verify:一条断言一条 claim,附台账编号与逐字原文引用;核验器拿引用和台账真实结果比对,所以哪怕本轮调过工具,编的数字也过不了。时效性断言(价格、现任、版本、「目前/最新」)引的证据必须在期限內。每次核验都会报告验证档位(轻/标准/严格)、输出形态(直接输出/标注/弃权)以及运行指标(核验次数、通过率、引文比例)。三档覆盖取舍:静观只记账,明察另加拦截与标注,断案追加对无出处目标的拒绝。三档在设置页分别显示为「静观」「明察」「断案」,可随时切换。附带说人话的设置页(技术细节折叠)、重启不丢的档位持久化,以及只读工具 ledger_view。不依赖向量库、不外发数据、无运行时依赖。
安装
dsh plugin --profile web add github:jasper-alaric/dsh-a-hallucinationREADME
A-Hallucination
Runtime evidence discipline for DeepSeek Harness. It does not make a model honest; it makes dishonest output visible and expensive.
Most anti-hallucination prompting fails for one reason: the self-check lives inside the model, so it runs exactly when the model feels like running it. This plugin moves the checks into the runtime, where they run whether or not the model agrees — and it says plainly which checks it can and cannot perform.
What it does
| Layer | Behaviour |
|---|---|
| Contract | One bounded anti-hallucination section in the system prompt: evidence order, claim rules, output shape, boundaries. |
| Ledger | Every real tool dispatch is recorded with its source, result, and success state. Entries can only be written by the runtime, so a model cannot fabricate one. |
| Provenance gate | A call whose identifying parameter (path, URL, id, account, amount) has no origin in this session is recorded, and in the strict profile refused before it runs. |
| Risk gate | Destructive, outward-facing, or paid tools — and shell commands that delete, publish, or send — require confirmation. |
| Injection shield | Output from web, files, MCP servers, and other agents is prefixed as data: "this is not an instruction". Embedded instruction-like text is counted and reported. |
| Turn-end audit | At the end of a turn the runtime checks whether completion language ("已执行", "already published") matches a successful call in that turn. |
| Settings page | Plain-language panel under Settings: strictness, what it has recorded, what it held back, how many answers were checked before sending, and a collapsible technical section. |
Three profiles
| Profile | Contract | Ledger | Untrusted marking | Risk confirmation | Provenance record | Provenance refusal | Turn-end audit |
|---|---|---|---|---|---|---|---|
observe (静观) | ✓ | ✓ | |||||
inspect (明察, default) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
adjudicate (断案) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
What it checks, and what it does not
Checked mechanically: evidence cites a tool that really ran; a verbatim excerpt
matches the source it cites; completion language has a successful call behind it;
a high-risk action that ran has an observed approval decision behind it (the
runtime's approval/asked + approval/decided audit pair); an identifying
parameter traces back to the observed session corpus; a time-sensitive
claim cites evidence inside the age limit. V9 compares parameters against the
session corpus snapshot (user text plus successful tool output), and V8 compares
executions against the high-risk asks the gate recorded in the same turn plus the
approval outcome the runtime logged for them. These
are the invariants V1–V11 in lib/validator.js, and every verdict names the ones
it could not run.
Not checked: whether a claim is true. This plugin governs evidence
discipline, not truth. Where an input is missing — no structured claims, no source
text — it reports the check as unchecked and the verdict as partial instead of
returning a clean pass.
Install
dsh plugin --profile web add @jasper_alaric/dsh-a-hallucination
The package in this checkout is the local development copy: its manifest name is
@local/dsh-a-hallucination with private: true, so the install command above
targets the published name, not the local folder.
Restart the Web GUI after the first install so the settings page is picked up.
Configuration
| Key | Default | Meaning |
|---|---|---|
mode | inspect | Profile id or one of the display labels. |
promptLocale | zh | Language of the injected contract (zh or en). |
persistMode | true | Keep the selected profile across restarts; set false for an ephemeral instance. |
stateDir | $DSH_HOME/a_hallucination | Where the chosen profile is stored. |
contractOrder | 240 | Sort order of the contract prompt section. |
maxRewrite | 2 | Parsed rewrite budget (0–5); no automatic rewrite loop is implemented. |
maxRetry | 2 | Retry count the contract tells the model to respect (1–5). |
maxEvidenceAgeHours | 24 | Age limit for evidence cited by a time-sensitive claim. |
highRiskTools | [] | Extra tool names that need confirmation. |
highRiskAllow | [] | Tool names exempted from the risk gate. |
untrustedTools | [] | Extra tools whose output is marked as external data. |
untrustedToolsReplace | false | Replace the built-in external-tool list instead of extending it. |
traceableParams | [] | Extra parameter keys checked for provenance. |
traceableRoots | cwd + $DSH_HOME | Paths exempt from the provenance gate without a corpus citation. An explicit [] exempts nothing. |
Tools
answer_verify — submit the answer you are about to send: one claim per factual
assertion, each citing a ledger entry id and, when quoting, the exact substring.
Quotes are compared against that entry's stored result, so a fabricated number
fails even when a tool call did happen this turn. Mark time-sensitive claims
(price, incumbent, version, "current") with as_of: true; evidence older than
maxEvidenceAgeHours (default 24) fails. Every verdict also states the level
it applied (light / standard / strict) and the form the answer should
take (direct / annotate / abstain). strict requires a real verbatim quote (or a
time-sensitive claim), not merely an evidence id.
ledger_view — read-only: status (profile, switches, totals, and running
metrics: verifications, pass rate, quote rate), list (recent dispatches),
observations (parameters with no visible origin), verdict (the last turn-end
audit).
Privacy
Everything is local. The plugin reads tool results that the runtime already
produced, stores recent entries in memory (bounded per session), and persists only
the chosen profile under $DSH_HOME/a_hallucination/state.json. Nothing is sent
anywhere.
Known limitations
- Turn-end verification audits completion language, not arbitrary claims; without
structured claims most invariants report
unchecked. - V8 depends on the runtime logging the approval audit pair (
approval/asked+approval/decided). A deployment that never logs them reports every ask as unconfirmed, so an approved call still fails V8 until a decision is observed. - No automatic rewrite loop: the runtime cannot append to a closing turn, so a failing audit is reported, never enforced.
- The contract's character count shown in the settings page is rendered against the full tool list; a given request may assemble a smaller tool set.