DeepThonk

io.github.linxule由 GitHub 帳號 linxule 發布v0.4.0更新於 Nov 8, 2026

Provider-neutral OpenDeepThink reasoning server: generate, judge, rank, mutate.

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

與供應商無關的「深度思考」推理伺服器,透過 OpenDeepThink 迴圈產生、評判、排序並變異候選答案。

可以做什麼
  • 規劃並執行推理任務:估算呼叫數與輪次、背景啟動執行、輪詢狀態、取得勝出答案、取消或續跑
  • 對使用者提供的候選集進行成對評判與 Bradley-Terry 排序,或對單一候選做批評式變異
  • 以 MCP 資源檢視執行產物:設定、候選、比較、評分、用量、追蹤、族群快照與提示詞
  • 管理已儲存的具名設定組合:列出、檢視、儲存與刪除
  • 將執行摘要或完整追蹤匯出為 JSON 或 markdown
適用情境
適合程式撰寫、規劃、綜合等困難且可驗證的任務,此時廣度加上評判可能優於一次昂貴的單次呼叫。對評判雜訊占主導的高度主觀任務不宜使用。
執行需求
本機需 Node.js 22.13 或更新版本,透過 npx 或全域 npm 安裝執行。需在宿主行程環境中提供供應商 API 金鑰(DEEPSEEK_API_KEY、OPENROUTER_API_KEY,或自訂 OpenAI 相容端點的 DEEPTHONK_API_KEY),也可使用支援 MCP sampling 的宿主或離線的 fake 供應商。選用 DEEPTHONK_CONFIG 與 DEEPTHONK_PROFILES_DIR 路徑。付費供應商需要網路存取。
安裝前請注意
執行會呼叫付費模型:paper 設定預計 285 次模型呼叫,請先檢視計畫與供應商定價,並使用呼叫數、token 與美元上限等預算限制。token 與美元總額可能超出最多一個並行視窗。候選答案、批評、評分與最終產物依設計會被儲存與匯出,敏感任務不要使用共用執行目錄。選用的 HTTP 傳輸僅限本機回環且無 bearer 認證,不要透過反向代理對外暴露。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 DeepThonk,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

DeepThonk

thonk harder, not richer.

DeepThonk implements the OpenDeepThink algorithm (Zhou et al., 2026, arXiv:2605.15177) as a budget-friendly, provider-neutral "deep think / pro mode" wrapper, with first-class DeepSeek support. See Acknowledgments.

DeepThonk runs a population of candidate answers through pairwise judging, Bradley-Terry ranking, critique-guided mutation, elite preservation, and a final dense ranking pass. The CLI and MCP server both call the same TypeScript core engine.

Designed for agents. Every algorithm dimension — population shape (n, k, t, m), regularization (lambda), per-phase temperatures, prompt style, and per-phase prompt templates — is reachable inline through MCP arguments and CLI flags. CLI can load prompt files with --prompts or inline JSON with --prompts-json; MCP accepts inline structured prompt args. Every intermediate artifact (config, candidates, populations, comparisons, scores, per-call usage, status) is exposed as an MCP resource so an agent can inspect any step. See Customization for the full agent-composable surface.

Use it for hard, verifiable reasoning, coding, planning, and synthesis where breadth plus judgment can beat one expensive single shot. Avoid it for highly subjective tasks where judge noise dominates.

Quickstart

Requires Node ≥ 22.13.

Run without installing:

bash
npx -y deepthonk plan --profile papernpx -y deepthonk run --provider fake --profile quick \  --task "Find the smallest positive integer divisible by 3, 4, and 5." \  --out runs/test-quicknpx -y deepthonk inspect runs/test-quick

Or install globally:

bash
npm install -g deepthonkdeepthonk plan --profile paper

The paper profile plans 285 model calls and 8 sequential rounds. Confirm budget and provider pricing before pointing it at paid models. The short alias dt is installed alongside deepthonk. Develop from source: see Development.

DeepThonk is an independent TypeScript reimplementation and practical integration layer; the published algorithm is the load-bearing part. Cost guarantees rely on provider pricing being present in config. Trace-v2 resume can reuse validated per-item receipts after a crash, while older traces replay an incomplete phase wholesale. The MCP HTTP transport remains loopback-only. The included acceptance smoke uses the deterministic fake provider and a toy task — it is not a CF-73 / HLE reproduction; see docs/ and Acknowledgments for the canonical paper and Python reference.

Setup

Create a reusable local config:

bash
deepthonk setup \  --provider deepseek \  --api-key-env DEEPSEEK_API_KEY \  --fast-model deepseek-v4-flash \  --judge-model deepseek-v4-pro

By default this writes ~/.config/deepthonk/config.yaml. deepthonk run loads that file automatically when --config is not supplied. If you pass --api-key, setup stores it in ~/.config/deepthonk/env; otherwise it uses the named environment variable from your shell.

DeepSeek

bash
export DEEPSEEK_API_KEY=...deepthonk run \  --task task.md \  --profile paper \  --provider deepseek \  --generator-model deepseek-v4-flash \  --mutator-model deepseek-v4-flash \  --judge-model deepseek-v4-pro \  --out runs/task-paper

DeepSeek is implemented as an OpenAI-compatible profile using https://api.deepseek.com/v1. DeepThonk ships default USD pricing for deepseek-v4-flash and deepseek-v4-pro from the official DeepSeek pricing page, including cache-hit/cache-miss input rates. Model names and prices are still editable config because both can change.

Before paid runs, inspect cost shape and resolved config:

bash
deepthonk plan --config ~/.config/deepthonk/config.yamldeepthonk run --task task.md --config ~/.config/deepthonk/config.yaml --profile quick --dry-run

Start with --profile quick and consider --max-concurrency, --max-calls, --max-input-tokens, --max-output-tokens, --max-usd, and --request-timeout-ms before larger paid profiles. max_calls is reserved before dispatch and counts logical model invocations, including failed calls and invalid-JSON retries; provider-internal HTTP retries are reported separately. Token/USD totals are known only after responses and can overshoot by at most the active concurrency window. Plans keep nominal calls separate from finalizer and retry headroom in worst_case_calls.

OpenAI-Compatible Providers

bash
export DEEPTHONK_API_KEY=...deepthonk run \  --task task.md \  --profile balanced \  --provider openai-compatible \  --base-url https://provider.example.com/v1 \  --api-key-env DEEPTHONK_API_KEY \  --generator-model cheap-model \  --judge-model strong-model

The driver calls POST {base_url}/chat/completions and requests JSON mode for comparisons when supported. If a provider returns 400 or 422 with a body that mentions response_format or json, the driver retries without JSON mode, coordinates that capability probe across concurrent calls, and remembers the result for the process. Set supports_json_mode: false in YAML to disable JSON mode up front.

Provider names are flexible. For a custom OpenAI-compatible endpoint, use any provider label with --base-url, --api-key-env, and role-specific model flags. For OpenRouter:

bash
export OPENROUTER_API_KEY=...deepthonk run \  --task task.md \  --profile balanced \  --provider openrouter \  --generator-model openrouter/auto \  --mutator-model openrouter/auto \  --judge-model openrouter/auto

For mixed-provider runs, use YAML config and override individual roles under providers, especially judge.

Optional finalizer_model / --finalizer-model can post-process the ranked winner. Leave it unset when you want the raw ranked answer as the final artifact.

MCP

The MCP server exposes the same engine the CLI runs. Once wired into an MCP host, the host can plan budgets, kick off background runs, poll status, fetch winners, and stream structured trace artifacts — all through MCP tools, resources, and prompts.

DeepThonk is listed on the MCP Registry as io.github.linxule/deepthonk (since v0.2.1). Hosts that install by registry name resolve it to npx deepthonk serve-mcp automatically. For hosts that don't, the explicit configs below do the same thing by hand.

Provider API keys come from the host process's environment, not from DeepThonk's config alone. Each host handles env passthrough slightly differently — see the concrete patterns below. No key is required to start the server: with a sampling-capable host you can run provider: "sampling", and the fake provider needs no network at all.

MCP Sampling is supported as provider: "sampling" when the connected host advertises the MCP sampling capability. Blocking run, rank, and mutate work over stdio and stateful Streamable HTTP. HTTP background start rejects Sampling because nested Sampling must remain attached to the initiating request; stdio background runs and direct-provider HTTP background runs remain available. Sampling is not available from standalone CLI runs.

Claude Code

bash
claude mcp add deepthonk \  -e DEEPSEEK_API_KEY=$DEEPSEEK_API_KEY \  -- npx -y deepthonk serve-mcp --transport stdio

Use -s user for cross-project scope or -s project to commit registration into .claude/. Verify with claude mcp list. See claude mcp --help for the authoritative flag set.

Claude Desktop

Config path: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS), %APPDATA%\Claude\claude_desktop_config.json (Windows), ~/.config/Claude/claude_desktop_config.json (Linux). Add:

json
{  "mcpServers": {    "deepthonk": {      "command": "npx",      "args": ["-y", "deepthonk", "serve-mcp", "--transport", "stdio"],      "env": {        "DEEPSEEK_API_KEY": "sk-..."      }    }  }}

Restart Claude Desktop after editing.

Cursor

Project-scoped: .cursor/mcp.json in the workspace. User-global: ~/.cursor/mcp.json. Same JSON shape as Claude Desktop:

json
{  "mcpServers": {    "deepthonk": {      "command": "npx",      "args": ["-y", "deepthonk", "serve-mcp", "--transport", "stdio"],      "env": { "DEEPSEEK_API_KEY": "sk-..." }    }  }}

Other MCP hosts (stdio)

Any host that speaks MCP stdio launches:

bash
npx -y deepthonk serve-mcp --transport stdio

with the relevant provider env vars set on the process. If you'd rather install globally, npm install -g deepthonk then use command: "deepthonk" directly. Refer to the host's MCP registration docs for the configuration shape.

Streamable HTTP

For local web hosts, or when stdio isn't available:

bash
deepthonk serve-mcp --transport http --port 3333 \  --max-active-jobs 2 --max-queued-jobs 32

The server binds 127.0.0.1:3333 only and exposes stateful POST, GET, and DELETE at http://127.0.0.1:3333/mcp. Sessions use cryptographic IDs, expire after 30 idle minutes when no request is active, and are capped at 64. DNS rebinding protection is on (CVE-2025-66414): requests with Host headers outside 127.0.0.1:3333 / localhost:3333 are rejected. The wrapper also rejects non-JSON POSTs, non-loopback Origin headers, and Sec-Fetch-Site: cross-site before reading the body. It has no bearer auth. Do not expose this port through a reverse proxy without re-evaluating that trust boundary.

Tools

ToolPurpose
deepthonk.planEstimate calls and sequential rounds for a profile (no model calls). Use before paid runs.
deepthonk.startStart a run in the background; returns run_dir, job_id, and job-scoped artifact resources.
deepthonk.statusPoll job status from a run_dir.
deepthonk.resultReturn final summary + winner once a job is complete.
deepthonk.cancelRequest cancellation by writing cancel.json into the run directory.
deepthonk.lock_inspect / deepthonk.lock_reclaimInspect lock ownership and explicitly reclaim only an exact fingerprint.
deepthonk.repair_budgetReplace legacy [redacted] numeric budget fields with explicit original values.
deepthonk.runBlocking convenience: start + await completion in one call. Prefer start + polling for long-running jobs.
deepthonk.rankRank a user-supplied candidate set with pairwise judging + Bradley-Terry (skip generation).
deepthonk.mutateMutate one supplied candidate with critique (one-shot).
deepthonk.resumeDetect whether a run can be resumed; with continue: true, replay from the last validated phase boundary.
deepthonk.exportExport run summary or full trace in JSON or markdown.
deepthonk.profile_listList saved named profile bundles.
deepthonk.profile_showShow one saved profile; manually edited secret-shaped values are rejected on load.
deepthonk.profile_saveSave a reusable named profile bundle.
deepthonk.profile_deleteDelete a saved named profile bundle.

All tools accept inline provider/model fields, or config_path pointing at a DeepThonk YAML config.

Resources

  • deepthonk://runs — JSON index of all runs in runs/.
  • deepthonk://runs/{run_id}/summary — run summary (JSON).
  • deepthonk://runs/{run_id}/config — redacted run config (JSON).
  • deepthonk://runs/{run_id}/{candidates|comparisons|scores|usage|trace} — per-phase and per-call NDJSON.
  • deepthonk://runs/{run_id}/population/{generation} — population snapshot for a generation (JSON).
  • deepthonk://runs/{run_id}/{winner|final} — text artifacts.
  • deepthonk://runs/{run_id}/status — run state (JSON).
  • deepthonk://runs/{run_id}/prompts/{sha256} — verified content-addressed rendered prompt (JSON).
  • deepthonk://runs/{run_id}/trace-v2 — bounded phase index; follow its manifest, commit, checkpoint-index, and checkpoint URIs to inspect every receipt.
  • deepthonk://jobs/{job_id}/{status|result|config|candidates|comparisons|scores|usage|trace|final|winner}?run_dir=... — job-scoped lookup; the run_dir query param is required.
  • deepthonk://jobs/{job_id}/population/{generation}?run_dir=... — job-scoped population snapshots before or after completion.
  • Job results also include prompt_template and trace_v2_template for the job-scoped equivalents.
  • deepthonk://runs/{run_id}/{resource}/page/{cursor} and job equivalents — opaque bounded pages. Whole reads are limited to 1 MiB; pages contain at most 1,000 records and 1 MiB.

Prompts

Four templates mirror the core loop: deepthonk/generate, deepthonk/compare, deepthonk/mutate, deepthonk/finalize. Hosts can render them directly to drive the algorithm by hand without invoking the tool surface.

Limits

deepthonk.resume reports trace state by default. With continue: true, it validates phase order, artifacts, run/provider/model identity, scores, usage, deterministic pair schedules, trace-v2 receipts, and phase commits. Valid incomplete-phase receipts are reused without another provider call. MCP Sampling model hints are preferences and token usage may be unavailable. Its shared adaptive limiter starts at 4; direct providers start at 8.

Customization

Every algorithm dimension is reachable through MCP arguments and CLI flags:

  • Population shape: n, k, t, m — override profile defaults inline.
  • Algorithm constants: lambda, sample_temperature, mutate_temperature, judge_temperature.
  • Prompt style: general or paper-programming.
  • Per-phase prompt templates: override generate, compare, mutate, or finalize with custom system/user templates and variable substitution ({task}, {rubric}, {candidate}, {candidateA}, {candidateB}, {critique}). CLI supports --prompts <yaml> and --prompts-json <json>; MCP supports inline prompts. Unknown variables throw a fail-fast error at run-start.
  • Concurrency: per-phase caps for generate, judge, mutate.
  • Provider backpressure: provider_max_concurrency sets the recovery ceiling for the shared adaptive provider-route limiter.
  • Per-call output bounds: independent generation, mutation, judge, and finalizer token caps.
  • Final ranking schedule: seeded all-pairs or k-regular, with an explicit logical call cap.
  • Critique bound: deterministic deduplication and a configurable aggregate-character cap before mutation.

Example agent call (MCP), no YAML file required:

json
{  "task": "Draft a concise non-solicitation clause for a senior sales employee.",  "profile": "balanced",  "n": 6, "t": 1,  "provider": "deepseek",  "judge_model": "deepseek-v4-pro",  "prompts": {    "generate": { "system": "You are an experienced employment-law attorney." },    "compare":  { "system": "Prefer enforceable clauses under California law. Return strict JSON only." }  }}

CLI accepts the same surface. Use --prompts <yaml> for reusable prompt files or --prompts-json <json> for one-off inline overrides. MCP and CLI both merge over any --config/config_path YAML defaults.

Save reusable bundles as named profiles at ~/.config/deepthonk/profiles/<name>.yaml and load them with --profile-name <name> (CLI) or profile_name: "<name>" (MCP). A named profile is a standalone bundle that replaces the main config file for that run; CLI flags and MCP inline arguments still override fields inside it. See examples/profiles/legal-drafting.yaml for the shape. The Customization guide covers listing, showing, saving, and deleting named profiles from both CLI and MCP.

See the Customization guide for the complete variable contract, the compare-phase JSON safety rule, the named-profile schema, and three worked examples. Per-role provider routing (providers.judge.provider = openrouter) and per-model pricing remain YAML-only — they're nested structured config, not inline ergonomics.

Trace Files

A successful run writes:

txt
runs/{run_id}/  config.json  events.jsonl  candidates.jsonl  comparisons.jsonl  scores.jsonl  usage.jsonl  population-0.json  population-{generation}.json  manifests/*.json  checkpoints/*/*.json  commits/*.json  summary.json  artifacts/winner.txt  artifacts/final.txt  artifacts/prompts/<sha256>.json  # only when prompt capture is enabled

status.json is written when the run is launched through MCP deepthonk.start (so async clients can poll). cancel.json is written only when cancellation is requested. A run.lock file is held for the duration of the run.

Trace rows are batch-appended through a single writer and flushed before lifecycle boundaries. Per-item output and usage receipts are written atomically before a phase commit. If a run is killed mid-tournament, trace-v2 resume validates and reuses completed receipts, re-materializes their JSONL rows, and calls the provider only for missing or invalid work.

usage.jsonl carries one row per provider call (generator, judge, mutator, finalizer) with phase/role/provider/model/token/USD/latency/retry. It contains no prompt content. jq over usage.jsonl is the simplest way to break a run's cost down by role.

Prompts and raw model outputs are off by default. When prompt capture is enabled, candidate/comparison rows carry a promptRef and identical rendered prompts share one content-addressed blob under artifacts/prompts/; the full prompt is not repeated in every JSONL row or receipt. API keys are never written. Candidate answers, critiques, scores, and final artifacts are trace data and are stored/exported by design, so do not use a shared run directory for sensitive tasks unless that is acceptable.

Development

bash
pnpm installpnpm run buildpnpm testpnpm run lint

This repository is source-only. Generated run traces, paper notes, build output, coverage, logs, and node_modules are intentionally ignored.

Release publishing is tag-triggered through npm Trusted Publishing. See docs/release.md before bumping versions or pushing a v* tag.

Known limits for this release:

  • Trace-v1 resume replays an interrupted phase wholesale; per-item reuse requires a trace-v2 run created by DeepThonk v0.2.
  • HTTP Sampling is blocking-only. Use stdio or a direct provider for background deepthonk.start work.
  • maxUsd requires known model pricing; add explicit prices in YAML for custom providers and model IDs. Optional fields longContextThresholdTokens, inputUsdPerMillionLong, and outputUsdPerMillionLong enable tiered pricing for models with a long-context surcharge (e.g., Gemini at 200K input tokens). Cache hit/miss rates remain flat.

Acknowledgments

DeepThonk is an independent TypeScript reimplementation of the OpenDeepThink algorithm. It is not a fork; no source code from the reference implementation is vendored. Credit for the algorithm, the benchmark methodology, and the empirical results belongs to the paper authors.

  • Paper: Shang Zhou, Wenhao Chai, Kaiyuan Liu, Huanzhi Mao, Qiuyang Mang, Jingbo Shang. OpenDeepThink: Parallel Reasoning via Bradley–Terry Aggregation. arXiv:2605.15177, 2026. https://arxiv.org/abs/2605.15177
  • Reference Python implementation: https://github.com/ZhouShang0817/open-deep-think (MIT). This is the authors' code release and the canonical implementation for reproducing paper results (CF-73, HLE).

DeepThonk's contribution is an integration layer: a provider-neutral TypeScript core, an MCP server, a CLI, structured trace artifacts, and budget enforcement. The algorithm itself is theirs.

來源:README.md,提交 8713841

工具

17

deepthonk.plan

Plan DeepThonk Budget

Estimate model calls for a DeepThonk profile.

輸入參數kmntprofileconfig_pathprofile_name

deepthonk.start

Start DeepThonk Job

Start DeepThonk in the background and persist status in the run directory.

輸入參數kmntrankseedtask必填lambdarubricrun_idmax_usdprofile另有 30 個

deepthonk.status

DeepThonk Job Status

Read persisted job/run status from a run directory.

輸入參數job_idrun_dir

deepthonk.result

DeepThonk Job Result

Return final summary/resource URIs when a background job is complete.

輸入參數job_idrun_dir

deepthonk.cancel

Cancel DeepThonk Job

Request cancellation for a running job by writing cancel.json in the run directory.

輸入參數job_idrun_dir

deepthonk.lock_inspect

Inspect DeepThonk Run Lock

Inspect run.lock and return its exact fingerprint without mutating it.

輸入參數run_dir必填

deepthonk.lock_reclaim

Reclaim DeepThonk Run Lock

Reclaim run.lock only when its current bytes match the inspected fingerprint exactly.

輸入參數run_dir必填fingerprint必填

deepthonk.repair_budget

Repair Legacy Budget Config

Replace only legacy [redacted] numeric budget fields with explicit original values.

輸入參數run_dir必填replacements必填

deepthonk.run

Run DeepThonk

Run DeepThonk through the shared core engine.

輸入參數kmntrankseedtask必填lambdarubricrun_idmax_usdprofile另有 30 個

deepthonk.rank

Rank Candidates

Rank supplied candidates with pairwise judging and Bradley-Terry aggregation.

輸入參數ranktask必填lambdarubricprofilepromptsbase_urlprovidercandidates必填api_key_envconcurrencyconfig_path另有 15 個

deepthonk.mutate

Mutate Candidate

Mutate one supplied candidate with critique.

輸入參數task必填rubricprofilepromptsbase_urlcritiqueprovidercandidate必填api_key_envconfig_pathjudge_modelprofile_name另有 13 個

deepthonk.resume

Resume Run

Detect resume state (default) or replay an interrupted run with continue: true.

輸入參數run_dir必填continue

deepthonk.export

Export Run

Export a run summary or trace.

輸入參數formatrun_dir必填

deepthonk.profile_list

List DeepThonk Profiles

List saved named profiles.

無需輸入參數。

deepthonk.profile_show

Show DeepThonk Profile

Show a saved named profile; manually edited secret-shaped values are rejected on load.

輸入參數name必填

deepthonk.profile_save

Save DeepThonk Profile

Save a reusable named profile bundle.

輸入參數name必填forceretrybudgetmodelsoutputprofilepromptsbase_urlprovideralgorithmproviders另有 3 個

deepthonk.profile_delete

Delete DeepThonk Profile

Delete a saved named profile.

輸入參數name必填

版本歷史

1
  1. v0.3.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分