@@ -2653,3 +2653,204 @@ describe("ProviderTransform.variants", () => {
26532653 } )
26542654 } )
26552655} )
2656+
2657+ // ---------------------------------------------------------------------------
2658+ // ProviderTransform.temperature / topP / topK — model-specific inference params
2659+ // ---------------------------------------------------------------------------
2660+
2661+ function modelWithId ( id : string ) {
2662+ return { id, api : { id } } as any
2663+ }
2664+
2665+ describe ( "ProviderTransform.temperature" , ( ) => {
2666+ test ( "qwen models return 0.55" , ( ) => {
2667+ expect ( ProviderTransform . temperature ( modelWithId ( "qwen-2.5-coder" ) ) ) . toBe ( 0.55 )
2668+ expect ( ProviderTransform . temperature ( modelWithId ( "Qwen-Max" ) ) ) . toBe ( 0.55 )
2669+ } )
2670+
2671+ test ( "claude models return undefined" , ( ) => {
2672+ expect ( ProviderTransform . temperature ( modelWithId ( "claude-3-5-sonnet" ) ) ) . toBeUndefined ( )
2673+ expect ( ProviderTransform . temperature ( modelWithId ( "claude-opus-4-6" ) ) ) . toBeUndefined ( )
2674+ } )
2675+
2676+ test ( "gemini models return 1.0" , ( ) => {
2677+ expect ( ProviderTransform . temperature ( modelWithId ( "gemini-2.5-pro" ) ) ) . toBe ( 1.0 )
2678+ } )
2679+
2680+ test ( "glm-4.6 and glm-4.7 return 1.0" , ( ) => {
2681+ expect ( ProviderTransform . temperature ( modelWithId ( "glm-4.6-flash" ) ) ) . toBe ( 1.0 )
2682+ expect ( ProviderTransform . temperature ( modelWithId ( "glm-4.7-plus" ) ) ) . toBe ( 1.0 )
2683+ } )
2684+
2685+ test ( "minimax-m2 returns 1.0" , ( ) => {
2686+ expect ( ProviderTransform . temperature ( modelWithId ( "minimax-m2-pro" ) ) ) . toBe ( 1.0 )
2687+ } )
2688+
2689+ test ( "kimi-k2 thinking variants return 1.0" , ( ) => {
2690+ expect ( ProviderTransform . temperature ( modelWithId ( "kimi-k2-thinking" ) ) ) . toBe ( 1.0 )
2691+ expect ( ProviderTransform . temperature ( modelWithId ( "kimi-k2.5-pro" ) ) ) . toBe ( 1.0 )
2692+ expect ( ProviderTransform . temperature ( modelWithId ( "kimi-k2p5-chat" ) ) ) . toBe ( 1.0 )
2693+ expect ( ProviderTransform . temperature ( modelWithId ( "kimi-k2-5-turbo" ) ) ) . toBe ( 1.0 )
2694+ } )
2695+
2696+ test ( "plain kimi-k2 (non-thinking) returns 0.6" , ( ) => {
2697+ expect ( ProviderTransform . temperature ( modelWithId ( "kimi-k2" ) ) ) . toBe ( 0.6 )
2698+ expect ( ProviderTransform . temperature ( modelWithId ( "kimi-k2-chat" ) ) ) . toBe ( 0.6 )
2699+ } )
2700+
2701+ test ( "unknown model returns undefined" , ( ) => {
2702+ expect ( ProviderTransform . temperature ( modelWithId ( "meta-llama-3" ) ) ) . toBeUndefined ( )
2703+ expect ( ProviderTransform . temperature ( modelWithId ( "mixtral-8x7b" ) ) ) . toBeUndefined ( )
2704+ } )
2705+ } )
2706+
2707+ describe ( "ProviderTransform.topP" , ( ) => {
2708+ test ( "qwen models return 1" , ( ) => {
2709+ expect ( ProviderTransform . topP ( modelWithId ( "qwen-2.5-coder" ) ) ) . toBe ( 1 )
2710+ } )
2711+
2712+ test ( "minimax-m2 returns 0.95" , ( ) => {
2713+ expect ( ProviderTransform . topP ( modelWithId ( "minimax-m2-pro" ) ) ) . toBe ( 0.95 )
2714+ } )
2715+
2716+ test ( "gemini returns 0.95" , ( ) => {
2717+ expect ( ProviderTransform . topP ( modelWithId ( "gemini-2.5-pro" ) ) ) . toBe ( 0.95 )
2718+ } )
2719+
2720+ test ( "kimi-k2.5 / k2p5 / k2-5 return 0.95" , ( ) => {
2721+ expect ( ProviderTransform . topP ( modelWithId ( "kimi-k2.5-pro" ) ) ) . toBe ( 0.95 )
2722+ expect ( ProviderTransform . topP ( modelWithId ( "kimi-k2p5" ) ) ) . toBe ( 0.95 )
2723+ expect ( ProviderTransform . topP ( modelWithId ( "kimi-k2-5" ) ) ) . toBe ( 0.95 )
2724+ } )
2725+
2726+ test ( "plain kimi-k2 returns undefined (not in special list)" , ( ) => {
2727+ expect ( ProviderTransform . topP ( modelWithId ( "kimi-k2" ) ) ) . toBeUndefined ( )
2728+ } )
2729+
2730+ test ( "unknown model returns undefined" , ( ) => {
2731+ expect ( ProviderTransform . topP ( modelWithId ( "meta-llama-3" ) ) ) . toBeUndefined ( )
2732+ } )
2733+ } )
2734+
2735+ describe ( "ProviderTransform.topK" , ( ) => {
2736+ test ( "minimax-m2 sub-variants (m2., m25, m21) return 40" , ( ) => {
2737+ expect ( ProviderTransform . topK ( modelWithId ( "minimax-m2.1-chat" ) ) ) . toBe ( 40 )
2738+ expect ( ProviderTransform . topK ( modelWithId ( "minimax-m25-pro" ) ) ) . toBe ( 40 )
2739+ expect ( ProviderTransform . topK ( modelWithId ( "minimax-m21-lite" ) ) ) . toBe ( 40 )
2740+ } )
2741+
2742+ test ( "minimax-m2 base returns 20" , ( ) => {
2743+ expect ( ProviderTransform . topK ( modelWithId ( "minimax-m2-pro" ) ) ) . toBe ( 20 )
2744+ expect ( ProviderTransform . topK ( modelWithId ( "minimax-m2" ) ) ) . toBe ( 20 )
2745+ } )
2746+
2747+ test ( "gemini returns 64" , ( ) => {
2748+ expect ( ProviderTransform . topK ( modelWithId ( "gemini-2.5-pro" ) ) ) . toBe ( 64 )
2749+ } )
2750+
2751+ test ( "unknown model returns undefined" , ( ) => {
2752+ expect ( ProviderTransform . topK ( modelWithId ( "claude-3-5-sonnet" ) ) ) . toBeUndefined ( )
2753+ expect ( ProviderTransform . topK ( modelWithId ( "gpt-5.1" ) ) ) . toBeUndefined ( )
2754+ } )
2755+ } )
2756+
2757+ // ---------------------------------------------------------------------------
2758+ // ProviderTransform.smallOptions — minimal config for auxiliary LLM calls
2759+ // ---------------------------------------------------------------------------
2760+
2761+ describe ( "ProviderTransform.smallOptions" , ( ) => {
2762+ function smallModel ( overrides : { providerID : string ; apiId : string ; npm ?: string } ) {
2763+ return {
2764+ providerID : overrides . providerID ,
2765+ api : {
2766+ id : overrides . apiId ,
2767+ npm : overrides . npm ?? "" ,
2768+ } ,
2769+ } as any
2770+ }
2771+
2772+ test ( "openai gpt-5.1 (subdot) returns store:false + reasoningEffort:low" , ( ) => {
2773+ const model = smallModel ( { providerID : "openai" , apiId : "gpt-5.1-turbo" } )
2774+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { store : false , reasoningEffort : "low" } )
2775+ } )
2776+
2777+ test ( "openai gpt-5.2 returns store:false + reasoningEffort:low" , ( ) => {
2778+ const model = smallModel ( { providerID : "openai" , apiId : "gpt-5.2" } )
2779+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { store : false , reasoningEffort : "low" } )
2780+ } )
2781+
2782+ test ( "openai gpt-5 (base, no subdot) returns store:false + reasoningEffort:minimal" , ( ) => {
2783+ const model = smallModel ( { providerID : "openai" , apiId : "gpt-5" } )
2784+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { store : false , reasoningEffort : "minimal" } )
2785+ } )
2786+
2787+ test ( "openai non-gpt-5 returns only store:false" , ( ) => {
2788+ const model = smallModel ( { providerID : "openai" , apiId : "gpt-4o-mini" } )
2789+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { store : false } )
2790+ } )
2791+
2792+ test ( "github-copilot npm also triggers openai path" , ( ) => {
2793+ const model = smallModel ( { providerID : "github-copilot" , apiId : "gpt-5.1" , npm : "@ai-sdk/github-copilot" } )
2794+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { store : false , reasoningEffort : "low" } )
2795+ } )
2796+
2797+ test ( "google gemini-3 returns thinkingLevel:minimal" , ( ) => {
2798+ const model = smallModel ( { providerID : "google" , apiId : "gemini-3-flash" } )
2799+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { thinkingConfig : { thinkingLevel : "minimal" } } )
2800+ } )
2801+
2802+ test ( "google gemini-2.5 returns thinkingBudget:0" , ( ) => {
2803+ const model = smallModel ( { providerID : "google" , apiId : "gemini-2.5-pro" } )
2804+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { thinkingConfig : { thinkingBudget : 0 } } )
2805+ } )
2806+
2807+ test ( "openrouter google model returns reasoning:disabled" , ( ) => {
2808+ const model = smallModel ( { providerID : "openrouter" , apiId : "google/gemini-2.5-pro" } )
2809+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { reasoning : { enabled : false } } )
2810+ } )
2811+
2812+ test ( "openrouter non-google returns reasoningEffort:minimal" , ( ) => {
2813+ const model = smallModel ( { providerID : "openrouter" , apiId : "anthropic/claude-3-5-sonnet" } )
2814+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { reasoningEffort : "minimal" } )
2815+ } )
2816+
2817+ test ( "venice returns disableThinking" , ( ) => {
2818+ const model = smallModel ( { providerID : "venice" , apiId : "deepseek-r1" } )
2819+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { veniceParameters : { disableThinking : true } } )
2820+ } )
2821+
2822+ test ( "unknown provider returns empty object" , ( ) => {
2823+ const model = smallModel ( { providerID : "custom-provider" , apiId : "custom-model" } )
2824+ expect ( ProviderTransform . smallOptions ( model ) ) . toEqual ( { } )
2825+ } )
2826+ } )
2827+
2828+ // ---------------------------------------------------------------------------
2829+ // ProviderTransform.maxOutputTokens — output token cap
2830+ // ---------------------------------------------------------------------------
2831+
2832+ describe ( "ProviderTransform.maxOutputTokens" , ( ) => {
2833+ function tokenModel ( output : number ) {
2834+ return { limit : { output } } as any
2835+ }
2836+
2837+ test ( "caps at OUTPUT_TOKEN_MAX when model limit exceeds it" , ( ) => {
2838+ expect ( ProviderTransform . maxOutputTokens ( tokenModel ( 50000 ) ) ) . toBe ( OUTPUT_TOKEN_MAX )
2839+ } )
2840+
2841+ test ( "returns model limit when below cap" , ( ) => {
2842+ expect ( ProviderTransform . maxOutputTokens ( tokenModel ( 1000 ) ) ) . toBe ( 1000 )
2843+ } )
2844+
2845+ test ( "returns exact cap at boundary" , ( ) => {
2846+ expect ( ProviderTransform . maxOutputTokens ( tokenModel ( OUTPUT_TOKEN_MAX ) ) ) . toBe ( OUTPUT_TOKEN_MAX )
2847+ } )
2848+
2849+ test ( "falls back to OUTPUT_TOKEN_MAX when limit is 0" , ( ) => {
2850+ expect ( ProviderTransform . maxOutputTokens ( tokenModel ( 0 ) ) ) . toBe ( OUTPUT_TOKEN_MAX )
2851+ } )
2852+
2853+ test ( "falls back to OUTPUT_TOKEN_MAX when limit is NaN" , ( ) => {
2854+ expect ( ProviderTransform . maxOutputTokens ( tokenModel ( NaN ) ) ) . toBe ( OUTPUT_TOKEN_MAX )
2855+ } )
2856+ } )
0 commit comments