Skip to content

fix: max reasoning effort for deepseek v4 - #4330

Merged
akshaydeo merged 1 commit into
devfrom
06-12-fix_max_reasoning_effort_for_deepseek_v4
Jun 12, 2026
Merged

fix: max reasoning effort for deepseek v4#4330
akshaydeo merged 1 commit into
devfrom
06-12-fix_max_reasoning_effort_for_deepseek_v4

Conversation

@TejasGhatte

@TejasGhatte TejasGhatte commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash) natively accept "max" as a reasoning effort value. Previously, the normalization logic would convert "max" to "high" (or "xhigh" for supported OpenAI models) for all models, which incorrectly stripped the valid "max" value when routing through DeepSeek's OpenAI-compatible provider.

closes #4320

Changes

  • Added supportsMaxReasoningEffort helper in utils.go that identifies models with a deepseek-v4 prefix as natively supporting "max" reasoning effort.
  • Updated normalizeOpenAIReasoningEffort to short-circuit and return "max" unchanged for those models before applying the OpenAI-specific "high"/"xhigh" mapping.
  • Extended tests in chat_test.go and responses_test.go to cover the "max" passthrough behavior for deepseek-v4-pro and deepseek-v4-flash.
  • Updated the responses test harness to accept a configurable provider field so DeepSeek-routed requests can be tested independently from OpenAI-routed ones.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

go test ./core/providers/openai/...

Verify that the new test cases "preserves max for deepseek-v4-pro" and "preserves max for deepseek-v4-flash" pass in both TestToOpenAIChatRequest_NormalizesReasoningEffort, TestOpenAIChatRequest_FilterOpenAISpecificParameters_NormalizesReasoningEffort, and TestToOpenAIResponsesRequest_NormalizesReasoningEffort.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

None.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Summary by CodeRabbit

  • New Features

    • Added official support for DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash), including recognition of provider-prefixed model identifiers.
  • Bug Fixes

    • Reasoning-effort handling now preserves the "max" setting for DeepSeek V4 models across requests and responses, ensuring expected high-effort behavior is retained.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


tejas ghatte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fdfbde22-e9b4-49d3-8f57-d34b8897d61e

📥 Commits

Reviewing files that changed from the base of the PR and between bdc1392 and b6a2a61.

📒 Files selected for processing (3)
  • core/providers/openai/chat_test.go
  • core/providers/openai/responses_test.go
  • core/providers/openai/utils.go

📝 Walkthrough

Walkthrough

The PR makes reasoning-effort normalization model-aware: it preserves "max" for DeepSeek V4 models by adding a detection helper in utils and updates chat and responses normalization tests to register a deepseek provider and assert "max" is retained for deepseek-v4 model variants.

Changes

DeepSeek V4 Reasoning Effort Normalization

Layer / File(s) Summary
Core normalization logic and helper
core/providers/openai/utils.go
normalizeOpenAIReasoningEffort checks supportsMaxReasoningEffort(model) before remapping "max" and preserves it when the model indicates deepseek-v4; new internal helper parses model names.
Chat request normalization test coverage
core/providers/openai/chat_test.go
Tests register/unregister the deepseek provider, add per-case provider fields, and include table cases asserting reasoning.effort: "max" is preserved for deepseek-v4-pro, deepseek-v4-flash, and deepseek/deepseek-v4-pro in both ToOpenAIChatRequest and filterOpenAISpecificParameters paths.
Response request normalization test coverage
core/providers/openai/responses_test.go
Tests register/unregister the deepseek provider, add optional provider per-case (defaulting to schemas.OpenAI), pass Provider into BifrostResponsesRequest, and add DeepSeek V4 cases asserting effort: "max" is preserved when routed via DeepSeek provider.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • akshaydeo
  • danpiths

Poem

🐰 Hopping through tests with a twitch and a grin,
DeepSeek's "max" stays safe, not folded thin.
Chat and responses now sing in tune,
Preserved efforts beneath the moon.
🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: max reasoning effort for deepseek v4' directly and clearly summarizes the main change: addressing a bug where DeepSeek V4 models' native 'max' reasoning effort was being incorrectly normalized.
Description check ✅ Passed The PR description comprehensively follows the template with all critical sections completed: Summary explains the problem clearly, Changes detail the implementation, Type of change is checked, Affected areas are selected, How to test provides specific commands, Breaking changes are addressed, and the Checklist shows completed relevant items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 06-12-fix_max_reasoning_effort_for_deepseek_v4

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TejasGhatte
TejasGhatte marked this pull request as ready for review June 12, 2026 08:41
@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge; the change is a targeted short-circuit in a pure transformation function with no side effects, and the new test cases cover the expected paths well.

The new helper is structurally identical to the two sibling helpers it sits alongside, the ParseModelString prefix-stripping is applied consistently, and the test harness now exercises the bare, variant, and provider-prefixed model strings. No new HTTP calls, no pooled objects, no streaming paths, and no provider-interface changes are involved.

No files require special attention.

Important Files Changed

Filename Overview
core/providers/openai/utils.go Adds supportsMaxReasoningEffort helper with ParseModelString prefix-stripping and wires it into normalizeOpenAIReasoningEffort before the existing xhigh/high fallbacks; logic is correct and consistent with the two sibling helper functions.
core/providers/openai/chat_test.go Extends both normalisation test tables with deepseek-v4 cases; properly registers/defers the custom provider in both test functions, adds a provider field to the first test's struct, and correctly defaults to schemas.OpenAI for pre-existing cases.
core/providers/openai/responses_test.go Mirrors the chat-test additions for the responses path; adds provider field, registers the deepseek provider, and covers the same three model-string variants (bare, -flash, provider-prefixed).

Reviews (2): Last reviewed commit: "fix: max reasoning effort for deepseek v..." | Re-trigger Greptile

Comment thread core/providers/openai/utils.go
Comment thread core/providers/openai/chat_test.go

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/providers/openai/utils.go`:
- Around line 133-136: supportsMaxReasoningEffort currently checks the raw model
string; normalize the input first using schemas.ParseModelString(model) and then
run the prefix check on the parsed model name (e.g., use parsed.Model or
equivalent field), e.g. lowercasing that parsed value and calling
strings.HasPrefix(..., "deepseek-v4") so provider-qualified forms are normalized
and "max" is preserved correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 729b5116-764f-40de-9732-ad518b26832b

📥 Commits

Reviewing files that changed from the base of the PR and between 93e4305 and bdc1392.

📒 Files selected for processing (3)
  • core/providers/openai/chat_test.go
  • core/providers/openai/responses_test.go
  • core/providers/openai/utils.go

Comment thread core/providers/openai/utils.go
@TejasGhatte
TejasGhatte force-pushed the 06-12-fix_max_reasoning_effort_for_deepseek_v4 branch from bdc1392 to b6a2a61 Compare June 12, 2026 08:50

akshaydeo commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jun 12, 8:51 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 12, 8:52 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit ed785cd into dev Jun 12, 2026
14 of 16 checks passed
@akshaydeo
akshaydeo deleted the 06-12-fix_max_reasoning_effort_for_deepseek_v4 branch June 12, 2026 08:52
akshaydeo pushed a commit that referenced this pull request Jun 12, 2026
## Summary

DeepSeek V4 models (`deepseek-v4-pro`, `deepseek-v4-flash`) natively accept `"max"` as a reasoning effort value. Previously, the normalization logic would convert `"max"` to `"high"` (or `"xhigh"` for supported OpenAI models) for all models, which incorrectly stripped the valid `"max"` value when routing through DeepSeek's OpenAI-compatible provider.  
  
closes #4320

## Changes

- Added `supportsMaxReasoningEffort` helper in `utils.go` that identifies models with a `deepseek-v4` prefix as natively supporting `"max"` reasoning effort.
- Updated `normalizeOpenAIReasoningEffort` to short-circuit and return `"max"` unchanged for those models before applying the OpenAI-specific `"high"`/`"xhigh"` mapping.
- Extended tests in `chat_test.go` and `responses_test.go` to cover the `"max"` passthrough behavior for `deepseek-v4-pro` and `deepseek-v4-flash`.
- Updated the responses test harness to accept a configurable `provider` field so DeepSeek-routed requests can be tested independently from OpenAI-routed ones.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./core/providers/openai/...
```

Verify that the new test cases `"preserves max for deepseek-v4-pro"` and `"preserves max for deepseek-v4-flash"` pass in both `TestToOpenAIChatRequest_NormalizesReasoningEffort`, `TestOpenAIChatRequest_FilterOpenAISpecificParameters_NormalizesReasoningEffort`, and `TestToOpenAIResponsesRequest_NormalizesReasoningEffort`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added official support for DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash), including recognition of provider-prefixed model identifiers.

* **Bug Fixes**
  * Reasoning-effort handling now preserves the "max" setting for DeepSeek V4 models across requests and responses, ensuring expected high-effort behavior is retained.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
akshaydeo added a commit that referenced this pull request Jun 24, 2026
…4467)

GLM-5.2 (Z.ai) natively supports reasoning_effort "max" (alongside
"high"), but normalizeOpenAIReasoningEffort() silently downgraded
"max" to "high" because GLM-5.2 was not in supportsMaxReasoningEffort().
This is the same normalization gap that previously affected DeepSeek V4
(issue #4320, PR #4330).

Affected packages: core/providers/openai/

Closes #4460

Signed-off-by: is911 <archilles92@gmail.com>
Signed-off-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
## Summary

DeepSeek V4 models (`deepseek-v4-pro`, `deepseek-v4-flash`) natively accept `"max"` as a reasoning effort value. Previously, the normalization logic would convert `"max"` to `"high"` (or `"xhigh"` for supported OpenAI models) for all models, which incorrectly stripped the valid `"max"` value when routing through DeepSeek's OpenAI-compatible provider.  
  
closes maximhq#4320

## Changes

- Added `supportsMaxReasoningEffort` helper in `utils.go` that identifies models with a `deepseek-v4` prefix as natively supporting `"max"` reasoning effort.
- Updated `normalizeOpenAIReasoningEffort` to short-circuit and return `"max"` unchanged for those models before applying the OpenAI-specific `"high"`/`"xhigh"` mapping.
- Extended tests in `chat_test.go` and `responses_test.go` to cover the `"max"` passthrough behavior for `deepseek-v4-pro` and `deepseek-v4-flash`.
- Updated the responses test harness to accept a configurable `provider` field so DeepSeek-routed requests can be tested independently from OpenAI-routed ones.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./core/providers/openai/...
```

Verify that the new test cases `"preserves max for deepseek-v4-pro"` and `"preserves max for deepseek-v4-flash"` pass in both `TestToOpenAIChatRequest_NormalizesReasoningEffort`, `TestOpenAIChatRequest_FilterOpenAISpecificParameters_NormalizesReasoningEffort`, and `TestToOpenAIResponsesRequest_NormalizesReasoningEffort`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added official support for DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash), including recognition of provider-prefixed model identifiers.

* **Bug Fixes**
  * Reasoning-effort handling now preserves the "max" setting for DeepSeek V4 models across requests and responses, ensuring expected high-effort behavior is retained.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…aximhq#4467)

GLM-5.2 (Z.ai) natively supports reasoning_effort "max" (alongside
"high"), but normalizeOpenAIReasoningEffort() silently downgraded
"max" to "high" because GLM-5.2 was not in supportsMaxReasoningEffort().
This is the same normalization gap that previously affected DeepSeek V4
(issue maximhq#4320, PR maximhq#4330).

Affected packages: core/providers/openai/

Closes maximhq#4460

Signed-off-by: is911 <archilles92@gmail.com>
Signed-off-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
## Summary

DeepSeek V4 models (`deepseek-v4-pro`, `deepseek-v4-flash`) natively accept `"max"` as a reasoning effort value. Previously, the normalization logic would convert `"max"` to `"high"` (or `"xhigh"` for supported OpenAI models) for all models, which incorrectly stripped the valid `"max"` value when routing through DeepSeek's OpenAI-compatible provider.  
  
closes maximhq#4320

## Changes

- Added `supportsMaxReasoningEffort` helper in `utils.go` that identifies models with a `deepseek-v4` prefix as natively supporting `"max"` reasoning effort.
- Updated `normalizeOpenAIReasoningEffort` to short-circuit and return `"max"` unchanged for those models before applying the OpenAI-specific `"high"`/`"xhigh"` mapping.
- Extended tests in `chat_test.go` and `responses_test.go` to cover the `"max"` passthrough behavior for `deepseek-v4-pro` and `deepseek-v4-flash`.
- Updated the responses test harness to accept a configurable `provider` field so DeepSeek-routed requests can be tested independently from OpenAI-routed ones.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./core/providers/openai/...
```

Verify that the new test cases `"preserves max for deepseek-v4-pro"` and `"preserves max for deepseek-v4-flash"` pass in both `TestToOpenAIChatRequest_NormalizesReasoningEffort`, `TestOpenAIChatRequest_FilterOpenAISpecificParameters_NormalizesReasoningEffort`, and `TestToOpenAIResponsesRequest_NormalizesReasoningEffort`.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added official support for DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash), including recognition of provider-prefixed model identifiers.

* **Bug Fixes**
  * Reasoning-effort handling now preserves the "max" setting for DeepSeek V4 models across requests and responses, ensuring expected high-effort behavior is retained.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…aximhq#4467)

GLM-5.2 (Z.ai) natively supports reasoning_effort "max" (alongside
"high"), but normalizeOpenAIReasoningEffort() silently downgraded
"max" to "high" because GLM-5.2 was not in supportsMaxReasoningEffort().
This is the same normalization gap that previously affected DeepSeek V4
(issue maximhq#4320, PR maximhq#4330).

Affected packages: core/providers/openai/

Closes maximhq#4460

Signed-off-by: is911 <archilles92@gmail.com>
Signed-off-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
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.

normalizeOpenAIReasoningEffort maps 'max' → 'high' for DeepSeek V4 models, but DeepSeek V4 natively supports 'max'

3 participants