From e959a853c3df58b365e3f43c5d968c1b024ae786 Mon Sep 17 00:00:00 2001 From: Wladmir Silva Date: Wed, 22 Jul 2026 16:52:28 -0300 Subject: [PATCH] fix(core): preserve disabled reasoning effort --- .../openaiContentGenerator/pipeline.test.ts | 35 +++++++++++++++++++ .../core/openaiContentGenerator/pipeline.ts | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/core/src/core/openaiContentGenerator/pipeline.test.ts b/packages/core/src/core/openaiContentGenerator/pipeline.test.ts index 29e2a408814..ee70f7d10a2 100644 --- a/packages/core/src/core/openaiContentGenerator/pipeline.test.ts +++ b/packages/core/src/core/openaiContentGenerator/pipeline.test.ts @@ -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'); + }); + 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) => ({ diff --git a/packages/core/src/core/openaiContentGenerator/pipeline.ts b/packages/core/src/core/openaiContentGenerator/pipeline.ts index eea26e11026..2c0e20774a6 100644 --- a/packages/core/src/core/openaiContentGenerator/pipeline.ts +++ b/packages/core/src/core/openaiContentGenerator/pipeline.ts @@ -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') { delete typed['reasoning_effort']; } // DeepSeek V4+ defaults `thinking.type` to `'enabled'`, so removing