<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[DeepSeek Harness 添加本地 Qwen3.8-27B 模型要这样控制思考深度，亲测有效，也许你们都已经成功了，但我今天才认真考虑解决这个问题，主要是太难等了！]]></title><description><![CDATA[<h1>DeepSeek Harness 添加本地 Qwen3.8-27B 模型完整指南（llama.cpp × dsh）</h1>
<p dir="auto"><strong>四档推理深度（关/低/中/高）全量生效实测 · 可直接复制配置 · 踩坑记录</strong></p>
<blockquote>
<p dir="auto">这篇是写给<strong>另一台机器上的 Hermes</strong> 看的操作文档：照着做就能把本地 Qwen3.8-27B（含 UC 版）完整配置进 DeepSeek Harness（dsh），四档推理深度全部真实生效。</p>
<p dir="auto">前提：llama.cpp 的 llama-server 已经在 127.0.0.1:8000 跑起来（<code>--jinja --reasoning on --reasoning-preserve</code>），dsh web 已装好。本文只讲「把模型加进 dsh」这一步。</p>
</blockquote>
<hr />
<h2>目录</h2>
<ol>
<li>先给结论</li>
<li>名词白话解释</li>
<li>最终配置（可直接复制）</li>
<li>四档推理深度机制（为什么必须这么配）</li>
<li>踩过的坑（4 个，都流了血）</li>
<li>验证清单（照做一遍）</li>
<li>附录：完整操作流程</li>
</ol>
<hr />
<h2>1. 先给结论</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项目</th>
<th>结果</th>
</tr>
</thead>
<tbody>
<tr>
<td>配置位置</td>
<td><code>~/.dsh/settings.yaml</code> 的 <code>llm-pi-ai.providers</code> 下加 provider</td>
</tr>
<tr>
<td>模型条目</td>
<td><code>qwen3.8-27B</code> + <code>qwen3.8-27B-UC</code> 两个</td>
</tr>
<tr>
<td>推理深度</td>
<td><strong>关/低/中/高 四档全部真实生效</strong>（抓包验证）</td>
</tr>
<tr>
<td>关键</td>
<td>光配 <code>reasoningEfforts</code> 不够，必须配 <code>compat</code> 块</td>
</tr>
<tr>
<td>一句话</td>
<td><strong><code>reasoning_effort: "none"</code> 关不掉 Qwen3.8 的思考，必须走 <code>chat_template_kwargs.enable_thinking: false</code></strong></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>最终配置效果</strong>（tcpdump 抓包实测）：</p>
<ul>
<li>关 → <code>enable_thinking: false</code>（思考彻底关闭，秒回）</li>
<li>低 → <code>enable_thinking: true, reasoning_effort: "low"</code>（思考最简短）</li>
<li>中 → <code>enable_thinking: true, reasoning_effort: "medium"</code></li>
<li>高 → <code>enable_thinking: true, reasoning_effort: "xhigh"</code>（官方最高档）</li>
</ul>
<hr />
<h2>2. 名词白话解释</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>名词</th>
<th>白话解释</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>dsh</strong></td>
<td>DeepSeek Harness，DeepSeek 官方开源的 agent harness，<code>dsh web</code> 是它的 Web UI（本机 127.0.0.1:3080）</td>
</tr>
<tr>
<td><strong>llama.cpp / llama-server</strong></td>
<td>本地跑 GGUF 模型的推理引擎，提供 OpenAI 兼容 API（<code>/v1/chat/completions</code>）</td>
</tr>
<tr>
<td><strong>reasoningEfforts</strong></td>
<td>dsh 里给每个模型声明的「推理深度档位 → 端点参数」映射表</td>
</tr>
<tr>
<td><strong>thinkingFormat</strong></td>
<td>dsh 的 compat 配置，决定「把推理档位翻译成哪种端点的请求格式」</td>
</tr>
<tr>
<td><strong>chat_template_kwargs</strong></td>
<td>llama.cpp 端点认识的请求字段，Qwen3.8 的 jinja 模板用 <code>enable_thinking</code> 控制是否思考</td>
</tr>
<tr>
<td><strong>enable_thinking</strong></td>
<td>Qwen3.8 模板真正的思考开关。<code>false</code> = 不思考，<code>true</code> = 思考</td>
</tr>
</tbody>
</table>
<hr />
<h2>3. 最终配置（可直接复制）</h2>
<p dir="auto">打开 <code>~/.dsh/settings.yaml</code>，在 <code>llm-pi-ai.providers</code> 下加入（或合并到已有的 qwen provider 里）：</p>
<pre><code class="language-yaml">llm-pi-ai:
  providers:
    qwen-local:
      displayName: qwen-local
      apiKeyEnv: QWEN_LOCAL_API_KEY        # 任意命名，~/.dsh/.env 里加 QWEN_LOCAL_API_KEY=local（本地不校验）
      api: openai-completions
      baseURL: http://127.0.0.1:8000/v1
      models:
        - id: qwen3.8-27B
          name: qwen3.8-27B
          contextWindow: 153600
          maxTokens: 32768
          reasoningEfforts:
            'off': none
            low: low
            medium: medium
            high: xhigh          # ⚠️ 必须是 xhigh！Qwen3.8 模板不认 high，会直接 500
          compat:
            thinkingFormat: chat-template    # ⚠️ 必须是 chat-template，不是 qwen-chat-template！
            chatTemplateKwargs:
              enable_thinking: {$var: thinking.enabled}
              reasoning_effort: {$var: thinking.effort, omitWhenOff: true}
              preserve_thinking: true
        - id: qwen3.8-27B-UC
          name: qwen3.8-27B-UC
          contextWindow: 153600
          maxTokens: 32768
          reasoningEfforts:
            'off': none
            low: low
            medium: medium
            high: xhigh
          compat:
            thinkingFormat: chat-template
            chatTemplateKwargs:
              enable_thinking: {$var: thinking.enabled}
              reasoning_effort: {$var: thinking.effort, omitWhenOff: true}
              preserve_thinking: true
</code></pre>
<p dir="auto">然后：</p>
<pre><code class="language-bash"># 1. 备份
cp ~/.dsh/settings.yaml ~/.dsh/settings.yaml.bak.$(date +%Y%m%d-%H%M%S)

# 2. .env 补 apiKeyEnv 对应的变量（本地端点不校验 key 值，任意非空即可）
echo 'QWEN_LOCAL_API_KEY=local' &gt;&gt; ~/.dsh/.env

# 3. 默认模型指向本地（可选，按需）
#    agent-default-model:
#      provider: qwen-local
#      model: qwen3.8-27B-UC
#      reasoningEffort: 'off'     # ⚠️ off 必须带引号！

# 4. 重启
systemctl --user restart dsh-web.service
sleep 6
systemctl --user is-active dsh-web.service        # 期望 active
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:3080/   # 期望 200
</code></pre>
<hr />
<h2>4. 四档推理深度机制（为什么必须这么配）</h2>
<h3>4.1 Qwen3.8 模板只认 xhigh / medium / low</h3>
<p dir="auto">从 Qwen3.8 GGUF 里直接提取的 jinja 模板源码：</p>
<pre><code>{%- if enable_thinking is undefined or enable_thinking is true %}
    {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}
    {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}
        {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}
    {%- endif %}
</code></pre>
<ul>
<li><strong><code>none</code> 不是合法档位</strong> → 顶层 API 传 <code>reasoning_effort: none</code> 时被 llama.cpp 归一化剥掉（不传给模板），模板走默认 xhigh 满档思考——实测 none 思考最长（4631 字符）</li>
<li><strong><code>high</code> 不是合法档位</strong> → 若直接把 <code>high</code> 塞进 <code>chat_template_kwargs.reasoning_effort</code> 传给模板，模板 raise_exception → HTTP 500（实测确认）</li>
<li>所以 UI 四档映射：关 → <code>enable_thinking: false</code>；低 → <code>low</code>；中 → <code>medium</code>；高 → <code>xhigh</code></li>
</ul>
<h3>4.2 为什么必须用 <code>chat-template</code> 而不是 <code>qwen-chat-template</code></h3>
<p dir="auto">dsh 源码（pi-ai 的 openai-completions.js）里有两个 Qwen 分支：</p>
<pre><code class="language-js">// qwen-chat-template 分支：只发开关，不带 effort → 低/中/高三档没区别！
else if (compat.thinkingFormat === "qwen-chat-template" &amp;&amp; model.reasoning) {
    params.chat_template_kwargs = {
        enable_thinking: !!options?.reasoningEffort,
        preserve_thinking: true,
    };
}
// chat-template 分支：走 buildChatTemplateKwargs → 支持 $var 占位符，带 effort！
else if (compat.thinkingFormat === "chat-template" &amp;&amp; model.reasoning) {
    const chatTemplateKwargs = buildChatTemplateKwargs(model, options, compat);
    ...
}
</code></pre>
<p dir="auto"><strong><code>qwen-chat-template</code> 分支只发 <code>enable_thinking</code> 开关</strong>（低/中/高都变成「开思考」+ 默认 xhigh 满档），<strong>必须用 <code>chat-template</code> 分支</strong> + <code>chatTemplateKwargs</code> 里的 <code>$var: thinking.effort</code> 才能把档位传下去。</p>
<h3>4.3 <code>$var</code> 是 dsh 官方占位符</h3>
<p dir="auto"><code>chatTemplateKwargs</code> 的 value 支持两种写法：</p>
<ul>
<li>字面量：<code>string</code> / <code>number</code> / <code>boolean</code> / <code>null</code></li>
<li>占位符：<code>{$var: "thinking.enabled"}</code> 或 <code>{$var: "thinking.effort", omitWhenOff: true}</code></li>
</ul>
<p dir="auto"><code>thinking.effort</code> 解析逻辑（dsh 源码 resolveChatTemplateKwargValue）：</p>
<ul>
<li>有 effort（低/中/高）→ 查 <code>thinkingLevelMap</code> → 发对应值</li>
<li>off → <code>omitWhenOff: true</code> 让它不发（思考由 enable_thinking: false 关掉）</li>
</ul>
<hr />
<h2>5. 踩过的坑（4 个，都流了血）</h2>
<h3>坑 1：光配 reasoningEfforts 关不掉思考（off 无效）</h3>
<p dir="auto"><strong>症状</strong>：dsh 里把推理深度设「关」，模型还在不停思考。<br />
<strong>根因</strong>：dsh 走通用分支发 <code>reasoning_effort: "none"</code>，但 Qwen3.8 模板不认 none → 默认 xhigh 满档思考。实测 <code>reasoning_effort=none</code> 思考最长（4631 字符）。<br />
<strong>修复</strong>：配 compat 走 chat-template 分支，发 <code>chat_template_kwargs.enable_thinking: false</code>（实测思考归零）。</p>
<h3>坑 2：<code>reasoning_effort: {}</code> 空对象 → 整个 provider 挂掉，模型从 dsh 消失</h3>
<p dir="auto"><strong>症状</strong>：<code>NO_ADAPTER: no adapter registered for provider "qwen-local"</code>，dsh 里模型全没了。<br />
<strong>根因</strong>：dsh 的 schema（<code>chatTemplateKwarg</code>）只接受 string/number/boolean/null/带必填 <code>$var</code> 的对象。空对象 <code>{}</code> 校验失败 → 整个 provider 被拒。<br />
<strong>修复</strong>：<code>reasoning_effort</code> 用 <code>{$var: thinking.effort, omitWhenOff: true}</code>。<br />
<strong>血泪</strong>：改完必须验证——<code>dsh --profile headless '测试'</code> 能回话才算真活。</p>
<h3>坑 3：PyYAML 把 <code>off</code> 重写成布尔 false</h3>
<p dir="auto"><strong>症状</strong>：用 Python yaml 库改 settings.yaml 后，<code>reasoningEffort: off</code> 变成 <code>reasoningEffort: false</code>。<br />
<strong>根因</strong>：PyYAML 按 YAML 1.1 解析，<code>off/on/yes/no</code> 是布尔关键字；dsh 用 js-yaml 按 YAML 1.2 解析，<code>off</code> 是字符串。<br />
<strong>修复</strong>：写回时显式带引号 <code>'off'</code>，改完 grep 检查 <code>reasoningEffort</code> 行。<br />
<strong>血泪</strong>：<code>'off'</code> 键也要带引号——PyYAML 会把 <code>off: none</code> 的键 <code>off</code> 解析成布尔 False。</p>
<h3>坑 4：<code>high</code> 档直接 500</h3>
<p dir="auto"><strong>症状</strong>：选「高」档，请求 500 错误。<br />
<strong>根因</strong>：模板只认 xhigh/medium/low，<code>high</code> 触发 raise_exception。<br />
<strong>修复</strong>：<code>reasoningEfforts.high</code> 映射到 <code>xhigh</code>（官方最高档）。</p>
<hr />
<h2>6. 验证清单（照做一遍）</h2>
<pre><code class="language-bash"># 1. 服务健康
systemctl --user is-active dsh-web.service          # active
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:3080/   # 200

# 2. headless 实测（能回话 = provider 真活着）
dsh --profile headless '27乘以43等于多少？一行答案。'
# 期望：秒回「1161」这类答案（不是 NO_ADAPTER）

# 3. 四档抓包验证（可选但推荐）
# 临时改 agent-default-model.reasoningEffort 到 off/low/medium/high 各测一次
sudo tcpdump -i lo -A -s 0 'tcp port 8000' &gt; /tmp/dsh_cap.txt &amp;
dsh --profile headless '27乘以43等于多少？'
grep -o 'chat_template_kwargs[^,}]*' /tmp/dsh_cap.txt
# 期望：off → enable_thinking:false
#       低 → reasoning_effort:"low"，中 → "medium"，高 → "xhigh"
</code></pre>
<hr />
<h2>7. 附录：完整操作流程（给执行方 Hermes）</h2>
<ol>
<li><strong>确认前提</strong>：<code>curl -s http://127.0.0.1:8000/v1/models</code> 返回模型列表（llama-server 活着）</li>
<li><strong>确认 dsh 存在</strong>：<code>ls ~/.dsh/settings.yaml</code> + <code>systemctl --user is-active dsh-web.service</code></li>
<li><strong>备份</strong>：<code>cp ~/.dsh/settings.yaml ~/.dsh/settings.yaml.bak.$(date +%Y%m%d-%H%M%S)</code></li>
<li><strong>改配置</strong>：按第 3 节 YAML 加入 provider + 模型条目（或合并到已有 provider）</li>
<li><strong>补 .env</strong>：<code>echo 'QWEN_LOCAL_API_KEY=local' &gt;&gt; ~/.dsh/.env</code>（apiKeyEnv 对应变量，本地不校验值）</li>
<li><strong>重启</strong>：<code>systemctl --user restart dsh-web.service</code></li>
<li><strong>验证</strong>：is-active=active + curl 3080=200 + <code>dsh --profile headless '测试'</code> 回话</li>
<li><strong>四档验证</strong>（可选）：按第 6 节抓包确认各档位参数</li>
<li><strong>收尾</strong>：web UI 里能看到模型，选推理深度各档位可切换</li>
</ol>
<blockquote>
<p dir="auto">注意：dsh 的 <code>--dump-config</code> 输出 profile 树，<strong>不含 llm-pi-ai 的 model 条目</strong>——grep 不到模型条目属正常，不能用来验证模型级配置。验证用第 6 节的方法。</p>
</blockquote>
<hr />
<p dir="auto"><em>实测日期：2026-08-30 · 环境：Ubuntu + llama.cpp（CUDA 12.9）+ Qwen3.8-27B Q4_K_XL / Q4_K_P · dsh web :3080 · 全文配置均经抓包与 headless 实测验证</em></p>
]]></description><link>https://lcz.me/topic/1422</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 19:42:49 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1422.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Aug 2026 11:07:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DeepSeek Harness 添加本地 Qwen3.8-27B 模型要这样控制思考深度，亲测有效，也许你们都已经成功了，但我今天才认真考虑解决这个问题，主要是太难等了！ on Mon, 31 Aug 2026 02:57:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry" aria-label="Profile: terry">@<bdi>terry</bdi></a> 以前没在意，现在比较在意回复速度了</p>
]]></description><link>https://lcz.me/post/15050</link><guid isPermaLink="true">https://lcz.me/post/15050</guid><dc:creator><![CDATA[清风明月]]></dc:creator><pubDate>Mon, 31 Aug 2026 02:57:24 GMT</pubDate></item><item><title><![CDATA[Reply to DeepSeek Harness 添加本地 Qwen3.8-27B 模型要这样控制思考深度，亲测有效，也许你们都已经成功了，但我今天才认真考虑解决这个问题，主要是太难等了！ on Sun, 30 Aug 2026 22:17:27 GMT]]></title><description><![CDATA[<p dir="auto">不明觉厉，我都是直接让dsh自己配置的，我很早的视频里就是发过去秒回，不需要思考。</p>
]]></description><link>https://lcz.me/post/15021</link><guid isPermaLink="true">https://lcz.me/post/15021</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sun, 30 Aug 2026 22:17:27 GMT</pubDate></item></channel></rss>