Skip to content

fix(deepseek): use provider-native transport - #198

Merged
EricSanchezok merged 1 commit into
devfrom
synergy/deepseek-native-transport
Sep 5, 2026
Merged

EricSanchezok merged 1 commit into
devfrom
synergy/deepseek-native-transport

Conversation

@EricSanchezok

Copy link
Copy Markdown
Owner

Summary

  • add an explicit DeepSeek protocol backed by Rig's provider-native transport
  • preserve exact thinking/tool history plus max_tokens on the DeepSeek wire request
  • add an exact local HTTP wire regression, compatibility coverage, spec, MADR, and escaped-failure postmortem

Verification

  • cargo nextest run --workspace --locked (519 passed)
  • cargo test --workspace --doc --locked
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --tests --locked -- -D warnings
  • node scripts/run-gates.mjs

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review 结论:可合并 — 目标达成。 PR 声称的「显式 DeepSeek 协议 + Rig provider-native transport + 保留 thinking/tool history 与 max_tokens + exact wire 回归与治理产物」与 diff 实际改动一一对应,无范围漂移,调用方/文档/测试配套齐全。

代码质量

  • ✓ Protocol::DeepSeek 分支(crates/machine/src/completion.rs:175-194)与既有 OpenAI/Anthropic/Gemini 分支同构:复用 openai_http_client()、base_url、apply_headers,无重复逻辑。
  • ✓ additional_params 的 match 改写(crates/machine/src/completion.rs:707-734)把 thinking 扩展严格限定在支持的协议上,Anthropic/Gemini 显式返回 None,不会误发。
  • ✓ max_tokens 通过 flattened provider params 保留(limit.output → completion.rs:728-730),并注释说明了对 Rig 0.36 adapter 不投影 generic 字段的规避,provenance 清楚。
  • ✓ 兼容性保持:set_openai_thinking_mode/openai_thinking_mode 保留为薄转发(model.rs:70-84),存储 key 不变,序列化与旧调用方均不受影响。
  • ✓ wire 级回归是真实 HTTP 捕获(tokio TcpListener + raw request body 断言),断言到字段级类型(content == "" 为 string、reasoning_content、tool_calls[].function.arguments),补上了 v0.2.23 「presence ≠ shape」的测试盲区。
  • ⚠ DeepSeek 分支 .expect("failed to build deepseek client")(completion.rs:191)沿用了同文件既有 panic 模式;builder 仅在静态错误配置下失败,运行时风险低,但与仓库「failed outcomes log at warn!」的开发规则在字面上有张力,属既有约定而非本 PR 引入。
  • ⚠ 测试网关为手写 HTTP/1.1 解析,仅处理单个连接、单请求;作为精确形状断言够用,但若 Rig 请求头/编码变化,失败信息会偏底层,可维护性一般。

目标 / 范围

  • ✓ 目标 why 充分:postmortem 0003 明确根因(generic OpenAI content-parts ≠ DeepSeek string-or-null),不是只有 what。
  • ✓ 声称项全部落地:协议变体(model.rs:133)+ serde round-trip 测试、CLI parse_protocol、server build_model、provider 注册表、exact wire 回归、spec 0004 / decision 0007 / postmortem 0003。
  • ✓ 无范围漂移:cli 0.2.23→0.2.24 是 spec 0004 明确写入的契约部分;.repo-seed/manifest.json sha256 更新是 docs 变更的必然连带。
  • ✓ 无遗漏配套:Protocol 所有 match 点均已覆盖(compiler 对非 exhaustive enum 强制报错,均改过说明无漏);N-1 兼容测试(openai_thinking_mode() 旧断言、build_request_does_not_send_openai_thinking_extension_to_other_protocols)仍通过。

修改建议(非阻塞)

  1. 可考虑为 DeepSeek 分支的 client build 失败补一条与 send 内一致的 warn! 结构化日志,与仓库日志规则对齐(即便走 expect,也便于将来排查)。
  2. wire 回归的网关 helper 可抽一个小工具或至少加注释说明其「单连接、content-length 驱动」的假设,降低后续维护者改动成本。
  3. 若 Rig 升级到投影 generic max_tokens,请在 spec 0004 的 Contract 中记录该临时 additional_params 注入的退役条件,避免永久负债。

@EricSanchezok
EricSanchezok merged commit cef2c90 into dev Sep 5, 2026
7 checks passed
@EricSanchezok
EricSanchezok deleted the synergy/deepseek-native-transport branch September 5, 2026 14:16
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.

1 participant