@@ -380,6 +380,55 @@ describe("OpenAiHandler", () => {
380380 const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
381381 expect ( callArgs . temperature ) . toBe ( 0.6 )
382382 } )
383+
384+ it ( "should detect DeepSeek V3 models with reasoning effort as reasoning models" , async ( ) => {
385+ const deepseekV3Options : ApiHandlerOptions = {
386+ ...mockOptions ,
387+ openAiModelId : "deepseek-v3" ,
388+ openAiCustomModelInfo : {
389+ ...openAiModelInfoSaneDefaults ,
390+ supportsReasoningEffort : true ,
391+ } ,
392+ reasoningEffort : "medium" ,
393+ }
394+ const deepseekHandler = new OpenAiHandler ( deepseekV3Options )
395+ const stream = deepseekHandler . createMessage ( systemPrompt , messages )
396+ for await ( const _chunk of stream ) {
397+ // consume stream
398+ }
399+ // Assert the mockCreate was called with R1 format messages
400+ expect ( mockCreate ) . toHaveBeenCalled ( )
401+ const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
402+ // When DeepSeek is detected as a reasoning model, it uses R1 format
403+ // which combines system and user messages
404+ expect ( callArgs . messages [ 0 ] . role ) . toBe ( "user" )
405+ expect ( callArgs . messages [ 0 ] . content ) . toContain ( "You are a helpful assistant." )
406+ expect ( callArgs . reasoning_effort ) . toBe ( "medium" )
407+ } )
408+
409+ it ( "should detect DeepSeek-chat models with reasoning effort as reasoning models" , async ( ) => {
410+ const deepseekChatOptions : ApiHandlerOptions = {
411+ ...mockOptions ,
412+ openAiModelId : "deepseek-chat" ,
413+ openAiCustomModelInfo : {
414+ ...openAiModelInfoSaneDefaults ,
415+ supportsReasoningEffort : true ,
416+ } ,
417+ reasoningEffort : "high" ,
418+ }
419+ const deepseekHandler = new OpenAiHandler ( deepseekChatOptions )
420+ const stream = deepseekHandler . createMessage ( systemPrompt , messages )
421+ for await ( const _chunk of stream ) {
422+ // consume stream
423+ }
424+ // Assert the mockCreate was called with R1 format messages
425+ expect ( mockCreate ) . toHaveBeenCalled ( )
426+ const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
427+ // When DeepSeek is detected as a reasoning model, it uses R1 format
428+ expect ( callArgs . messages [ 0 ] . role ) . toBe ( "user" )
429+ expect ( callArgs . messages [ 0 ] . content ) . toContain ( "You are a helpful assistant." )
430+ expect ( callArgs . reasoning_effort ) . toBe ( "high" )
431+ } )
383432 } )
384433
385434 describe ( "error handling" , ( ) => {
0 commit comments