DeepSeek Harness Plugin

kittimzhe/dsh-session-eval

Stars ★ 0 Downloads (30d) 2,364 Category Sessions & Messages Added 2026-10-17 npm dsh-session-eval

Retrospective agent-session evaluation — grades the sessions that already happened: deterministic grade cards, regression diffs, /eval-history trends, and /eval --report straight from exported artifacts; no benchmark runs, no LLM judges.

Install

# from npm (prebuilt)

dsh plugin --profile web add dsh-session-eval

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:kittimzhe/dsh-session-eval

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

English | 中文

tests

Retrospective evaluation for DeepSeek Harness agent sessions — deterministic grade cards computed from sessions that already happened, plus cross-session regression diffs that answer "did my agent get better or worse after that plugin / prompt / model change?"

No benchmark suites to author. No LLM judges. No new runs. Every grade is a fixed, documented threshold over persisted session logs — fully reproducible.

Install

Requirements: Node.js 20 or 22 · a DeepSeek Harness profile that mounts the commands and sessionQuery services (the shipped web / agent profiles qualify).

dsh plugin --profile web add dsh-session-eval

Or from GitHub:

dsh plugin --profile web add github:kittimzhe/dsh-session-eval

The bundle overlay mounts /eval, /eval-diff, /eval-history, and /eval-baseline. If you maintain your own cordis.patch.yml, keep this row:

- insert:
    - id: session-eval
      name: 'dsh-session-eval'

Try it once

In DeepSeek Harness:

/eval
Session eval — a1b2c3d4… (dsh-session-eval v0.6.0)
Overall: A
  Reliability    A    2/87 tool results errored (2.3%)
  Re-ask         A    1 re-ask signal(s) over 23 turns (0.4/10 turns)
  Tool load      B    3.8 tool calls per turn
  Evidence order A    1/18 turns answered before evidence (5.6%)
Notes:
  • Wall time 41.2 min over 23 turns.

The measurement layer of the session toolchain

Plugin Layer Answers
dsh-session-export Evidence "What exactly happened in this session?"
dsh-session-recall Memory "What did I do before, and where is it?"
dsh-session-eval Measurement "Was that session good? Is the trend improving?"

All three read through the same trusted ctx.sessionQuery seam, so any persistence backend (JSONL or SQLite) works without touching raw artifacts.

Evidence-handoff closure (#8)

/eval --report grades straight from an artifact dsh-session-export already wrote — no session id to copy, and it works after the session is gone from the store:

recall "resume template font"
→ session session-ca62e005-… · report /proj/dsh-transcripts/bundle-ca62e005-20261104-120000.zip

/eval --report /proj/dsh-transcripts/bundle-ca62e005-20261104-120000.zip

Bundle ZIPs (the nested archive.zip raw JSONL) and raw /archive ZIPs are both accepted. The JSONL inside is the canonical event log — the same bytes readSession returns — so --report grades identically to /eval --id (verified by a round-trip test against the real dsh-session-export writer). --id and --report are mutually exclusive.

Baselines & format guardrails

/eval-baseline pins grade cards per workspace and compares later sessions against them:

/eval-baseline set            # grade the current session, save it as the baseline
/eval-baseline compare        # grade the current session, diff vs the latest baseline
/eval-baseline list 10        # newest-first list of saved records (default 5)
/eval-baseline clear          # delete the store (prints how many records it removed)

set and compare accept --id <sessionId> to grade another session, with the same default-to-current-session semantics as /eval. Records live in <session cwd>/.dsh-evals/baseline.jsonl — one JSON line per record, append-only. Each record carries the timestamp, session id, full metrics, the complete grade card, the generator version (dsh-session-eval v…), the session format version, and a fingerprint of the grade bands that were active when it was written (sha256 over version + bands, 16 hex — a gradeBands config change is therefore visible to compare). The store is read defensively: unparseable lines are skipped and counted, never fatal.

compare reuses /eval-diff's noise-tolerant comparison, so a ±2pp error-rate wiggle is flat, not a regression; per-dimension verdicts come with the signed delta against the baseline (percentage points for Reliability, raw metric units for the others).

Three guardrails keep the numbers honest:

  • Version stamping: /eval --json and --id outputs carry a top-level sessionFormatVersion read from the session header (null when unavailable — including every --report grade, since an archived JSONL has no header).
  • Zero-projection warning: when a raw log has events but none of them project into the evaluation vocabulary, the card says so — "Projected 0 events from a non-empty log; session format may have drifted from what this version understands" — instead of silently grading zeros.
  • Cross-version comparison warning: /eval-baseline compare prints "baseline recorded under …, current …; comparison crosses versions" before its verdict whenever the recorded generator version, bands fingerprint, or session format version differs from the current run — the comparison still runs, but you can't mistake it for an apples-to-apples one.

Contributing

  • Local dev: npm ci && npm run typecheck && npm test && npm run bundle (Node 20 or 22).
  • Start in the source: src/grade.ts (thresholds, grade cards), src/metrics.ts (metric extraction), src/trend.ts (/eval-history trend logic). See CONTRIBUTING.md for the source map and first-PR suggestions.
  • Open gaps: #1 (configurable thresholds) and #2 (/eval-history --since) shipped in v0.3.0 — browse issues labeled good first issue.
  • Rules: behavior changes need tests; doc changes must update README.md and README.zh.md in sync; version releases belong to the maintainer. Details: CONTRIBUTING.md.

How it differs from benchmark-style evaluation

dsh-eval (benchmark) dsh-session-eval (this)
Evaluates Runs you launch ahead of time Sessions that already happened
Setup Author benchmark YAML + cases None — read existing logs
Judge Metric folding over trials Fixed thresholds, deterministic
Best at Pre-deploy benchmarks Regression tracking over real work

Both are useful; they don't compete. Benchmarks test what you predicted; retrospective evaluation watches what actually happened.

Commands

Command Effect
/eval Grade card for the current session
/eval --id <sessionId> Grade a specific session
/eval --report <bundle-or-archive.zip> Grade from an exported artifact (works after the session is gone from the store)
/eval --json Machine-readable metrics + card, with sessionFormatVersion
/eval-diff <beforeId> <afterId> Regression comparison, noise-tolerant
/eval-diff … --json Machine-readable trend report
/eval-history [N] Grade the last N sessions in this workspace and show the trend
/eval-history … --json Machine-readable history report
/eval-history --since 7d Grade only sessions with activity inside the window (24h, 30d also parse)
/eval-baseline set [--id <sessionId>] Save the current (or given) session's grade card as this workspace's baseline
/eval-baseline compare [--id <sessionId>] Diff the current (or given) session against the latest baseline, with signed deltas
/eval-baseline list [N] List the last N baseline records, newest first (default 5)
/eval-baseline clear Delete the baseline store, reporting how many records it removed

--since filters by each session's latest activity, not its creation time: a session opened long ago but active an hour ago stays in the window; a freshly created but silent one drops out. With --since 7d the trend compares the first and last of the in-window set, and an empty window prints a clear message instead of a crash. Without the flag, behavior is exactly as before (last N sessions).

Use /eval-history --out report.md to save the terminal card as Markdown, or add --json to save the JSON payload. Relative paths resolve against the current session workspace (the process working directory when unavailable). Parent directories must already exist; file errors are reported without creating directories. Existing output files are overwritten.

/eval-history finds the sessions for you via the same sessionQuery seam /archive uses (scoped to the current workspace's cwd), grades each, and diffs the first against the last. /eval-diff remains the tool when you already know the two ids that matter.

Configuring grade bands

The thresholds are defaults, not laws. A gradeBands block under the plugin's config node (naturally per-profile) overrides any dimension — values are the A–D upper bounds, ascending:

session-eval:
  gradeBands:
    reliability: [4, 8, 15, 30]     # tool error-rate percent
    reask: [0, 2, 4, 8]             # corrections per 10 user turns
    toolLoad: [0.1, 0.5, 8, 20]     # tool calls per turn: [lowC, lowB, highC, highD]
    evidenceOrder: [10, 30, 50, 70] # answered-before-evidence percent

Any subset may be overridden; unlisted dimensions keep the documented defaults. Unknown keys, wrong arity, non-numeric, negative, or non-ascending values fail fast at plugin load with a readable error — sessions are never graded against bands nobody chose.

Typical use: grade the ten sessions before and after a plugin or prompt change; a persistent Reliability regression is an early warning that the change hurt real work, not just benchmarks.

Dimensions & thresholds

All grades derive from four deterministic metrics. n/a when the session lacks the relevant activity.

Dimension Metric A B C D E
Reliability tool error rate ≤5% ≤10% ≤20% ≤35% >35%
Re-ask corrections per 10 turns¹ 0 ≤1 ≤2 ≤4 >4
Tool load tool calls per turn 0.5–8 0.1–0.5 or just above 8 <0.1 or 8–20 >20 —
Evidence order answered-before-evidence rate² ≤10% ≤30% ≤50% ≤70% >70%

¹ A correction signal is each extra user message inside a consecutive-user run — the human re-asking before any assistant reply, a behavioral proxy for "the agent didn't get it right the first time."

² See Why answer-only grading is not enough.

Overall is the worst graded dimension — conservative by design. Thresholds are constants in src/grade.ts; making them configurable is on the roadmap (see issues).

Diff verdicts include a noise band (±2pp error rate, ±0.5 re-ask, ±1 tool load, ±10pp evidence order) so trivial jitter doesn't cry regression.

Why answer-only grading is not enough

A session can produce the right final answer along the wrong path: the model answers first, then fetches evidence that happens to agree. Reliability, Re-ask, and Tool load are aggregates — they see how much tool traffic happened, never when it happened relative to the answer. Two sessions with identical turn counts, tool counts, error rates, and final answers can still differ in whether the answer was grounded.

Evidence order measures exactly that, deterministically:

  • A turn is the event run between one user message and the next.
  • A turn is evidence-eligible when it holds at least one assistant message and one non-error tool result — turns with no tools cannot be judged, and errored calls prove nothing.
  • The answer message is the turn's assistant message with the longest visible text (ties break to the later message, since a final answer tends to come last). Interjections like "let me check" are short by comparison, so they don't mask the real answer.
  • The turn counts against the session when the answer message precedes the turn's first non-error tool result — the agent committed to a conclusion before looking.
  • Turns whose assistant content the adapter cannot read are excluded and noted, never guessed at.

The defaults are deliberately lenient (E only above 70%) because answering before evidence is sometimes legitimate — the human may ask for a guess-then-verify on purpose. Tighten evidenceOrder bands in config when your workflow forbids it.

This is the same class of check agent-inspect ships for TypeScript agents as instrumented trajectory contracts — including their broken-agent-debugging starter, whose same-answer/wrong-path fixture and typed step-order relation (e65e944, d9ab3e9) this dimension mirrors. The difference: no instrumentation required — it is computed retroactively over session logs that already exist, so yesterday's sessions can be graded for path discipline today.

Determinism guarantee

Same session logs in → same grade card out, every time, forever. There is no model in the loop, no sampling, no clock dependence in the metrics (wall time is reported, never graded). This is what makes /eval-diff trustworthy as a regression signal.

Development

npm ci
npm run typecheck   # tsc --noEmit
npm test            # vitest run
npm run bundle      # tsdown → lib/

License

MIT

Community

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.