@@ -164,3 +164,84 @@ describe("openai-compatible adapter reasoning_content handling", () => {
164164 expect ( assistant ?. [ "reasoning_content" ] ) . toBe ( "ponder" ) ;
165165 } ) ;
166166} ) ;
167+
168+ describe ( "openai-compatible adapter V4 effort wiring" , ( ) => {
169+ function bodyForModel (
170+ model : string ,
171+ options : InferenceOptions ,
172+ ) : Record < string , unknown > {
173+ const adapter = createOpenAICompatibleAdapter ( {
174+ ...source ,
175+ model,
176+ } as typeof source ) ;
177+ const built = adapter . buildRequest ( messages , model , options ) ;
178+ return JSON . parse ( built . body ) as Record < string , unknown > ;
179+ }
180+
181+ test ( "none drops reasoning_effort and sets thinking off" , ( ) => {
182+ const body = bodyForModel ( "deepseek-v4-pro" , {
183+ providerOptions : { reasoning_effort : "none" } ,
184+ } as InferenceOptions ) ;
185+ expect ( "reasoning_effort" in body ) . toBe ( false ) ;
186+ expect ( body [ "chat_template_kwargs" ] ) . toEqual ( { thinking : false } ) ;
187+ } ) ;
188+
189+ test . each ( [ "xhigh" , "max" ] as const ) (
190+ "maps ladder %s through verbatim" ,
191+ ( effort ) => {
192+ const body = bodyForModel ( "deepseek-v4-pro" , {
193+ providerOptions : { reasoning_effort : effort } ,
194+ } as InferenceOptions ) ;
195+ expect ( body [ "reasoning_effort" ] ) . toBe ( effort ) ;
196+ } ,
197+ ) ;
198+
199+ test . each ( [ "low" , "medium" , "high" ] as const ) (
200+ "leaves off-ladder %s untouched" ,
201+ ( effort ) => {
202+ const body = bodyForModel ( "deepseek-v4-pro" , {
203+ providerOptions : { reasoning_effort : effort } ,
204+ } as InferenceOptions ) ;
205+ expect ( body [ "reasoning_effort" ] ) . toBe ( effort ) ;
206+ } ,
207+ ) ;
208+
209+ describe ( "v4-effort is no-op for non-V4" , ( ) => {
210+ const models = [
211+ "gpt-5" ,
212+ "gpt-5.1" ,
213+ "kimi-k2" ,
214+ "grok-4.6" ,
215+ "claude-sonnet-4.5" ,
216+ "glm-5.3" ,
217+ "some-openai-compatible-model" ,
218+ "deepseek-r1" ,
219+ "deepseek-v3" ,
220+ ] ;
221+
222+ test . each ( models ) (
223+ "merged body for %s is byte-identical to a manual base+merge (V4 step no-op)" ,
224+ ( model ) => {
225+ const base = bodyForModel ( model , { } as InferenceOptions ) ;
226+ const withEffort = bodyForModel ( model , {
227+ providerOptions : { reasoning_effort : "high" } ,
228+ } as InferenceOptions ) ;
229+ const expected = {
230+ ...base ,
231+ ...( { reasoning_effort : "high" } as const ) ,
232+ } ;
233+ expect ( withEffort ) . toEqual ( expected ) ;
234+ } ,
235+ ) ;
236+
237+ test . each ( models ) (
238+ "merged body for %s carries reasoning_effort verbatim" ,
239+ ( model ) => {
240+ const body = bodyForModel ( model , {
241+ providerOptions : { reasoning_effort : "high" } ,
242+ } as InferenceOptions ) ;
243+ expect ( body [ "reasoning_effort" ] ) . toBe ( "high" ) ;
244+ } ,
245+ ) ;
246+ } ) ;
247+ } ) ;
0 commit comments