({
model,
reasoningBudget,
reasoningEffort,
settings,
}: GetModelReasoningOptions)
| 139 | } |
| 140 | |
| 141 | export const getGeminiReasoning = ({ |
| 142 | model, |
| 143 | reasoningBudget, |
| 144 | reasoningEffort, |
| 145 | settings, |
| 146 | }: GetModelReasoningOptions): GeminiReasoningParams | undefined => { |
| 147 | // Budget-based (2.5) models: use thinkingBudget, not thinkingLevel. |
| 148 | if (shouldUseReasoningBudget({ model, settings })) { |
| 149 | return { thinkingBudget: reasoningBudget!, includeThoughts: true } |
| 150 | } |
| 151 | |
| 152 | // For effort-based Gemini models, rely directly on the selected effort value. |
| 153 | // We intentionally ignore enableReasoningEffort here so that explicitly chosen |
| 154 | // efforts in the UI (e.g. "High" for gemini-3-pro-preview) always translate |
| 155 | // into a thinkingConfig, regardless of legacy boolean flags. |
| 156 | const selectedEffort = (settings.reasoningEffort ?? model.reasoningEffort) as |
| 157 | | ReasoningEffortExtended |
| 158 | | "disable" |
| 159 | | undefined |
| 160 | |
| 161 | // Respect "off" / unset semantics from the effort selector itself. |
| 162 | if (!selectedEffort || selectedEffort === "disable") { |
| 163 | return undefined |
| 164 | } |
| 165 | |
| 166 | // Validate that the selected effort is supported by this specific model. |
| 167 | // e.g. gemini-3-pro-preview only supports ["low", "high"] — sending |
| 168 | // "medium" (carried over from a different model's settings) causes errors. |
| 169 | const effortToUse = |
| 170 | Array.isArray(model.supportsReasoningEffort) && |
| 171 | isGeminiThinkingLevel(selectedEffort) && |
| 172 | !model.supportsReasoningEffort.includes(selectedEffort) |
| 173 | ? model.reasoningEffort |
| 174 | : selectedEffort |
| 175 | |
| 176 | // Effort-based models on Google GenAI support minimal/low/medium/high levels. |
| 177 | if (!effortToUse || !isGeminiThinkingLevel(effortToUse)) { |
| 178 | return undefined |
| 179 | } |
| 180 | |
| 181 | return { thinkingLevel: effortToUse as unknown as GeminiReasoningParams["thinkingLevel"], includeThoughts: true } |
| 182 | } |
no test coverage detected