Skip to content

Commit 022beb5

Browse files
thaolaptrinhclaude
andcommitted
fix(models): guard empty effort set in resolveEffortForModel
An empty reasoningEfforts array ([] is truthy) bypassed the early return and reached reduce() on an empty array, which throws. No current model triggers it, but adding `reasoningEfforts: []` to models.json would have crashed the request. Added a length guard. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 83acb44 commit 022beb5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/translate/models.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ export function resolveEffortForModel(
7474
requested?: string,
7575
): string | undefined {
7676
const supported = REASONING_EFFORTS[canonicalModel];
77-
// Uncatalogued model, or nothing requested → preserve as-is (undefined or the value).
78-
if (!supported || !requested) return requested;
77+
// Uncatalogued/empty effort set, or nothing requested → preserve as-is
78+
// (undefined or the value). The empty-array guard matters: `[]` is truthy,
79+
// and reduce() on it below would otherwise throw.
80+
if (!supported || supported.length === 0 || !requested) return requested;
7981

8082
if (supported.includes(requested)) return requested;
8183

0 commit comments

Comments
 (0)