fix(deepseek): force tool_choice=required for thinking models + e2e regression suite#72
Open
roomote[bot] wants to merge 3 commits into
Open
fix(deepseek): force tool_choice=required for thinking models + e2e regression suite#72roomote[bot] wants to merge 3 commits into
roomote[bot] wants to merge 3 commits into
Conversation
Author
|
1 issue outstanding. Action required. See task
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| const isDeepSeekTest = testFile?.includes("deepseek-v4") === true | ||
|
|
||
| if (isRecord && !process.env.OPENROUTER_API_KEY) { | ||
| if (isRecord && isDeepSeekTest && !process.env.DEEPSEEK_API_KEY) { |
Author
There was a problem hiding this comment.
This adds the DeepSeek-specific record-mode key check, but the useMock gate below still ignores DEEPSEEK_API_KEY. Running DEEPSEEK_API_KEY=... TEST_FILE=deepseek-v4.test pnpm --filter @roo-code/vscode-e2e test:ci still starts aimock and injects AIMOCK_URL, so the new suite replays fixtures instead of exercising the live provider this PR is meant to validate. The DeepSeek key needs to count as a real-provider credential for DeepSeek-targeted runs.
6189beb to
cdae5dd
Compare
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.
Related GitHub Issue
Addresses PostHog error 019e08dc: 24 occurrences of
ConsecutiveMistakeErrorfromdeepseek-v4-pro(20) anddeepseek-v4-flash(4) thinking models.See also: #73 — follow-up to apply this fix holistically across all providers.
Description
Root cause: DeepSeek V4 thinking models sometimes return a plain text response instead of calling a tool when
tool_choice: "auto"is sent, causingMODEL_NO_TOOLS_USEDerrors that accumulate intoConsecutiveMistakeErrorafter 3 consecutive failures.Fix (
src/api/providers/deepseek.ts): Overridetool_choicefrom"auto"to"required"insideDeepSeekHandler.createMessagewhenisThinkingModelis true and tools are present. Sinceattempt_completionis always included as a tool, every turn must end with a tool call —"required"is semantically correct here. Scoped to thinking models only to minimise blast radius; #73 tracks the global fix.E2E regression suite (
apps/vscode-e2e/src/suite/providers/deepseek-v4.test.ts): Four tests coveringdeepseek-v4-flashanddeepseek-v4-pro× reasoning on/off. Each test verifies:max_completion_tokensis setthinkingandreasoning_effortparams match the reasoning toggleread_file→attempt_completiontool loopFixtures use
toolCallIdmatching for turn-2 to avoid cross-test count contamination from aimock's global match counters (documented inAGENTS.md).Test Procedure
Mock mode (no API key needed):
USE_MOCK=true TEST_FILE=deepseek-v4.test pnpm --filter @roo-code/vscode-e2e test:run # Expected: 4 passingRecord mode (requires DeepSeek API key):
Unit tests:
Pre-Submission Checklist
AGENTS.mdupdated with fixture guidance.Screenshots / Videos
N/A — backend provider change, no UI impact.
Documentation Updates
apps/vscode-e2e/AGENTS.mdupdated with multi-turn fixture andtoolCallIdmatching guidance.Additional Notes
If another provider shows similar
no_tools_usedflakiness, apply the same targeted override pattern and reference #73.Get in Touch