@@ -257,6 +257,44 @@ describe("openai-compatible adapter V4 effort wiring", () => {
257257 some : "existing" ,
258258 } ) ;
259259 } ) ;
260+
261+ test ( "provider-set thinking is preserved (absent-only thinking)" , ( ) => {
262+ // A provider-supplied thinking value beats the V4 effort's implied one:
263+ // `none` normally forces thinking off, but an explicit thinking:true
264+ // must be kept (never force-stamped), and vice versa.
265+ const noneThenTrue = bodyForModel ( "deepseek-v4-pro" , {
266+ providerOptions : {
267+ reasoning_effort : "none" ,
268+ chat_template_kwargs : { thinking : true } ,
269+ } ,
270+ } as InferenceOptions ) ;
271+ expect ( noneThenTrue [ "chat_template_kwargs" ] ) . toEqual ( { thinking : true } ) ;
272+
273+ const xhighThenFalse = bodyForModel ( "deepseek-v4-pro" , {
274+ providerOptions : {
275+ reasoning_effort : "xhigh" ,
276+ chat_template_kwargs : { thinking : false } ,
277+ } ,
278+ } as InferenceOptions ) ;
279+ expect ( xhighThenFalse [ "chat_template_kwargs" ] ) . toEqual ( {
280+ thinking : false ,
281+ } ) ;
282+ } ) ;
283+
284+ test ( "unset effort does not inject empty chat_template_kwargs" , ( ) => {
285+ const body = bodyForModel ( "deepseek-v4-pro" , { } as InferenceOptions ) ;
286+ expect ( "chat_template_kwargs" in body ) . toBe ( false ) ;
287+ expect ( body [ "reasoning_effort" ] ) . toBeUndefined ( ) ;
288+ } ) ;
289+
290+ test ( "provider-set stream_options is preserved (absent-only)" , ( ) => {
291+ const body = bodyForModel ( "deepseek-v4-pro" , {
292+ providerOptions : {
293+ stream_options : { include_usage : false } ,
294+ } ,
295+ } as InferenceOptions ) ;
296+ expect ( body [ "stream_options" ] ) . toEqual ( { include_usage : false } ) ;
297+ } ) ;
260298 } ) ;
261299
262300 describe ( "v4-effort is no-op for non-V4" , ( ) => {
0 commit comments