Skip to main content
J

dsh-a-hallucination

jasper-alaric/dsh-a-hallucination

Runtime evidence discipline for DeepSeek Harness that does not rely on the model agreeing with itself. A bounded anti-hallucination contract is injected as one short system-prompt section, and four checks run outside the model: a ledger written only by real tool dispatches, so an entry cannot be fabricated; a provenance gate that records (and in the strict profile refuses) a call whose path, URL, id, account, or amount has no origin in the session; a risk gate that holds destructive, outward-facing, or paid tools, plus shell commands that delete, publish, or send, for confirmation; and an injection shield that marks web, file, MCP, and A2A output as data rather than instructions, counting instruction-like fragments it finds. Before sending an answer the model calls answer_verify with one claim per assertion, each citing a ledger id and the exact quoted excerpt; the verifier compares quotes against the stored result, so a fabricated number fails even when a tool call did happen. Time-sensitive claims (price, incumbent, version, current) must cite evidence inside an age limit. Every verdict reports the verification level it applied (light, standard, strict) and the output form the answer should take (direct, annotate, or abstain with what is missing), plus running metrics such as verification counts, pass rate and quote rate, and the Settings panel shows those same counts in plain language. Three profiles cover the tradeoff: observe only records, inspect also blocks and annotates, adjudicate additionally refuses untraceable targets, and the Settings panel labels the three of them 静观 (observe), 明察 (inspect) and 断案 (adjudicate). Ships a plain-language Settings panel with a collapsible technical section, durable profile selection, and a read-only ledger_view tool. No embedding service, no vector database, no network calls, no runtime dependencies.

Install

dsh plugin --profile web add github:jasper-alaric/dsh-a-hallucination

README

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

LayerBehaviour
ContractOne bounded anti-hallucination section in the system prompt: evidence order, claim rules, output shape, boundaries.
LedgerEvery 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 gateA 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 gateDestructive, outward-facing, or paid tools — and shell commands that delete, publish, or send — require confirmation.
Injection shieldOutput 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 auditAt the end of a turn the runtime checks whether completion language ("已执行", "already published") matches a successful call in that turn.
Settings pagePlain-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

ProfileContractLedgerUntrusted markingRisk confirmationProvenance recordProvenance refusalTurn-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

KeyDefaultMeaning
modeinspectProfile id or one of the display labels.
promptLocalezhLanguage of the injected contract (zh or en).
persistModetrueKeep the selected profile across restarts; set false for an ephemeral instance.
stateDir$DSH_HOME/a_hallucinationWhere the chosen profile is stored.
contractOrder240Sort order of the contract prompt section.
maxRewrite2Parsed rewrite budget (0–5); no automatic rewrite loop is implemented.
maxRetry2Retry count the contract tells the model to respect (1–5).
maxEvidenceAgeHours24Age 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.
untrustedToolsReplacefalseReplace the built-in external-tool list instead of extending it.
traceableParams[]Extra parameter keys checked for provenance.
traceableRootscwd + $DSH_HOMEPaths 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.

Related plugins