diff --git a/src/plugin/config/model-discovery.test.ts b/src/plugin/config/model-discovery.test.ts index 5ff0b92..777f283 100644 --- a/src/plugin/config/model-discovery.test.ts +++ b/src/plugin/config/model-discovery.test.ts @@ -71,6 +71,28 @@ describe("model discovery is forward-only", () => { expect(buildDiscoveredModels(["gemini-4-argon"])["antigravity-gemini-4-argon"]).toBeDefined(); }); + it("groups the Gemini 4 Hydrogen family and keeps xhigh out of the picker", () => { + // The official CLI ships Hydrogen as Low|Medium|High|XHigh. OpenCode's + // ModelThinkingLevel has no `xhigh`, so the tier is still recognized and + // stripped from the family id, but it is not offered as a variant. + expect(isDiscoverableModelId("gemini-4-hydrogen-xhigh")).toBe(true); + expect(isDiscoverableModelId("gemini-4-carbon-high")).toBe(true); + + const discovered = buildDiscoveredModels([ + "gemini-4-hydrogen-low", + "gemini-4-hydrogen-medium", + "gemini-4-hydrogen-high", + "gemini-4-hydrogen-xhigh", + ]); + + expect(Object.keys(discovered)).toEqual(["antigravity-gemini-4-hydrogen"]); + expect(Object.keys(discovered["antigravity-gemini-4-hydrogen"]!.variants!).sort()).toEqual([ + "high", + "low", + "medium", + ]); + }); + it("surfaces Claude generations newer than the curated floor", () => { // Successors of the Claude 4.6 trio that Google removes on 2026-11-02. expect(isDiscoverableModelId("claude-sonnet-5-5")).toBe(true); diff --git a/src/plugin/config/model-discovery.ts b/src/plugin/config/model-discovery.ts index 7132eac..05c1d97 100644 --- a/src/plugin/config/model-discovery.ts +++ b/src/plugin/config/model-discovery.ts @@ -120,8 +120,8 @@ const TIERED_SUFFIX = /-tiered$/i; * a thinking dial is noise, and the curated catalog already models 3.8 Flash that * way (`antigravity-gemini-3.8-flash` + `low|medium|high` variants). */ -const TIER_SUFFIX = /-(low|medium|high|max)$/i; -const TIER_ORDER = ["low", "medium", "high", "max"] as const; +const TIER_SUFFIX = /-(low|medium|high|xhigh|max)$/i; +const TIER_ORDER = ["low", "medium", "high", "xhigh", "max"] as const; type TierName = (typeof TIER_ORDER)[number]; /** Backend limits measured from `fetchAvailableModels`, keyed by backend id. */ @@ -169,6 +169,17 @@ const GEMINI_THINKING_VARIANTS: Record = { high: { thinkingLevel: "high" }, }; +/** + * Tiers the backend encodes in the id but OpenCode's `ModelThinkingLevel` cannot + * express yet. Gemini 4 Hydrogen ships `-xhigh` (the official CLI exposes it as + * `--effort xhigh` and lists Low|Medium|High|XHigh), but the selector type only + * knows low|medium|high. The tier is still recognized and stripped so the + * family groups correctly and nothing is duplicated; it simply is not offered as + * a picker variant until the type grows the level. `#xhigh` still travels through + * the launch-model suffix. + */ +const UNMAPPED_TIERS = new Set(["xhigh"]); + const CLAUDE_THINKING_VARIANTS: Record = { low: { thinkingConfig: { thinkingBudget: 8192 } }, medium: { thinkingConfig: { thinkingBudget: 16384 } }, @@ -273,7 +284,7 @@ export function buildDiscoveredModelDefinition( : { ...CLAUDE_THINKING_VARIANTS }; } else if (!isGptOss) { definition.variants = observed - ? Object.fromEntries(observed.map((tier) => [tier, { thinkingLevel: tier as "low" | "medium" | "high" }])) + ? Object.fromEntries(observed.filter((tier) => !UNMAPPED_TIERS.has(tier)).map((tier) => [tier, { thinkingLevel: tier as "low" | "medium" | "high" }])) : { ...GEMINI_THINKING_VARIANTS }; }