Skip to content

fix(proxy): recognize DeepSeek reasoning stream content - #1395

Merged
ding113 merged 1 commit into
devfrom
fix/deepseek-reasoning-stream-gate
Aug 4, 2026
Merged

fix(proxy): recognize DeepSeek reasoning stream content#1395
ding113 merged 1 commit into
devfrom
fix/deepseek-reasoning-stream-gate

Conversation

@ding113

@ding113 ding113 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Fixes #1394

Summary

  • Classify non-empty choices[].delta.reasoning_content as valid OpenAI Chat stream content.
  • Preserve empty reasoning chunks as neutral and keep existing error/content precedence unchanged.
  • Cover the 65-frame DeepSeek reasoning stream and the Request Replay owner path that still gates streams while STREAM_GATE_MODE=off.

Validation

  • bunx vitest run tests/unit/proxy/stream-gate-frame-classifier.test.ts tests/unit/proxy/stream-gate-content-gate.test.ts tests/unit/proxy/stream-gate-forwarder-integration.test.ts (79 passed)
  • bun run typecheck
  • bun run lint
  • bun run lint:fix
  • bun run build
  • bun run test
  • bun run test:coverage

Review

Greptile Summary

This PR updates the OpenAI Chat stream classifier so non-empty DeepSeek reasoning_content deltas count as valid content while empty deltas remain neutral.

  • Adds choices.#.delta.reasoning_content to the existing OpenAI Chat content paths.
  • Adds classifier coverage for non-empty and empty reasoning deltas.
  • Adds content-gate and replay-owner integration coverage for a 65-frame reasoning stream.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The new path uses the classifier’s existing non-empty-value semantics, preserves error-before-content precedence, and is covered at classifier, gate, and forwarding integration levels.

Important Files Changed

Filename Overview
src/app/v1/_lib/proxy/stream-gate/frame-classifier.ts Adds DeepSeek reasoning deltas to the established OpenAI Chat content classification without changing error precedence or empty-value semantics.
tests/unit/proxy/stream-gate-frame-classifier.test.ts Verifies non-empty reasoning deltas classify as content and empty reasoning deltas remain neutral.
tests/unit/proxy/stream-gate-content-gate.test.ts Verifies a reasoning-only stream commits immediately rather than reaching the event cap.
tests/unit/proxy/stream-gate-forwarder-integration.test.ts Verifies the replay-owner forwarding path accepts and returns a reasoning-only DeepSeek stream without failover.

Reviews (1): Last reviewed commit: "fix(proxy): recognize DeepSeek reasoning..." | Re-trigger Greptile

Context used:

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

OpenAI Chat 内容帧规则新增 delta.reasoning_content。测试覆盖非空与空 reasoning 内容,以及 DeepSeek 流的提交、完整透传和单次转发行为。

Changes

DeepSeek reasoning 内容支持

Layer / File(s) Summary
内容帧分类规则
src/app/v1/_lib/proxy/stream-gate/frame-classifier.ts, tests/unit/proxy/stream-gate-frame-classifier.test.ts
非空 reasoning_content 被分类为 content。空字符串仍被分类为 neutral
流式提交与转发验证
tests/unit/proxy/stream-gate-content-gate.test.ts, tests/unit/proxy/stream-gate-forwarder-integration.test.ts
测试验证 65 个 reasoning 帧可提交并完整透传,且不触发 failover 或失败记录。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed 变更将非空 reasoning_content 识别为有效内容,并覆盖 DeepSeek 流场景,符合问题 #1394 的修复目标。
Out of Scope Changes check ✅ Passed 代码和测试变更均围绕 DeepSeek reasoning 流处理及其验证,没有发现无关改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed 标题准确概括了修复 DeepSeek reasoning stream 内容识别的主要变更。
Description check ✅ Passed 描述与变更内容直接相关,并说明了实现、测试范围和验证结果。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deepseek-reasoning-stream-gate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Summary

No significant issues identified in this PR.

PR Size: S

  • Lines changed: 60
  • Files changed: 4

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate
  • Code clarity - Good

Automated review by Codex AI

@github-actions github-actions Bot added the size/S Small PR (< 200 lines) label Aug 4, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Completed the PR review for #1395 and posted the GitHub review summary as a comment.
  • Applied the size label size/S.
  • I did not find any diff-scoped issue that cleared the reporting threshold after validating the new classifier change and the added coverage in src/app/v1/_lib/proxy/stream-gate/frame-classifier.ts, tests/unit/proxy/stream-gate-frame-classifier.test.ts, tests/unit/proxy/stream-gate-content-gate.test.ts, and tests/unit/proxy/stream-gate-forwarder-integration.test.ts.
  • I also attempted targeted test execution, but this runner does not have bun/bunx installed, so runtime validation could not be rerun locally here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR (< 200 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant