Skip to content

feat(deepseek-harness): 通过 reasoningEffort 支持 Thinking 档位选择 - #53

Merged
BytePioneer-AI merged 2 commits into
BytePioneer-AI:mainfrom
omsd512-W:feat/deepseek-reasoning-effort
Aug 30, 2026
Merged

feat(deepseek-harness): 通过 reasoningEffort 支持 Thinking 档位选择#53
BytePioneer-AI merged 2 commits into
BytePioneer-AI:mainfrom
omsd512-W:feat/deepseek-reasoning-effort

Conversation

@omsd512-W

@omsd512-W omsd512-W commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

背景

README 能力矩阵把 DeepSeek Harness 的 模型 / Thinking 档位选择 标为 🚧。模型切换原本已可用,但 Thinking 档位仍被硬编码禁用:adapter 报告 selectThinkingOption: false、目录固定为 thinkingOptions: [],且 open() 会拒绝 thinkingOptionId

DeepSeek Harness Host 协议早已提供所需能力;本 PR 仅将既有协议字段接入 adapter,沿用 Pi 与 Claude Code 已采用的模式。

版本 / 对接点(已核验)

项目 版本 / 证据
基线 main @ 64ae4c3(v0.3.5 之后)
锁定的协议依赖 @deepseek-ai/dsh-host-apiproxy 0.1.0-rc.6(见 package-lock.json;adapter 也声明完全相同的版本)
选择 RPC sessions.selectModel({ sessionId, provider, model, reasoningEffort? }) —— 自 rc.6 起可用
目录元数据 ModelCatalogModel.reasoning?: ModelReasoning { efforts: { id, name, description? }[], defaultEffort? } —— 自 rc.6 起可用
回读状态 sessions.modelsModelSelection.reasoningEffort?: string
交叉验证 @deepseek-ai/dsh 0.1.1-rc.2(字段完全一致,向后兼容 rc.6)
档位语义 dsh-llm-deepseek 按顺序公开 off / low / high / maxoff 映射为 thinking: disabled;省略档位时保留部署默认值(high);锁定 Thinking 的部署仅公开 off

改动

  • model-catalog.ts —— 将每个模型的 reasoning.efforts 投影为目录的 thinkingOptions(并集,保留 adapter 顺序)和每个模型的 supportedThinkingOptionIds;从当前选择或默认模型的 reasoning.defaultEffort 推导 defaultThinkingOptionId,避免未显式指定档位时错误落到第一个公开的 off 选项。新增 normalizeDeepSeekThinkingOptions() / parseDeepSeekThinkingOptionId() 均采用 fail-closed 策略:无法识别的 effort id 会被丢弃,不进行猜测。
  • deepseek-harness-adapter.ts
    • 公开 selectThinkingOption: true(inspect 与 session capabilities)
    • 处理 thinking.select:使用当前 provider/model 加 reasoningEffort 调用 sessions.selectModel,再通过 sessions.models 回读并要求精确匹配后才发布状态(fail-closed,与 #selectModel 保持一致)
    • model.select 有意省略 reasoningEffort,使模型切换回退到目标模型自己的默认档位;随后从回读值刷新 effectiveThinkingOptionId
    • open({ kind: "create", thinkingOptionId }) 不再拒绝该参数;未显式给出 model 时,会先读取 Host 默认选择,再带档位执行选择
    • initialStatereadSnapshot() 与选择事件均携带 effectiveThinkingOptionId + availableThinkingOptions
    • 顶层当前模型和 Thinking 状态统一来自同一份 sessions.models.current 快照;历史请求头仍只归属于各自的历史 Turn
  • 测试 —— fixture 中的 selectModel 现在会像 DSH 一样物化每个模型的默认档位;新增 5 个聚焦用例,覆盖目录公开/默认值、创建时指定档位、恢复会话后的选择与发布、当前配置与历史配置的区分,以及 Thinking 回读不匹配时不发布状态。

验证

  • npm run typecheck
  • npx vitest run --config tests/vitest.config.js packages/adapters/deepseek-harness27 passed(22 个既有 + 5 个新增)✅
  • npx prettier --check packages/adapters/deepseek-harness
  • npx eslint packages/adapters/deepseek-harness
  • node tools/check-boundaries.mjs

合入后,README 能力矩阵中 DeepSeek Harness 的 模型 / Thinking 档位选择 可由 🚧 更新为 ✅。

Project DeepSeek Harness reasoning efforts into the Harness Model catalog (thinkingOptions, supportedThinkingOptionIds) and wire thinking.select to sessions.selectModel with exact readback confirmation. Creation accepts thinkingOptionId; Model switches fall back to the route default effort.
@omsd512-W
omsd512-W marked this pull request as ready for review August 29, 2026 20:19
Copilot AI lite review requested due to automatic review settings August 29, 2026 20:19
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are confirmed correctness/input-validation issues in the DeepSeek model catalog and session creation path that can cause schema parse failures or allow invalid Thinking option IDs through.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR completes DeepSeek Harness “Thinking” option support by projecting Host-provided reasoning.efforts into the adapter’s model catalog and wiring reasoningEffort through session creation/resume and runtime thinking.select configuration, aligning DeepSeek behavior with other adapters in the workspace.

Changes:

  • Expand DeepSeek model catalog normalization to advertise thinkingOptions, per-model supportedThinkingOptionIds, and a derived defaultThinkingOptionId.
  • Enable selectThinkingOption capability and implement thinking.select by calling sessions.selectModel(..., reasoningEffort) with fail-closed readback verification.
  • Update/extend adapter tests and the fake Host fixture to model default reasoningEffort behavior and validate state publication semantics.
File summaries
File Description
packages/adapters/deepseek-harness/test/deepseek-harness-adapter.test.ts Updates the fake Host and adds focused tests for Thinking catalog/state/selection behavior.
packages/adapters/deepseek-harness/src/model-catalog.ts Projects Host reasoning metadata into the harness model catalog (thinking options + defaults).
packages/adapters/deepseek-harness/src/deepseek-harness-adapter.ts Enables Thinking selection capability, reads current reasoningEffort, publishes Thinking state, and implements thinking.select.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +113 to +115
...(model.reasoning && model.reasoning.efforts.length > 0
? { supportedThinkingOptionIds: model.reasoning.efforts.map((effort) => effort.id) }
: {}),
Comment on lines 1359 to +1363
await this.#connection.client.sessions.selectModel({
sessionId: sessionId as SessionId,
provider: requested.provider,
model: requested.model,
provider: target.provider,
model: target.model,
...(input.thinkingOptionId ? { reasoningEffort: input.thinkingOptionId } : {}),
Comment on lines +133 to +135
const defaultEffort = MODEL_GROUPS.find((group) => group.id === provider)?.models.find(
(candidate) => candidate.id === model,
)?.reasoning.defaultEffort;
@omsd512-W omsd512-W changed the title feat(deepseek-harness): support Thinking option selection via reasoningEffort feat(deepseek-harness): 通过 reasoningEffort 支持 Thinking 档位选择 Aug 29, 2026
@BytePioneer-AI
BytePioneer-AI merged commit cd7285b into BytePioneer-AI:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants