Skip to content

Commit 3d7f63e

Browse files
anandgupta42claude
andcommitted
fix: parse the Gemini generation from any gemini-<N> id form
Prefixed or concatenated ids such as `vertex_gemini-4argon` did not match the anchored pattern, so they fell back to `thinkingBudget: 0` and the 400. One unanchored `gemini-(\d+)` parse now covers Gemini 3 and Gemini 4+ alike, which also replaces the substring fallback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 82775cc commit 3d7f63e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/opencode/src/provider/transform.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,9 @@ export namespace ProviderTransform {
13551355
model.capabilities.reasoning
13561356
) {
13571357
const id = model.api.id.toLowerCase()
1358-
const generation = Number(/(?:^|\/)gemini-(\d+)(?:[.-]|$)/.exec(id)?.[1])
1359-
// Fall back to the earlier substring rule when the id has no parseable generation.
1360-
if (generation === 3 || (Number.isNaN(generation) && id.includes("gemini-3"))) {
1358+
// Leading digits after "gemini-", wherever it appears (prefixed, concatenated or dated ids).
1359+
const generation = Number(/gemini-(\d+)/.exec(id)?.[1])
1360+
if (generation === 3) {
13611361
return { thinkingConfig: { thinkingLevel: "minimal" } }
13621362
}
13631363
// Gemini 2.x and unversioned aliases (e.g. gemini-flash-latest) keep the budget control.

‎packages/opencode/test/provider/transform.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ describe("ProviderTransform.smallOptions - google thinking", () => {
319319
{ id: "gemini-3.1-pro", thinkingConfig: { thinkingLevel: "minimal" } },
320320
{ id: "models/gemini-3-pro-preview", thinkingConfig: { thinkingLevel: "minimal" } },
321321
{ id: "vertex_gemini-3pro", thinkingConfig: { thinkingLevel: "minimal" } },
322+
{ id: "vertex_gemini-4argon", thinkingConfig: { thinkingLevel: "low" } },
323+
{ id: "publishers/google/models/gemini-4-argon", thinkingConfig: { thinkingLevel: "low" } },
322324
{ id: "gemini-2.5-flash-lite-preview-06-17", thinkingConfig: { thinkingBudget: 0 } },
323325
{ id: "gemini-4-argon", thinkingConfig: { thinkingLevel: "low" } },
324326
{ id: "gemini-5-pro", thinkingConfig: { thinkingLevel: "low" } },

0 commit comments

Comments
 (0)