From b62abf3b5f4a545d67d0663371fd005de2a15074 Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:06:20 -0500 Subject: [PATCH 1/2] fix(server): show Antigravity and ACP thinking levels in the effort meter --- .../provider/acp/AcpProviderModels.test.ts | 95 +++++++++++++++++++ .../src/provider/acp/AcpProviderModels.ts | 75 +++++++++++++-- .../src/provider/acp/AcpRuntimeModel.ts | 16 ++++ .../acp/AntigravityAcpSupport.test.ts | 54 ++++++++++- .../src/provider/acp/AntigravityAcpSupport.ts | 57 +++++++---- .../server/src/provider/acp/GrokAcpSupport.ts | 2 +- packages/shared/src/model.test.ts | 44 +++++++++ packages/shared/src/model.ts | 36 +++++-- 8 files changed, 345 insertions(+), 34 deletions(-) diff --git a/apps/server/src/provider/acp/AcpProviderModels.test.ts b/apps/server/src/provider/acp/AcpProviderModels.test.ts index e1a5a5c1d..6d477b095 100644 --- a/apps/server/src/provider/acp/AcpProviderModels.test.ts +++ b/apps/server/src/provider/acp/AcpProviderModels.test.ts @@ -79,6 +79,101 @@ describe("GENERIC_ACP_MODEL_OPTION_MAPPING", () => { ]), ).toEqual([{ configId: "provider", value: "codex" }]); }); + + it("maps ACP thought_level options onto reasoningEffort and sends selections back under the agent's id", () => { + const antigravityOptions = [ + { + id: "model", + name: "Model", + category: "model", + type: "select", + currentValue: "gemini-4-neon", + options: [{ value: "gemini-4-neon", name: "Gemini 4 Neon" }], + }, + { + id: "thought_level", + name: "Thinking Level", + category: "thought_level", + type: "select", + currentValue: "high", + options: [ + { value: "xhigh", name: "Extra" }, + { value: "high", name: "High" }, + { value: "medium", name: "Medium" }, + { value: "low", name: "Low" }, + ], + }, + ] satisfies ReadonlyArray; + + const capabilities = + GENERIC_ACP_MODEL_OPTION_MAPPING.capabilitiesFromConfigOptions(antigravityOptions); + const descriptor = capabilities.optionDescriptors?.[0]; + expect(descriptor).toEqual({ + id: "reasoningEffort", + label: "Thinking Level", + type: "select", + currentValue: "high", + options: [ + { id: "low", label: "Low" }, + { id: "medium", label: "Medium" }, + { id: "high", label: "High", isDefault: true }, + { id: "xhigh", label: "Extra" }, + ], + }); + expect( + GENERIC_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(antigravityOptions, [ + { id: "reasoningEffort", value: "xhigh" }, + ]), + ).toEqual([{ configId: "thought_level", value: "xhigh" }]); + // Saved selections written under the old raw id still apply. + expect( + GENERIC_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(antigravityOptions, [ + { id: "thought_level", value: "medium" }, + ]), + ).toEqual([{ configId: "thought_level", value: "medium" }]); + }); + + it("drops a single-choice thought_level option and keeps already-known reasoning ids", () => { + const singleChoice = [ + { + id: "thought_level", + name: "Thinking Level", + category: "thought_level", + type: "select", + currentValue: "high", + options: [{ value: "high", name: "High" }], + }, + ] satisfies ReadonlyArray; + expect( + GENERIC_ACP_MODEL_OPTION_MAPPING.capabilitiesFromConfigOptions(singleChoice) + .optionDescriptors, + ).toEqual([]); + + const customCommunity = [ + { + id: "thinking_budget", + name: "Thinking", + category: "thought_level", + type: "select", + currentValue: "medium", + options: [ + { value: "low", name: "Low" }, + { value: "medium", name: "Medium" }, + { value: "high", name: "High" }, + ], + }, + ] satisfies ReadonlyArray; + expect( + NATIVE_ACP_MODEL_OPTION_MAPPING.capabilitiesFromConfigOptions( + customCommunity, + ).optionDescriptors?.map((d) => d.id), + ).toEqual(["reasoningEffort"]); + expect( + NATIVE_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(customCommunity, [ + { id: "reasoningEffort", value: "high" }, + ]), + ).toEqual([{ configId: "thinking_budget", value: "high" }]); + }); }); describe("buildAcpModelsFromConfigOptions", () => { diff --git a/apps/server/src/provider/acp/AcpProviderModels.ts b/apps/server/src/provider/acp/AcpProviderModels.ts index 65f4098e3..2d5cdb78c 100644 --- a/apps/server/src/provider/acp/AcpProviderModels.ts +++ b/apps/server/src/provider/acp/AcpProviderModels.ts @@ -15,8 +15,10 @@ import type { ServerProviderModel, } from "@threadlines/contracts"; import { + CANONICAL_REASONING_OPTION_ID, createModelCapabilities, getProviderOptionSelectionValue, + isReasoningOptionId, } from "@threadlines/shared/model"; import type * as EffectAcpSchema from "effect-acp/schema"; @@ -27,7 +29,11 @@ import type { AcpProviderDescriptor, AcpProviderSettings, } from "./AcpProviderDescriptor.ts"; -import { findModelConfigOption, isModeConfigOption } from "./AcpRuntimeModel.ts"; +import { + findModelConfigOption, + findThoughtLevelConfigOption, + isModeConfigOption, +} from "./AcpRuntimeModel.ts"; export const EMPTY_ACP_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({ optionDescriptors: [], @@ -64,17 +70,54 @@ export function selectConfigOptionCurrentValue( } /** - * Mirrors every option but the model one-to-one. `modeOptions: "hidden"` - * leaves out mode-style options (driven by the runtime mode, never by the - * model picker); `"shown"` keeps them, for agents driven through their own - * controls. + * Descriptor id for an ACP `thought_level` select option. Keeps ids Threadlines + * already recognizes as reasoning (`effort`, `reasoning`, `reasoningEffort`, + * `variant`), and maps any other id (`thought_level`, `reasoning_effort`, or a + * community agent's custom id) to `reasoningEffort` so the EffortMeter and + * reasoning helpers recognize it. + */ +export function acpThoughtLevelDescriptorId( + optionId: string, + otherOptionIds?: ReadonlySet, +): string { + if (isReasoningOptionId(optionId) || otherOptionIds?.has(CANONICAL_REASONING_OPTION_ID)) { + return optionId; + } + return CANONICAL_REASONING_OPTION_ID; +} + +/** + * Mirrors every option but the model one-to-one, normalizing an ACP + * `thought_level` select onto a recognized reasoning id so the EffortMeter + * handles it. `modeOptions: "hidden"` leaves out mode-style options (driven by + * the runtime mode, never by the model picker); `"shown"` keeps them, for + * agents driven through their own controls. */ const makeAcpModelOptionMapping = (modeOptions: "hidden" | "shown"): AcpModelOptionMapping => { const isSessionControlOption = (option: EffectAcpSchema.SessionConfigOption) => modeOptions === "hidden" && isModeConfigOption(option); + const descriptorIdFor = ( + option: EffectAcpSchema.SessionConfigOption, + thoughtLevelOption: EffectAcpSchema.SessionConfigOption | undefined, + otherOptionIds: ReadonlySet, + ) => + option === thoughtLevelOption + ? acpThoughtLevelDescriptorId(option.id, otherOptionIds) + : option.id; return { capabilitiesFromConfigOptions: (configOptions) => { const modelOption = findModelConfigOption(configOptions); + const thoughtLevelOption = findThoughtLevelConfigOption(configOptions); + const otherOptionIds = new Set( + configOptions + .filter( + (candidate) => + candidate !== modelOption && + candidate !== thoughtLevelOption && + !isSessionControlOption(candidate), + ) + .map((candidate) => candidate.id), + ); const optionDescriptors: Array = []; for (const option of configOptions) { if (option === modelOption || isSessionControlOption(option)) { @@ -97,13 +140,13 @@ const makeAcpModelOptionMapping = (modeOptions: "hidden" | "shown"): AcpModelOpt continue; } const choices = flattenSessionConfigSelectOptions(option); - if (choices.length === 0) { + if (choices.length === 0 || (option === thoughtLevelOption && choices.length < 2)) { continue; } const currentValue = selectConfigOptionCurrentValue(option); optionDescriptors.push( buildSelectOptionDescriptor({ - id: option.id, + id: descriptorIdFor(option, thoughtLevelOption, otherOptionIds), label, options: choices.map((choice) => ({ value: choice.value, @@ -121,12 +164,28 @@ const makeAcpModelOptionMapping = (modeOptions: "hidden" | "shown"): AcpModelOpt return []; } const modelOption = findModelConfigOption(configOptions); + const thoughtLevelOption = findThoughtLevelConfigOption(configOptions); + const otherOptionIds = new Set( + configOptions + .filter( + (candidate) => + candidate !== modelOption && + candidate !== thoughtLevelOption && + !isSessionControlOption(candidate), + ) + .map((candidate) => candidate.id), + ); const updates: Array = []; for (const option of configOptions) { if (option === modelOption || isSessionControlOption(option)) { continue; } - const requested = getProviderOptionSelectionValue(selections, option.id); + const descriptorId = descriptorIdFor(option, thoughtLevelOption, otherOptionIds); + const requested = + getProviderOptionSelectionValue(selections, descriptorId) ?? + (descriptorId !== option.id + ? getProviderOptionSelectionValue(selections, option.id) + : undefined); if (requested === undefined) { continue; } diff --git a/apps/server/src/provider/acp/AcpRuntimeModel.ts b/apps/server/src/provider/acp/AcpRuntimeModel.ts index f491b3b2b..c02f4a5c6 100644 --- a/apps/server/src/provider/acp/AcpRuntimeModel.ts +++ b/apps/server/src/provider/acp/AcpRuntimeModel.ts @@ -173,6 +173,22 @@ export function isModeConfigOption(option: EffectAcpSchema.SessionConfigOption): return option.category === "mode" || option.id.trim().toLowerCase() === LEGACY_MODE_OPTION_ID; } +/** + * The config option that selects the agent's reasoning / thinking level, by + * ACP's standard `thought_level` category. Only select options qualify. + */ +export function findThoughtLevelConfigOption( + configOptions: ReadonlyArray | null | undefined, +): EffectAcpSchema.SessionConfigOption | undefined { + if (!configOptions) return undefined; + return configOptions.find( + (option) => + option.category === "thought_level" && + option.type === "select" && + option.id.trim().length > 0, + ); +} + /** * The older `modes` and `models` session fields as config options, each only * where the agent lists no option of its own for it. Agents driven through diff --git a/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts b/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts index b87aadf7f..bd5cf7ef7 100644 --- a/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts +++ b/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts @@ -175,12 +175,64 @@ describe("Antigravity reasoning levels", () => { "claude-sonnet-4-6", "gpt-6-1", ]); - expect(levels("gemini-4-argon")).toEqual(["thought_level", ["low", "medium", "high"]]); + expect(levels("gemini-4-argon")).toEqual(["reasoningEffort", ["low", "medium", "high"]]); expect(levels("claude-sonnet-4-6")).toBeUndefined(); // Not seen yet: the current model's levels stand in (here, none). expect(levels("gpt-6-1")).toBeUndefined(); }); + it("does not mistake a single parenthesized model name like GPT-OSS 120B (Medium) for a legacy effort-in-name catalog", async () => { + const choices = [ + { value: "gemini-4-neon", name: "Gemini 4 Neon" }, + { value: "gpt-oss-120b-medium", name: "GPT-OSS 120B (Medium)" }, + ]; + expect( + isAntigravityCatalogComplete({ + choices, + currentValue: "gemini-4-neon", + thoughtLevels: { + "gemini-4-neon": { + configId: "thought_level", + name: "Thinking Level", + currentValue: "high", + options: [ + { value: "low", name: "Low" }, + { value: "high", name: "High" }, + ], + }, + }, + }), + ).toBe(false); + + let current = "gemini-4-neon"; + const optionsFor = (slug: string): ReadonlyArray => [ + { + id: "model", + name: "Model", + category: "model", + type: "select", + currentValue: slug, + options: choices, + }, + ...(slug === "gemini-4-neon" ? [thought("high", ["low", "high"])] : []), + ]; + const probed = await Effect.runPromise( + probeAntigravityModelOptions({ + getConfigOptions: Effect.sync(() => optionsFor(current)), + setConfigOption: (_configId, value) => + Effect.sync(() => { + current = String(value); + return { configOptions: [...optionsFor(current)] }; + }), + }), + ); + expect(probed?.thoughtLevels["gemini-4-neon"]?.options.map((o) => o.value)).toEqual([ + "low", + "high", + ]); + expect(probed?.thoughtLevels["gpt-oss-120b-medium"]).toBeNull(); + }); + it("falls back to folding names when the agent names the level in the model", () => { const next = nextAntigravityCatalog(undefined, configOptions); expect(next?.thoughtLevels).toBeUndefined(); diff --git a/apps/server/src/provider/acp/AntigravityAcpSupport.ts b/apps/server/src/provider/acp/AntigravityAcpSupport.ts index 2b4929976..d49140020 100644 --- a/apps/server/src/provider/acp/AntigravityAcpSupport.ts +++ b/apps/server/src/provider/acp/AntigravityAcpSupport.ts @@ -122,10 +122,16 @@ import type { AcpProviderProbeOutcome, } from "./AcpProviderDescriptor.ts"; import { + acpThoughtLevelDescriptorId, flattenSessionConfigSelectOptions, + hasAcpModelCapabilities, selectConfigOptionCurrentValue, } from "./AcpProviderModels.ts"; -import { type AcpToolCallState, findModelConfigOption } from "./AcpRuntimeModel.ts"; +import { + type AcpToolCallState, + findModelConfigOption, + findThoughtLevelConfigOption, +} from "./AcpRuntimeModel.ts"; import type { AcpSessionRuntimeShape } from "./AcpSessionRuntime.ts"; import { ProviderSetupError } from "../Errors.ts"; @@ -339,13 +345,23 @@ export function antigravityModelsFromChoices( const modelChoices = (configOptions: ReadonlyArray) => flattenSessionConfigSelectOptions(findModelConfigOption(configOptions)); +/** + * Whether a model list has at least one family split into multiple + * effort-suffixed entries ("Gemini 3.8 Flash (High)" and "(Low)"). A modern + * catalog with a single unrelated entry like "GPT-OSS 120B (Medium)" is not + * a legacy effort-in-name catalog. + */ +function hasFoldableAntigravityModels(choices: ReadonlyArray): boolean { + return foldAntigravityModels(choices).some( + (family) => family.variants.filter((variant) => variant.effort !== "").length >= 2, + ); +} + /** The session's `thought_level` option: the selected model's reasoning levels. */ export function antigravityThoughtLevels( configOptions: ReadonlyArray, ): AntigravityThoughtLevels | undefined { - const option = configOptions.find( - (candidate) => candidate.category === "thought_level" && candidate.type === "select", - ); + const option = findThoughtLevelConfigOption(configOptions); const options = flattenSessionConfigSelectOptions(option); if (!option || options.length === 0) return undefined; const currentValue = selectConfigOptionCurrentValue(option); @@ -364,8 +380,9 @@ function thoughtLevelCapabilities(levels: AntigravityThoughtLevels | null): Mode return createModelCapabilities({ optionDescriptors: [ { - // The session option's own id: the generic mapping sends a selection back to it. - id: levels.configId, + // Canonical reasoning id so EffortMeter and reasoning helpers recognize it; + // GENERIC_ACP_MODEL_OPTION_MAPPING maps selections back onto `levels.configId`. + id: acpThoughtLevelDescriptorId(levels.configId), label: levels.name, type: "select", options: levels.options.map((option) => @@ -440,9 +457,10 @@ export function nextAntigravityCatalog( */ export function isAntigravityCatalogComplete(catalog: AntigravityCatalogCache): boolean { if (catalog.probed === true) return true; - if (catalog.choices.some((choice) => EFFORT_NAME.test(choice.name.trim()))) return true; const levels = catalog.thoughtLevels; - if (!levels) return false; + if (!levels || Object.keys(levels).length === 0) { + return hasFoldableAntigravityModels(catalog.choices); + } return catalog.choices.every((choice) => choice.value in levels); } @@ -460,7 +478,12 @@ export const probeAntigravityModelOptions = ( const modelOption = findModelConfigOption(initialOptions); const choices = flattenSessionConfigSelectOptions(modelOption); if (!modelOption || choices.length === 0) return undefined; - if (choices.some((choice) => EFFORT_NAME.test(choice.name.trim()))) return undefined; + if ( + antigravityThoughtLevels(initialOptions) === undefined && + hasFoldableAntigravityModels(choices) + ) { + return undefined; + } const currentValue = selectConfigOptionCurrentValue(modelOption); const modelOptions: Array = []; @@ -1370,15 +1393,15 @@ export function makeAntigravityDescriptor( return probed.modelOptions; }), // Older agents name the level in the model: fold those. Newer agents are - // probed once per catalog in `listModelOptions` and read from disk thereafter. - enrichDiscoveredModels: (models) => - Effect.succeed( - models.some((model) => EFFORT_NAME.test(model.name.trim())) - ? antigravityModelsFromChoices( - models.map((model) => ({ value: model.slug, name: model.name })), - ) + // probed once per catalog in `discoverModelOptions` and read from disk thereafter. + enrichDiscoveredModels: (models) => { + const choices = models.map((model) => ({ value: model.slug, name: model.name })); + return Effect.succeed( + !models.some(hasAcpModelCapabilities) && hasFoldableAntigravityModels(choices) + ? antigravityModelsFromChoices(choices) : models, - ), + ); + }, modelCapabilitiesVaryByModel: false, resolveModelId: resolveAntigravityModelId, }; diff --git a/apps/server/src/provider/acp/GrokAcpSupport.ts b/apps/server/src/provider/acp/GrokAcpSupport.ts index efb8533d7..190f47fef 100644 --- a/apps/server/src/provider/acp/GrokAcpSupport.ts +++ b/apps/server/src/provider/acp/GrokAcpSupport.ts @@ -190,7 +190,7 @@ export const GROK_MODEL_OPTION_MAPPING: AcpModelOptionMapping = { return { ...capabilities, optionDescriptors: (capabilities.optionDescriptors ?? []).map((descriptor) => - descriptor.id === GROK_EFFORT_CONFIG_ID + descriptor.id === GROK_EFFORT_CONFIG_ID || descriptor.id === REASONING_OPTION_ID ? { ...descriptor, id: REASONING_OPTION_ID, label: "Reasoning" } : descriptor, ), diff --git a/packages/shared/src/model.test.ts b/packages/shared/src/model.test.ts index 5f53c5cb8..a4450ffed 100644 --- a/packages/shared/src/model.test.ts +++ b/packages/shared/src/model.test.ts @@ -316,6 +316,50 @@ describe("descriptor helpers", () => { ).toEqual([{ id: "effort", value: "ultracode" }]); }); + it("reads legacy thought_level selections onto a reasoningEffort descriptor", () => { + const descriptors = getProviderOptionDescriptors({ + caps: codexCaps, + selections: [{ id: "thought_level", value: "xhigh" }], + }); + + expect(descriptors[0]?.currentValue).toBe("xhigh"); + expect(buildProviderOptionSelectionsFromDescriptors(descriptors)).toEqual([ + { id: "reasoningEffort", value: "xhigh" }, + ]); + + // An explicit reasoningEffort selection wins over a stale thought_level one. + const overridden = getProviderOptionDescriptors({ + caps: codexCaps, + selections: [ + { id: "thought_level", value: "xhigh" }, + { id: "reasoningEffort", value: "high" }, + ], + }); + expect(overridden[0]?.currentValue).toBe("high"); + }); + + it("orders ultra above max in ascending reasoning levels", () => { + const caps = createModelCapabilities({ + optionDescriptors: [ + { + id: "reasoningEffort", + label: "Reasoning", + type: "select", + options: [ + { id: "ultra", label: "Ultra" }, + { id: "low", label: "Low" }, + { id: "max", label: "Max" }, + ], + currentValue: "max", + }, + ], + }); + const descriptor = caps.optionDescriptors?.[0]; + expect( + descriptor?.type === "select" ? descriptor.options.map((option) => option.id) : [], + ).toEqual(["low", "max", "ultra"]); + }); + it("builds wire-format option selections from descriptors", () => { const descriptors = getProviderOptionDescriptors({ caps: codexCaps, diff --git a/packages/shared/src/model.ts b/packages/shared/src/model.ts index 43fa085fe..2fd4297d9 100644 --- a/packages/shared/src/model.ts +++ b/packages/shared/src/model.ts @@ -64,6 +64,7 @@ const REASONING_LEVEL_RANK: ReadonlyMap = new Map([ ["xhigh", 5], ["extrahigh", 5], ["max", 6], + ["ultra", 7], ]); const reasoningLevelRank = (id: string) => @@ -294,6 +295,14 @@ function migratePromotedSelectChoices( return next; } +/** + * Older option ids that were later mapped onto a canonical descriptor id. + * Persisted thread and draft selections keep working until rewritten. + */ +const LEGACY_OPTION_ID_ALIASES: Readonly>> = { + reasoningEffort: ["thought_level"], +}; + export function getProviderOptionDescriptors(input: { caps: ModelCapabilities; selections?: ReadonlyArray | null | undefined; @@ -302,12 +311,17 @@ export function getProviderOptionDescriptors(input: { const selections = migratePromotedSelectChoices(caps, input.selections); const baseDescriptors = (caps.optionDescriptors ?? []).map(cloneDescriptor); - return baseDescriptors.map((descriptor) => - withDescriptorCurrentValue( - descriptor, - getRawSelectionValueById(selections, descriptor.id) ?? descriptor.currentValue, - ), - ); + return baseDescriptors.map((descriptor) => { + const direct = getRawSelectionValueById(selections, descriptor.id); + const aliased = + direct === undefined + ? (LEGACY_OPTION_ID_ALIASES[descriptor.id] ?? []) + .filter((alias) => !baseDescriptors.some((candidate) => candidate.id === alias)) + .map((alias) => getRawSelectionValueById(selections, alias)) + .find((value) => value !== undefined) + : undefined; + return withDescriptorCurrentValue(descriptor, direct ?? aliased ?? descriptor.currentValue); + }); } export function getProviderOptionCurrentValue( @@ -345,14 +359,22 @@ export function getProviderOptionCurrentLabel( return descriptor.options.find((option) => option.id === currentValue)?.label; } +/** Canonical option id for reasoning effort when normalizing provider options. */ +export const CANONICAL_REASONING_OPTION_ID = "reasoningEffort"; + /** The option each provider keeps its reasoning level in. */ const REASONING_OPTION_IDS: ReadonlySet = new Set([ - "reasoningEffort", + CANONICAL_REASONING_OPTION_ID, "effort", "reasoning", "variant", ]); +/** Whether an option id is one of Threadlines' recognized reasoning level controls. */ +export function isReasoningOptionId(id: string): boolean { + return REASONING_OPTION_IDS.has(id); +} + /** * A model's reasoning setting among its options: Codex calls it * `reasoningEffort`, Claude `effort`, OpenCode `variant`. Undefined for a model From 42697d521c072b21d41c26157112d707f84e7268 Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Mon, 23 Nov 2026 19:14:31 -0500 Subject: [PATCH 2/2] fix(server): keep thought_level id aligned with main's reasoning option list --- .../provider/acp/AcpProviderModels.test.ts | 38 +++++++++++++---- .../src/provider/acp/AcpProviderModels.ts | 2 +- .../acp/AntigravityAcpSupport.test.ts | 2 +- packages/shared/src/model.test.ts | 37 ++++++++-------- packages/shared/src/model.ts | 42 +++++++------------ 5 files changed, 67 insertions(+), 54 deletions(-) diff --git a/apps/server/src/provider/acp/AcpProviderModels.test.ts b/apps/server/src/provider/acp/AcpProviderModels.test.ts index 6d477b095..466e8b68e 100644 --- a/apps/server/src/provider/acp/AcpProviderModels.test.ts +++ b/apps/server/src/provider/acp/AcpProviderModels.test.ts @@ -80,7 +80,7 @@ describe("GENERIC_ACP_MODEL_OPTION_MAPPING", () => { ).toEqual([{ configId: "provider", value: "codex" }]); }); - it("maps ACP thought_level options onto reasoningEffort and sends selections back under the agent's id", () => { + it("keeps recognized thought_level ids and normalizes custom ACP thought_level ids onto reasoningEffort", () => { const antigravityOptions = [ { id: "model", @@ -109,7 +109,7 @@ describe("GENERIC_ACP_MODEL_OPTION_MAPPING", () => { GENERIC_ACP_MODEL_OPTION_MAPPING.capabilitiesFromConfigOptions(antigravityOptions); const descriptor = capabilities.optionDescriptors?.[0]; expect(descriptor).toEqual({ - id: "reasoningEffort", + id: "thought_level", label: "Thinking Level", type: "select", currentValue: "high", @@ -122,15 +122,39 @@ describe("GENERIC_ACP_MODEL_OPTION_MAPPING", () => { }); expect( GENERIC_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(antigravityOptions, [ - { id: "reasoningEffort", value: "xhigh" }, + { id: "thought_level", value: "xhigh" }, ]), ).toEqual([{ configId: "thought_level", value: "xhigh" }]); - // Saved selections written under the old raw id still apply. + + const vendorEffortOptions = [ + { + id: "reasoning_effort", + name: "Reasoning Effort", + category: "thought_level", + type: "select", + currentValue: "high", + options: [ + { value: "high", name: "High" }, + { value: "low", name: "Low" }, + ], + }, + ] satisfies ReadonlyArray; expect( - GENERIC_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(antigravityOptions, [ - { id: "thought_level", value: "medium" }, + GENERIC_ACP_MODEL_OPTION_MAPPING.capabilitiesFromConfigOptions( + vendorEffortOptions, + ).optionDescriptors?.map((entry) => entry.id), + ).toEqual(["reasoningEffort"]); + expect( + GENERIC_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(vendorEffortOptions, [ + { id: "reasoningEffort", value: "low" }, + ]), + ).toEqual([{ configId: "reasoning_effort", value: "low" }]); + // Saved selections written under the raw vendor id still apply. + expect( + GENERIC_ACP_MODEL_OPTION_MAPPING.configUpdatesFromSelections(vendorEffortOptions, [ + { id: "reasoning_effort", value: "high" }, ]), - ).toEqual([{ configId: "thought_level", value: "medium" }]); + ).toEqual([{ configId: "reasoning_effort", value: "high" }]); }); it("drops a single-choice thought_level option and keeps already-known reasoning ids", () => { diff --git a/apps/server/src/provider/acp/AcpProviderModels.ts b/apps/server/src/provider/acp/AcpProviderModels.ts index 2d5cdb78c..37f4871fd 100644 --- a/apps/server/src/provider/acp/AcpProviderModels.ts +++ b/apps/server/src/provider/acp/AcpProviderModels.ts @@ -72,7 +72,7 @@ export function selectConfigOptionCurrentValue( /** * Descriptor id for an ACP `thought_level` select option. Keeps ids Threadlines * already recognizes as reasoning (`effort`, `reasoning`, `reasoningEffort`, - * `variant`), and maps any other id (`thought_level`, `reasoning_effort`, or a + * `variant`, `thought_level`), and maps any other id (`reasoning_effort` or a * community agent's custom id) to `reasoningEffort` so the EffortMeter and * reasoning helpers recognize it. */ diff --git a/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts b/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts index bd5cf7ef7..8502bd486 100644 --- a/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts +++ b/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts @@ -175,7 +175,7 @@ describe("Antigravity reasoning levels", () => { "claude-sonnet-4-6", "gpt-6-1", ]); - expect(levels("gemini-4-argon")).toEqual(["reasoningEffort", ["low", "medium", "high"]]); + expect(levels("gemini-4-argon")).toEqual(["thought_level", ["low", "medium", "high"]]); expect(levels("claude-sonnet-4-6")).toBeUndefined(); // Not seen yet: the current model's levels stand in (here, none). expect(levels("gpt-6-1")).toBeUndefined(); diff --git a/packages/shared/src/model.test.ts b/packages/shared/src/model.test.ts index a4450ffed..41d0b33bb 100644 --- a/packages/shared/src/model.test.ts +++ b/packages/shared/src/model.test.ts @@ -316,26 +316,27 @@ describe("descriptor helpers", () => { ).toEqual([{ id: "effort", value: "ultracode" }]); }); - it("reads legacy thought_level selections onto a reasoningEffort descriptor", () => { - const descriptors = getProviderOptionDescriptors({ - caps: codexCaps, - selections: [{ id: "thought_level", value: "xhigh" }], - }); - - expect(descriptors[0]?.currentValue).toBe("xhigh"); - expect(buildProviderOptionSelectionsFromDescriptors(descriptors)).toEqual([ - { id: "reasoningEffort", value: "xhigh" }, - ]); - - // An explicit reasoningEffort selection wins over a stale thought_level one. - const overridden = getProviderOptionDescriptors({ - caps: codexCaps, - selections: [ - { id: "thought_level", value: "xhigh" }, - { id: "reasoningEffort", value: "high" }, + it("recognizes thought_level as a reasoning option", () => { + const antigravityCaps = createModelCapabilities({ + optionDescriptors: [ + { + id: "thought_level", + label: "Thinking Level", + type: "select", + options: [ + { id: "high", label: "High", isDefault: true }, + { id: "low", label: "Low" }, + ], + currentValue: "high", + }, ], }); - expect(overridden[0]?.currentValue).toBe("high"); + expect(findReasoningOptionDescriptor(antigravityCaps.optionDescriptors ?? [])?.id).toBe( + "thought_level", + ); + expect(offersSelectedReasoning(antigravityCaps, [{ id: "thought_level", value: "low" }])).toBe( + true, + ); }); it("orders ultra above max in ascending reasoning levels", () => { diff --git a/packages/shared/src/model.ts b/packages/shared/src/model.ts index 2fd4297d9..13f4933a2 100644 --- a/packages/shared/src/model.ts +++ b/packages/shared/src/model.ts @@ -295,14 +295,6 @@ function migratePromotedSelectChoices( return next; } -/** - * Older option ids that were later mapped onto a canonical descriptor id. - * Persisted thread and draft selections keep working until rewritten. - */ -const LEGACY_OPTION_ID_ALIASES: Readonly>> = { - reasoningEffort: ["thought_level"], -}; - export function getProviderOptionDescriptors(input: { caps: ModelCapabilities; selections?: ReadonlyArray | null | undefined; @@ -311,17 +303,12 @@ export function getProviderOptionDescriptors(input: { const selections = migratePromotedSelectChoices(caps, input.selections); const baseDescriptors = (caps.optionDescriptors ?? []).map(cloneDescriptor); - return baseDescriptors.map((descriptor) => { - const direct = getRawSelectionValueById(selections, descriptor.id); - const aliased = - direct === undefined - ? (LEGACY_OPTION_ID_ALIASES[descriptor.id] ?? []) - .filter((alias) => !baseDescriptors.some((candidate) => candidate.id === alias)) - .map((alias) => getRawSelectionValueById(selections, alias)) - .find((value) => value !== undefined) - : undefined; - return withDescriptorCurrentValue(descriptor, direct ?? aliased ?? descriptor.currentValue); - }); + return baseDescriptors.map((descriptor) => + withDescriptorCurrentValue( + descriptor, + getRawSelectionValueById(selections, descriptor.id) ?? descriptor.currentValue, + ), + ); } export function getProviderOptionCurrentValue( @@ -364,21 +351,17 @@ export const CANONICAL_REASONING_OPTION_ID = "reasoningEffort"; /** The option each provider keeps its reasoning level in. */ const REASONING_OPTION_IDS: ReadonlySet = new Set([ - CANONICAL_REASONING_OPTION_ID, + "reasoningEffort", "effort", "reasoning", "variant", + "thought_level", ]); -/** Whether an option id is one of Threadlines' recognized reasoning level controls. */ -export function isReasoningOptionId(id: string): boolean { - return REASONING_OPTION_IDS.has(id); -} - /** * A model's reasoning setting among its options: Codex calls it - * `reasoningEffort`, Claude `effort`, OpenCode `variant`. Undefined for a model - * without one. + * `reasoningEffort`, Claude `effort`, OpenCode `variant`, Antigravity + * `thought_level`. Undefined for a model without one. */ export function findReasoningOptionDescriptor( descriptors: ReadonlyArray, @@ -389,6 +372,11 @@ export function findReasoningOptionDescriptor( ); } +/** Whether an option id is one of Threadlines' recognized reasoning level controls. */ +export function isReasoningOptionId(id: string): boolean { + return REASONING_OPTION_IDS.has(id); +} + /** The reasoning level among a selection's options; undefined when its provider picks. */ export function findReasoningSelection( selections: ReadonlyArray | null | undefined,