This plugin locates the root cause of a failed DeepSeek Harness agent session and produces a shareable diagnostic report.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:jiel521125/dsh-anlayzer
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
天枢 (TianShu, "Celestial Pivot") — the pivot star of the Big Dipper, used to locate the North Star. This plugin locates the root cause of a failed DeepSeek Harness agent session and produces a shareable diagnostic report.
TianShu combines a zero-cost rule engine (10 failure modes, no LLM calls) with an optional LLM deep-diagnosis layer that reuses the session's own model route — no extra API key required.
Features
- Rule engine (10 failure modes) — tool-error loops, identical-call dead loops, max-tokens truncation, sandbox denials, approval blocks, LLM errors/aborts, prompt-injection signals, token burn, no-progress stalls.
- LLM deep diagnosis — asks the session's own model "why did this fail?" with the rule
findings as structured context. Reuses the route from
assistant/messageprovenance. - Agent tool —
diagnose_sessionlets the agent self-diagnose a failed task and retry smarter. - Auto-trigger — subscribes to
turn/endand runs analysis automatically onerror/blocked/interrupted/abortedoutcomes. - Markdown reports — persisted to
~/.dsh/tianshu-reports/, ready to paste into a GitHub Issue. - Web UI panel — injects a "⚕︎ Diagnose" button into the session header; opens a panel showing findings, tool-call heat map, fork points, and the LLM diagnosis.
Quick Start
Prerequisites
- Node.js ≥ 20
- pnpm ≥ 9
- DeepSeek Harness (the
dshCLI, or a local clone of the harness repo)
1. Install
git clone <this-repo-url> tianshu-analyzer
cd tianshu-analyzer
pnpm install
pnpm build # produces lib/ (host ESM + browser CJS bundle)
2. Load into DSH
TianShu ships with a Cordis patch overlay that inserts it into an active DSH profile:
dsh web --patch ./cordis.patch.yml
That's it — open http://127.0.0.1:3080, pick any session, and click the ⚕︎ Diagnose button in the session header.
3. (Optional) Tune thresholds
Edit cordis.patch.yml — every config key is documented inline. See the Configuration table below for the full reference.
Usage
TianShu can be triggered in four ways. They all share the same engine and produce the same
DiagnosisReport.
A. Web UI panel (interactive)
- Open DSH Web (
dsh web). - Open any session.
- Click ⚕︎ Diagnose in the session header utilities slot.
- The panel opens. Toggle "LLM deep diagnosis" if you want the LLM layer, then click Analyze.
- Findings, heat map, fork points, and the Markdown report render inline.
B. Auto-trigger (hands-off)
Enabled by default. Whenever a turn/end event arrives with reason error / blocked /
interrupted / aborted, TianShu runs the analysis in the background and:
- Writes a Markdown report to
~/.dsh/tianshu-reports/<sessionId>-<timestamp>.md - Caches the report in memory (the Web UI reads it via the
/tianshuRPC channel) - Emits a
tianshu/reportevent other plugins can subscribe to
To disable auto-trigger, set autoTrigger: false in cordis.patch.yml.
C. Agent tool (self-diagnosis)
The agent itself can call the diagnose_session tool:
diagnose_session(sessionId: "<session-id>", useLlm?: boolean)
Returns a structured summary the agent can use to retry smarter (e.g., avoid the tool it was looping on, or request a model route change). The agent does not need an LLM call to use this — the rule engine runs synchronously and is free.
D. Programmatic (host-side)
Other DSH host plugins can read the in-process service directly:
// In any host plugin that declares `inject: ['tianshu']`
const report = await ctx.tianshu.analyze(sessionId, { useLlm: true })
const cached = await ctx.tianshu.getReport(sessionId)
const all = await ctx.tianshu.listReports()
const markdown = await ctx.tianshu.readMarkdown(sessionId)
Note:
ctx.tianshuis host-process only. Browser client code must call the host via the generic Connection RPC channel — see Architecture below.
Configuration
All config lives in cordis.patch.yml. A patch replaces the targeted row's
whole config, so every key below is authoritative when the patch is active.
| Key | Default | Description |
|---|---|---|
autoTrigger |
true |
Auto-run analysis on failed turn/end events |
autoTriggerReasons |
[error, blocked, interrupted, aborted] |
Which turn/end reasons trigger |
llmDiagnose |
true |
Enable LLM deep diagnosis (needs ctx.llm) |
llmMaxTokens |
2048 |
Output cap for the diagnostic LLM call |
llmTimeoutMs |
30000 |
Per-call deadline (ms) |
provider |
(unset) | Override the model provider; omit to reuse the session's |
model |
(unset) | Override the model id; omit to reuse the session's |
reportDir |
~/.dsh/tianshu-reports |
Where Markdown reports are saved |
keepReports |
50 |
Max report files retained (oldest pruned) |
rules.<id>.enabled |
true |
Toggle individual rules |
rules.<id>.threshold |
rule-specific | Loop detection thresholds (see below) |
Rule thresholds
| Rule | Key | Default | Meaning |
|---|---|---|---|
toolErrorLoop |
threshold |
3 |
Same tool errored N times → finding |
toolResultLoop |
threshold |
3 |
Same tool + identical args called N times → dead loop |
tokenBurn |
inputThreshold / outputThreshold |
50000 / 100 |
Single call: >50k input, <100 output → burn |
noProgress |
windowSteps |
5 |
N consecutive steps with shrinking assistant output → stall |
Failure Modes
| id | severity | What it detects |
|---|---|---|
tool-error-loop |
major → critical | Same tool errored ≥ threshold times |
tool-result-loop |
critical | Same tool + identical args called ≥ threshold times (dead loop) |
max-tokens-truncated |
major | turn/end.reason.kind === 'max-tokens' |
sandbox-denied |
major | Tool result contains permission/sandbox denial |
approval-blocked |
major | turn/end.reason.kind === 'blocked' |
llm-error |
critical | turn/end.reason.kind === 'error' with failure code |
llm-aborted |
critical | turn/end.reason.kind === 'aborted' |
prompt-injection-signal |
major | User message contains injection patterns |
token-burn |
minor | Single call: >50k input tokens, <100 output |
no-progress |
major | N consecutive steps with shrinking assistant output |
How It Works
turn/end (reason=error|blocked|interrupted|aborted)
│ auto-trigger (or: Web UI click, or: agent tool call)
▼
ctx.sessionQuery.readSession(id) → events[]
│
├─► [Rule engine] → findings[] (failure mode + evidence + fix)
│ (no LLM call — free, synchronous)
│
└─► [LLM diagnose] (optional)
│ reuses the session's own model route (no extra API key)
│ ctx.llm.stream({ purpose: 'session-title', ... })
▼
DiagnosisReport
│
├─► Markdown file (~/.dsh/tianshu-reports/<sid>-<timestamp>.md)
├─► In-memory cache (Web UI reads via /tianshu RPC channel)
├─► Tool result (agent receives a structured summary)
└─► tianshu/report event (other plugins can subscribe)
Architecture
src/
├── index.ts # Host entry: tool + auto-trigger + server API + /tianshu RPC channel
├── config.ts # Config schema + validation
├── types.ts # Shared types (Finding, DiagnosisReport, …)
├── analyzer/
│ ├── session-loader.ts # Load events from ctx.sessionQuery (live + persisted)
│ ├── rule-engine.ts # 10 rules + heat map + fork-point recommender
│ └── llm-diagnoser.ts # Reuse ctx.llm + session route for deep diagnosis
└── report/
├── markdown.ts # Render DiagnosisReport → Markdown
└── store.ts # Persist to disk + in-memory cache for the UI
client/
├── index.ts # Browser entry: locale + slot injection + RPC client
├── HeaderAction.tsx # The "⚕︎ Diagnose" button in the session header
├── Panel.tsx # The diagnosis panel (findings, heatmap, forks, LLM)
└── locales.ts # en / zh strings
Host ↔ Browser bridge
DSH has no automatic host→client service bridge. ctx.provide('tianshu', api) is
process-local (host-only). TianShu bridges the browser to the host via the generic
Connection RPC channel /tianshu:
- Host (src/index.ts) registers
ctx.connection.rpc.handle('/tianshu', …)withauthority: 'trusted-host'and dispatchesanalyze/getReport/listReports/readMarkdownendpoints. - Browser (client/index.ts) declares
inject: ['connection']and callsctx.connection.rpc.call('/tianshu', endpoint, payload), unwrapping theRpcResultenvelope.
No separate API key or proxy is needed — the channel rides DSH's existing trust fence.
Build
pnpm build # one-shot build (host ESM + browser CJS bundle)
pnpm watch # rebuild on change (dev)
pnpm typecheck # tsc --noEmit
The build produces two artifacts under lib/:
| Output | Format | Loaded by |
|---|---|---|
lib/index.mjs + *.d.mts |
ESM | DSH host (Node) |
lib/client.js |
CJS factory | DSH browser shell via window.__ModuleLoader__.load({ id, factory }) |
Troubleshooting
"loaded without registering via ModuleLoader.load"
The browser bundle must be a CJS factory wrapped in window.__ModuleLoader__.load({ id, factory }).
This is handled by tsdown.config.ts — if you fork the build config, keep the
banner / intro / footer that emit the wrapper.
"cannot get property 'tianshu' without inject"
The browser client must declare inject: ['connection'] (it reads ctx.connection.rpc, not
ctx.tianshu). The host-side ctx.tianshu is process-local and never crosses to the browser.
"cannot get property 'sessionQuery' without inject"
The host plugin must declare inject: ['tools', 'llm', 'sessionQuery', 'sessions']. Missing any of
these raises this error at the first access.
"⚕︎ Diagnose button not visible"
- Confirm the patch is active:
dsh web --patch ./cordis.patch.yml - Hard-reload the browser tab (the client bundle is revision-tagged; stale tabs may cache the old
client.js). - Check the browser console — the slot error boundary retries once on connection-ready.
Author
Zhou Long (Tianshu Intelligent / 天枢智能)
- WeChat:
longling1031 - Email:
1033085514@qq.com - Location: Pinghu, Jiaxing, Zhejiang, China
- Blog: https://www.zhihu.com/people/tianshu_cn
License
MIT © Zhou Long (Tianshu Intelligent / 天枢智能)
Links
More in this category
Tencent/WeKnora#dsh-weknora★ 21359
Four read-only tools over a WeKnora knowledge base: list knowledge bases, hybrid passage search, reassemble one document's chunks in order, and WeKnora's own cited RAG or ReAct-agent answer with a resumable session id.
superdesigndev/treg★ 1189
Tool catalog for agents: search ~2,600 external endpoints (SEO and SERP, backlinks, social, people and company enrichment, ad libraries, scraping) by the task you want done, read each one's parameters and per-call price, then call it with the credential injected server-side. Ships the skill plus an MCP row that stays disabled until TREG_TOKEN is set.
anysearch-team/anysearch-dsh★ 399
AnySearch-powered real-time web and vertical search provider for DeepSeek Harness.
EthanYoQ/Invoice-Downloader#dsh-invoice-downloader★ 379
Local IMAP invoice download, OCR, archive, and Excel reimbursement summaries for DeepSeek Harness.
omdsh-dev/dsh-data-agent★ 184
Let the AI connect to databases and write SQL for you.
zhaoolee/notes#dsh-plugin★ 158
Export DSH conversations as Smartisan Notes-style PNGs, or create and update Markdown notes in a configured account-scoped workspace.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.