Repository navigation
fix(ai): send DeepSeek's reasoning_content back on assistant turns - #739
Merged
Merged
Conversation
DeepSeek's thinking mode (on by default) answers HTTP 400 when a request carrying `tools` has an assistant turn without the `reasoning_content` the model produced for it. AI-authored checks always send tools, so every generation or repair failed on its second provider call. The openai driver now reads `reasoning_content`, the agent loop keeps it on the assistant message, and the driver sends it back on that turn only. It is omitted when the model produced none, so OpenAI itself (which rejects the field) is unaffected. GLM's interleaved thinking follows the same rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #739 +/- ##
==========================================
- Coverage 89.20% 89.18% -0.02%
==========================================
Files 1318 1319 +1
Lines 134873 135035 +162
==========================================
+ Hits 120307 120426 +119
- Misses 14557 14600 +43
Partials 9 9
🚀 New features to boost your workflow:
|
fclairamb
enabled auto-merge (squash)
November 5, 2026 01:58
…t' into fix/ai-deepseek-reasoning-content
Merged
fclairamb
added a commit
that referenced
this pull request
Nov 5, 2026
🤖 I have created a release *beep* *boop* --- ## [0.43.1](v0.43.0...v0.43.1) (2026-11-05) ### Bug Fixes * **ai:** send DeepSeek's reasoning_content back on assistant turns ([#739](#739)) ([d62bfc6](d62bfc6)) * **dash0:** email-scanner filter, non-admin crash, audit incident target ([#755](#755)) ([920d231](920d231)) * **deps:** update dependency @hookform/resolvers to v7 ([#736](#736)) ([f44707a](f44707a)) * **deps:** update github.com/dop251/goja digest to 2413f21 ([#756](#756)) ([166579c](166579c)) * **deps:** update github.com/dop251/goja digest to 622d100 ([#746](#746)) ([f46b46c](f46b46c)) * **deps:** update github.com/dop251/goja digest to a177d21 ([#747](#747)) ([09b0d72](09b0d72)) * **deps:** update github.com/dop251/goja digest to a537e0c ([#754](#754)) ([70ca3d6](70ca3d6)) * **deps:** update github.com/dop251/goja digest to a7bf126 ([#753](#753)) ([962eff3](962eff3)) * **deps:** update github.com/dop251/goja digest to cf2ff0e ([#730](#730)) ([92b6c17](92b6c17)) * **deps:** update github.com/dop251/goja digest to f5d1d00 ([#750](#750)) ([44c6ecc](44c6ecc)) * **deps:** update go dependencies (non-major) ([#748](#748)) ([e3c2416](e3c2416)) * **deps:** update go dependencies (non-major) ([#751](#751)) ([146bec5](146bec5)) * **deps:** update go dependencies (non-major) ([#758](#758)) ([17b0d6d](17b0d6d)) * **deps:** update module github.com/dlclark/regexp2/v2 to v2.12.0 ([#737](#737)) ([50fdb8d](50fdb8d)) * **deps:** update module github.com/oapi-codegen/oapi-codegen/v2 to v2.8.2 ([#733](#733)) ([672293f](672293f)) * **deps:** update module modernc.org/sqlite to v1.61.1 ([#732](#732)) ([02cd682](02cd682)) * **docs:** tour video under 500 KB ([#752](#752)) ([1cdcce4](1cdcce4)) * **reports:** point "Open dashboard" at the organization's dashboard ([#744](#744)) ([061eca0](061eca0)) * **security:** JS check memory budget gaps and regexp time limit, Discord link re-authentication, invitation cap ([#735](#735)) ([6026b05](6026b05)) * **security:** JS check memory budget residuals, regexp call time and process isolation, crawl link scheme, subscriber list role, reset links on password change ([#742](#742)) ([de9aac0](de9aac0)) * **security:** JS isolation parent decode budget, RegExp symbol methods budget, single-use TOTP codes ([#749](#749)) ([d55abe5](d55abe5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
SP_AI_PROVIDER=openaipointed at DeepSeek, AI-authored checks (generate and repair) fail on the second provider call with HTTP 400. DeepSeek's thinking mode is on by default. When a request carriestools, every assistant turn must carry back thereasoning_contentthe model produced for it (DeepSeek docs). Ouropenaidriver dropped that field on purpose ("unknown response fields are ignored").Fix
ai.Response.Reasoning/ai.Message.Reasoning: the driver readsreasoning_content, and the loop keeps it on the assistant message.reasoning_contentback on assistant turns only, and only when the model produced one (omitempty). OpenAI itself rejects that field and never returns it, so it is unaffected.Tests
TestOpenAIReasoningContentRoundTrip: a fake server enforces DeepSeek's rule (400 when an assistant turn lacksreasoning_content) and runs a real tool loop. Positive control: with the loop change reverted, it fails with the 400. The non-thinking subcase asserts the field is never sent.go test ./internal/ai/... ./internal/aichecks/... ./internal/handlers/aichecks/...passes.golangci-lint run ./...reports 0 issues.🤖 Generated with Claude Code