-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(core): preserve disabled reasoning effort #7541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -867,6 +867,41 @@ describe('ContentGenerationPipeline', () => { | |
| expect(apiCall.reasoning).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should preserve reasoning_effort none when thinking is disabled', async () => { | ||
| mockContentGeneratorConfig = { | ||
| ...mockContentGeneratorConfig, | ||
| samplingParams: { reasoning_effort: 'none' }, | ||
| } as ContentGeneratorConfig; | ||
| mockConfig = { | ||
| ...mockConfig, | ||
| contentGeneratorConfig: mockContentGeneratorConfig, | ||
| }; | ||
| pipeline = new ContentGenerationPipeline(mockConfig); | ||
|
|
||
| const request: GenerateContentParameters = { | ||
| model: 'gpt-5', | ||
| contents: [{ parts: [{ text: 'Classify action' }], role: 'user' }], | ||
| config: { thinkingConfig: { includeThoughts: false } }, | ||
| }; | ||
|
|
||
| (mockConverter.convertGeminiRequestToOpenAI as Mock).mockReturnValue([ | ||
| { role: 'user', content: 'Classify action' }, | ||
| ]); | ||
| (mockConverter.convertOpenAIResponseToGemini as Mock).mockReturnValue( | ||
| new GenerateContentResponse(), | ||
| ); | ||
| (mockClient.chat.completions.create as Mock).mockResolvedValue({ | ||
| id: 'response-id', | ||
| choices: [{ message: { content: 'safe' }, finish_reason: 'stop' }], | ||
| } as OpenAI.Chat.ChatCompletion); | ||
|
|
||
| await pipeline.execute(request, 'side-query:permission-classifier'); | ||
|
|
||
| const apiCall = (mockClient.chat.completions.create as Mock).mock | ||
| .calls[0][0]; | ||
| expect(apiCall.reasoning_effort).toBe('none'); | ||
| }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest adding a reverse test: |
||
|
|
||
| it('should preserve enable_thinking when thinking is not explicitly disabled', async () => { | ||
| // Arrange — normal request (not forked query), enable_thinking should be preserved | ||
| (mockProvider.buildRequest as Mock).mockImplementation((req) => ({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -897,7 +897,7 @@ export class ContentGenerationPipeline { | |
| if ('reasoning' in typed) { | ||
| delete typed['reasoning']; | ||
| } | ||
| if ('reasoning_effort' in typed) { | ||
| if ('reasoning_effort' in typed && typed['reasoning_effort'] !== 'none') { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the comparison is case-sensitive (
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing worth noting:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The block comment above still says "we strip both shapes here", which is no longer accurate for the flat shape. And the |
||
| delete typed['reasoning_effort']; | ||
| } | ||
| // DeepSeek V4+ defaults `thinking.type` to `'enabled'`, so removing | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] The new condition
typed['reasoning_effort'] !== 'none'has two branches (preserve when'none', strip otherwise), but only the preserve branch is tested. No test verifies thatreasoning_effortwith a non-'none'value (e.g.,'high') is still stripped when thinking is disabled. — Failure scenario: a future change accidentally widens the preservation condition (e.g., removes the!== 'none'guard), causing non-nonereasoning_effortvalues to leak through when thinking is disabled, contradicting the disable signal and adding unwanted reasoning latency/cost.— qwen3.7-max via Qwen Code /review