@@ -186,29 +186,25 @@ describe("OpencodeGoHandler", () => {
186186 model : "glm-5.1" ,
187187 stream : true ,
188188 stream_options : { include_usage : true } ,
189- // glm-5.1 maxTokens (131_072) is clamped to 20% of its 204_800
190- // context window => 40_960.
191- max_completion_tokens : 40_960 ,
189+ // glm-5.1 maxTokens is 131_072 (native registry value).
190+ max_completion_tokens : 131_072 ,
192191 temperature : expect . any ( Number ) ,
193192 } ) ,
194193 expect . objectContaining ( { signal : expect . any ( AbortSignal ) } ) ,
195194 )
196195 } )
197196
198- it ( "forwards the model's default reasoning_effort for reasoning-capable models" , async ( ) => {
197+ // The OpenAI completion path does not inject reasoning_effort ā
198+ // reasoning is controlled server-side by the Go gateway.
199+ it ( "does not inject reasoning_effort into OpenAI-style requests" , async ( ) => {
199200 const handler = new OpencodeGoHandler ( mockOptions )
200201 const messages : Anthropic . Messages . MessageParam [ ] = [ { role : "user" , content : "Hi" } ]
201202 for await ( const _chunk of handler . createMessage ( "sys" , messages ) ) {
202203 void _chunk // drain
203204 }
204205
205- // glm-5.1 advertises supportsReasoningEffort with a default of "medium".
206- expect ( mockCreate ) . toHaveBeenCalledWith (
207- expect . objectContaining ( {
208- model : "glm-5.1" ,
209- reasoning_effort : "medium" ,
210- } ) ,
211- )
206+ const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ] as Record < string , unknown >
207+ expect ( callArgs . reasoning_effort ) . toBeUndefined ( )
212208 } )
213209
214210 it ( "omits reasoning_effort when the user disables reasoning" , async ( ) => {
@@ -370,15 +366,20 @@ describe("OpencodeGoHandler", () => {
370366 expect ( chunks ) . toContainEqual ( { type : "usage" , inputTokens : 0 , outputTokens : 0 } )
371367 } )
372368
373- it ( "honors includeMaxTokens/modelMaxTokens override for max_completion_tokens " , async ( ) => {
369+ it ( "uses native model maxTokens even with includeMaxTokens set " , async ( ) => {
374370 const handler = new OpencodeGoHandler ( { ...mockOptions , includeMaxTokens : true , modelMaxTokens : 999 } )
375371 const messages : Anthropic . Messages . MessageParam [ ] = [ { role : "user" , content : "Hi" } ]
376372
377373 for await ( const _chunk of handler . createMessage ( "sys" , messages ) ) {
378374 void _chunk
379375 }
380376
381- expect ( mockCreate ) . toHaveBeenCalledWith ( expect . objectContaining ( { max_completion_tokens : 999 } ) )
377+ // OpenAI path uses info.maxTokens directly (131_072); includeMaxTokens
378+ // only affects the Anthropic-format path.
379+ expect ( mockCreate ) . toHaveBeenCalledWith (
380+ expect . objectContaining ( { max_completion_tokens : 131_072 } ) ,
381+ expect . objectContaining ( { signal : expect . any ( AbortSignal ) } ) ,
382+ )
382383 } )
383384 } )
384385
@@ -391,9 +392,8 @@ describe("OpencodeGoHandler", () => {
391392 expect . objectContaining ( {
392393 model : "glm-5.1" ,
393394 stream : false ,
394- // glm-5.1 maxTokens (131_072) clamped to 20% of 204_800 => 40_960.
395- max_completion_tokens : 40_960 ,
396- reasoning_effort : "medium" ,
395+ // glm-5.1 maxTokens is 131_072 (native registry value).
396+ max_completion_tokens : 131_072 ,
397397 } ) ,
398398 expect . objectContaining ( { signal : expect . any ( AbortSignal ) } ) ,
399399 )
0 commit comments