|
1 | 1 | // npx vitest run src/api/transform/__tests__/reasoning.spec.ts
|
2 | 2 |
|
3 |
| -import type { ModelInfo, ProviderSettings } from "@roo-code/types" |
| 3 | +import type { ModelInfo, ProviderSettings, ReasoningEffortWithMinimal } from "@roo-code/types" |
4 | 4 |
|
5 | 5 | import {
|
6 | 6 | getOpenRouterReasoning,
|
@@ -154,24 +154,81 @@ describe("reasoning.ts", () => {
|
154 | 154 |
|
155 | 155 | const result = getOpenRouterReasoning(optionsWithoutEffort)
|
156 | 156 |
|
157 |
| - expect(result).toEqual({ effort: undefined }) |
| 157 | + // When reasoningEffort is undefined, the function should return undefined |
| 158 | + expect(result).toBeUndefined() |
158 | 159 | })
|
159 | 160 |
|
160 |
| - it("should handle all reasoning effort values", () => { |
161 |
| - const efforts: Array<"low" | "medium" | "high"> = ["low", "medium", "high"] |
| 161 | + it("should handle all reasoning effort values including minimal", () => { |
| 162 | + const efforts: Array<ReasoningEffortWithMinimal> = ["minimal", "low", "medium", "high"] |
162 | 163 |
|
163 | 164 | efforts.forEach((effort) => {
|
164 | 165 | const modelWithEffort: ModelInfo = {
|
165 | 166 | ...baseModel,
|
| 167 | + supportsReasoningEffort: true, |
| 168 | + } |
| 169 | + |
| 170 | + const settingsWithEffort: ProviderSettings = { |
166 | 171 | reasoningEffort: effort,
|
167 | 172 | }
|
168 | 173 |
|
169 |
| - const options = { ...baseOptions, model: modelWithEffort, reasoningEffort: effort } |
| 174 | + const options = { |
| 175 | + ...baseOptions, |
| 176 | + model: modelWithEffort, |
| 177 | + settings: settingsWithEffort, |
| 178 | + reasoningEffort: effort, |
| 179 | + } |
170 | 180 | const result = getOpenRouterReasoning(options)
|
| 181 | + // All effort values including "minimal" should be passed through |
171 | 182 | expect(result).toEqual({ effort })
|
172 | 183 | })
|
173 | 184 | })
|
174 | 185 |
|
| 186 | + it("should handle minimal reasoning effort specifically", () => { |
| 187 | + const modelWithSupported: ModelInfo = { |
| 188 | + ...baseModel, |
| 189 | + supportsReasoningEffort: true, |
| 190 | + } |
| 191 | + |
| 192 | + const settingsWithEffort: ProviderSettings = { |
| 193 | + reasoningEffort: "minimal", |
| 194 | + } |
| 195 | + |
| 196 | + const options = { |
| 197 | + ...baseOptions, |
| 198 | + model: modelWithSupported, |
| 199 | + settings: settingsWithEffort, |
| 200 | + reasoningEffort: "minimal" as ReasoningEffortWithMinimal, |
| 201 | + } |
| 202 | + |
| 203 | + const result = getOpenRouterReasoning(options) |
| 204 | + |
| 205 | + // "minimal" should be passed through to OpenRouter |
| 206 | + expect(result).toEqual({ effort: "minimal" }) |
| 207 | + }) |
| 208 | + |
| 209 | + it("should handle minimal reasoning effort from settings", () => { |
| 210 | + const modelWithSupported: ModelInfo = { |
| 211 | + ...baseModel, |
| 212 | + supportsReasoningEffort: true, |
| 213 | + } |
| 214 | + |
| 215 | + const settingsWithMinimal: ProviderSettings = { |
| 216 | + reasoningEffort: "minimal" as ReasoningEffortWithMinimal, |
| 217 | + } |
| 218 | + |
| 219 | + const options = { |
| 220 | + ...baseOptions, |
| 221 | + model: modelWithSupported, |
| 222 | + settings: settingsWithMinimal, |
| 223 | + reasoningEffort: "minimal" as ReasoningEffortWithMinimal, |
| 224 | + } |
| 225 | + |
| 226 | + const result = getOpenRouterReasoning(options) |
| 227 | + |
| 228 | + // "minimal" should be passed through to OpenRouter |
| 229 | + expect(result).toEqual({ effort: "minimal" }) |
| 230 | + }) |
| 231 | + |
175 | 232 | it("should handle zero reasoningBudget", () => {
|
176 | 233 | const modelWithRequired: ModelInfo = {
|
177 | 234 | ...baseModel,
|
|
0 commit comments