Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: pick an Antigravity base model and its reasoning effort separately (#3480)
[._.]/ Adam Eivy7166c28c27a1
diff --git a/client/src/components/ProviderModelSelector.jsx b/client/src/components/ProviderModelSelector.jsxindex 9955686795..4e717a6bd9 100644--- a/client/src/components/ProviderModelSelector.jsx+++ b/client/src/components/ProviderModelSelector.jsx@@ -30,6 +30,12 @@* @param {'row'|'stacked'} [props.layout] - 'row' (default) lays the two selects* side by side; 'stacked' places the model select under the provider select for* narrow columns.+ * @param {string} [props.effort] - Current reasoning-effort override (`''` = the+ * provider's default). Pass with `onEffortChange` to get a third select for+ * effort-capable providers (Antigravity, Claude, Codex); it renders itself+ * away for every other provider, so no caller-side guard is needed. Omit both+ * props for the two-select picker.+ * @param {function} [props.onEffortChange] - Called with the new effort string.* @param {boolean} [props.highlightToolUse] - Opt-in for AGENT / CoS-task pickers:* marks each LOCAL (Ollama / LM Studio) model option with a tool-use indicator* and warns below the select when the chosen local model can't call tools (it@@ -38,7 +44,8 @@* providers, whose ids don't encode their family.*/import { useId } from 'react';-import { localToolUseHint, withToolUseOptionLabel } from '../utils/providers.js';+import { effortLevelsForProvider, localToolUseHint, withToolUseOptionLabel } from '../utils/providers.js';+import EffortSelect from './cos/EffortSelect.jsx';const SELECT_CLASS ='w-full px-3 py-1.5 min-h-[36px] bg-port-bg border border-port-border rounded-lg text-white text-sm';@@ -67,10 +74,13 @@ export default function ProviderModelSelector({emptyModelOption,alwaysShowModel = false,layout = 'row',- highlightToolUse = false+ highlightToolUse = false,+ effort,+ onEffortChange}) {const providerSelectId = useId();const modelSelectId = useId();+ const effortSelectId = useId();// Agent-picker tool-use highlight (opt-in). Resolve the selected provider so// the annotation only fires for local backends (the heuristic mislabels cloud// ids). `localToolUseHint` returns null for cloud/blank, so the warning stays@@ -92,6 +102,10 @@ export default function ProviderModelSelector({(p) => p.enabled !== false || p.id === selectedProviderId);const showModel = alwaysShowModel || availableModels.length > 0;+ // The effort select is opt-in (`onEffortChange`) AND self-hiding: EffortSelect+ // renders null for a provider with no effort control, so gate the label+wrapper+ // on the same predicate or a non-effort provider gets an orphaned label.+ const showEffort = !!onEffortChange && !!effortLevelsForProvider(selectedProvider, effectiveModel);const wrapperClass = layout === 'stacked' ? 'flex flex-col gap-1' : 'flex items-center gap-2';return (<div className={wrapperClass}>@@ -144,6 +158,24 @@ export default function ProviderModelSelector({)}</div>)}+ {showEffort && (+ <div className="flex-1 min-w-0">+ {!compact && (+ <label htmlFor={effortSelectId} className="block text-xs text-gray-500 mb-1">+ Thinking effort+ </label>+ )}+ <EffortSelect+ id={effortSelectId}+ provider={selectedProvider}+ model={effectiveModel}+ value={effort || ''}+ onChange={onEffortChange}+ disabled={disabled}+ className={SELECT_CLASS}+ />+ </div>+ )}</div>);}diff --git a/client/src/components/ProviderModelSelector.test.jsx b/client/src/components/ProviderModelSelector.test.jsxindex 0307e5ae2b..9435610043 100644--- a/client/src/components/ProviderModelSelector.test.jsx+++ b/client/src/components/ProviderModelSelector.test.jsx@@ -194,4 +194,68 @@ describe('ProviderModelSelector', () => {expect(screen.queryByText(/recognized tool-calling model/i)).not.toBeInTheDocument();});});++ describe('effort select', () => {+ const AGY = [{+ id: 'antigravity-cli',+ name: 'Antigravity',+ command: 'agy',+ models: ['gemini-3.6-flash-high', 'gemini-3.6-flash-medium', 'gemini-3.6-flash-low', 'gemini-3.1-pro-high', 'gemini-3.1-pro-low', 'claude-sonnet-4-6'],+ }];++ const renderEffort = (props = {}) => renderSelector({+ providers: AGY,+ selectedProviderId: 'antigravity-cli',+ selectedModel: 'gemini-3.6-flash',+ availableModels: ['gemini-3.6-flash', 'gemini-3.1-pro', 'claude-sonnet-4-6'],+ effort: '',+ onEffortChange: () => {},+ ...props,+ });++ it('is absent unless onEffortChange is supplied', () => {+ renderEffort({ effort: undefined, onEffortChange: undefined });+ expect(screen.getAllByRole('combobox')).toHaveLength(2);+ expect(screen.queryByLabelText('Thinking effort')).not.toBeInTheDocument();+ });++ it('renders a labeled effort select for an effort-capable provider', () => {+ renderEffort();+ const effortSelect = screen.getByLabelText('Thinking effort');+ const options = [...effortSelect.querySelectorAll('option')].map((o) => o.value);+ expect(options).toEqual(['', 'low', 'medium', 'high']);+ });++ it('narrows the options to the tiers the selected Antigravity model offers', () => {+ // agy rejects `--model gemini-3.1-pro --effort medium`.+ renderEffort({ selectedModel: 'gemini-3.1-pro' });+ const options = [...screen.getByLabelText('Thinking effort').querySelectorAll('option')].map((o) => o.value);+ expect(options).toEqual(['', 'low', 'high']);+ });++ it('hides itself (label and all) for an Antigravity model with no tiers', () => {+ renderEffort({ selectedModel: 'claude-sonnet-4-6' });+ expect(screen.queryByLabelText('Thinking effort')).not.toBeInTheDocument();+ expect(screen.queryByText('Thinking effort')).not.toBeInTheDocument();+ });++ it('hides itself for a provider with no effort control', () => {+ renderSelector({+ providers: [{ id: 'ollama', name: 'Ollama', endpoint: 'http://localhost:11434' }],+ selectedProviderId: 'ollama',+ selectedModel: 'qwen3',+ availableModels: ['qwen3'],+ effort: '',+ onEffortChange: () => {},+ });+ expect(screen.queryByLabelText('Thinking effort')).not.toBeInTheDocument();+ });++ it('reports the picked level to onEffortChange', () => {+ const onEffortChange = vi.fn();+ renderEffort({ onEffortChange });+ fireEvent.change(screen.getByLabelText('Thinking effort'), { target: { value: 'high' } });+ expect(onEffortChange).toHaveBeenCalledWith('high');+ });+ });});diff --git a/client/src/components/cos/EffortSelect.jsx b/client/src/components/cos/EffortSelect.jsxindex 65731bb05c..1765ec0c68 100644--- a/client/src/components/cos/EffortSelect.jsx+++ b/client/src/components/cos/EffortSelect.jsx@@ -15,8 +15,15 @@ import { FormField } from '../ui/FormField';** @param {object} props* @param {object} [props.provider] - The selected provider record (not its id).+ * @param {string} [props.model] - The selected model. Antigravity's tiers are+ * per-model (agy rejects `gemini-3.1-pro --effort medium`), so passing this+ * narrows the options to the ones that model actually offers — and hides the+ * select entirely for an Antigravity model with no tiers at all. Omit for the+ * provider-wide ladder.* @param {string} props.value - Current effort ('' = provider default).* @param {function} props.onChange - Called with the new effort string.+ * @param {string} [props.id] - Id for the <select>, when the caller owns the+ * `<label htmlFor>`. Defaults to a generated one (used by the FormField mode).* @param {string} [props.label] - Field label; enables the FormField wrapper.* @param {import('react').ReactNode} [props.hint] - Help text under the select (needs `label`).* @param {string} [props.className] - Classes for the <select>.@@ -26,8 +33,10 @@ import { FormField } from '../ui/FormField';*/export default function EffortSelect({provider,+ model = null,value,onChange,+ id: idProp,label,hint,className = '',@@ -35,8 +44,9 @@ export default function EffortSelect({labelClassName,disabled = false}) {- const id = useId();- const levels = effortLevelsForProvider(provider);+ const generatedId = useId();+ const id = idProp || generatedId;+ const levels = effortLevelsForProvider(provider, model);if (!levels) return null;// A stored effort can sit outside this provider's ladder — a task/stage@@ -48,7 +58,7 @@ export default function EffortSelect({// the run uses the clamped level. Mirrors the stale-model option the pipeline// stage's Model select already renders.const outOfLadder = value && !levels.includes(value) ? value : null;- const clamped = outOfLadder ? resolveCliEffort(outOfLadder, provider) : null;+ const clamped = outOfLadder ? resolveCliEffort(outOfLadder, provider, model) : null;const select = (<selectdiff --git a/client/src/hooks/useProviderModels.js b/client/src/hooks/useProviderModels.jsindex 4a73203609..1db909fe40 100644--- a/client/src/hooks/useProviderModels.js+++ b/client/src/hooks/useProviderModels.js@@ -1,12 +1,16 @@import { useState, useEffect, useCallback, useMemo, useRef } from 'react';import * as api from '../services/api';-import { filterSelectableModels } from '../utils/providers';+import { filterSelectableModels, isAntigravityProvider, selectableModelsForProvider, splitAntigravityModel } from '../utils/providers';// The provider's selectable model source: its `models` list, or — when that// list is empty (a cloud/manual provider configured with only a defaultModel,// where `[]` is truthy so `||` wouldn't fall through) — its defaultModel.-const sourceModels = (provider) => (- provider?.models?.length ? provider.models : [provider?.defaultModel]+// `selectableModelsForProvider` then applies any provider-specific rewrite —+// today that means Antigravity lists BASE models (`gemini-3.6-flash`) rather+// than one row per baked-in effort tier, since effort is its own control now.+const sourceModels = (provider) => selectableModelsForProvider(+ provider,+ provider?.models?.length ? provider.models : [provider?.defaultModel],);/**@@ -85,9 +89,24 @@ export default function useProviderModels({ filter, allowDefault = false, silent// `[]` is truthy, so a bare `||` would leave the dropdown empty for a// cloud/manual provider configured with only a defaultModel).const models = filterSelectableModels(sourceModels(currentProvider));- return modelFilter ? models.filter((m) => modelFilter(m, currentProvider)) : models;+ const filtered = modelFilter ? models.filter((m) => modelFilter(m, currentProvider)) : models;+ // Legacy-pin escape hatch: a record saved before Antigravity switched to+ // base models still holds `gemini-3.6-flash-high`, which now matches no+ // option and would render the select BLANK (reading as "no model"). Keep+ // the stored id as its own option so the pin stays visible — the server+ // splits it back into base + `--effort`, so it still runs. Same posture as+ // EffortSelect's out-of-ladder option.+ //+ // Deliberately narrow: only an Antigravity id that carries an effort+ // SUFFIX qualifies. A bare "not in the list" test would also re-surface+ // the configured-default sentinel (the shipped agy `defaultModel`, which+ // filterSelectableModels exists to hide) and any typo'd/stale pin.+ const staleAntigravityPin = isAntigravityProvider(currentProvider)+ && !!splitAntigravityModel(selectedModel).effort+ && !filtered.includes(selectedModel);+ return staleAntigravityPin ? [...filtered, selectedModel] : filtered;},- [currentProvider, modelFilter]+ [currentProvider, modelFilter, selectedModel]);const handleProviderChange = useCallback((id) => {diff --git a/client/src/hooks/useProviderModels.test.js b/client/src/hooks/useProviderModels.test.jsnew file mode 100644index 0000000000..38e7d8e5d4--- /dev/null+++ b/client/src/hooks/useProviderModels.test.js@@ -0,0 +1,79 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { act, renderHook, waitFor } from '@testing-library/react';++vi.mock('../services/api', () => ({ getProviders: vi.fn() }));++import * as api from '../services/api';+import useProviderModels from './useProviderModels';++// The catalog `agy models` prints — the shipped provider list mirrors it, and+// its defaultModel is the "use the CLI's own model" sentinel.+const AGY = {+ id: 'antigravity-cli',+ name: 'Antigravity CLI',+ type: 'cli',+ command: 'agy',+ enabled: true,+ defaultModel: 'antigravity-configured-default',+ models: [+ 'antigravity-configured-default',+ 'gemini-3.6-flash-high', 'gemini-3.6-flash-medium', 'gemini-3.6-flash-low',+ 'gemini-3.1-pro-high', 'gemini-3.1-pro-low',+ 'claude-sonnet-4-6', 'gpt-oss-120b-medium',+ ],+};++const CODEX = {+ id: 'codex',+ name: 'Codex',+ type: 'cli',+ command: 'codex',+ enabled: true,+ defaultModel: 'gpt-5',+ models: ['gpt-5', 'gpt-5-high'],+};++const mountWith = async (providers) => {+ api.getProviders.mockResolvedValue({ providers });+ const hook = renderHook(() => useProviderModels());+ await waitFor(() => expect(hook.result.current.loading).toBe(false));+ return hook;+};++describe('useProviderModels — Antigravity base models', () => {+ beforeEach(() => vi.clearAllMocks());++ it('collapses the effort-suffixed catalog into base models', async () => {+ const { result } = await mountWith([AGY]);+ expect(result.current.availableModels).toEqual([+ 'gemini-3.6-flash',+ 'gemini-3.1-pro',+ 'claude-sonnet-4-6',+ 'gpt-oss-120b',+ ]);+ });++ it('does not re-surface the configured-default sentinel as the auto-selected pin', async () => {+ const { result } = await mountWith([AGY]);+ // The sentinel is the provider's defaultModel, so it IS the selected value —+ // but filterSelectableModels exists to keep it out of the options.+ expect(result.current.selectedModel).toBe('antigravity-configured-default');+ expect(result.current.availableModels).not.toContain('antigravity-configured-default');+ });++ it('keeps a legacy effort-suffixed pin visible instead of blanking the select', async () => {+ const { result } = await mountWith([AGY]);+ act(() => result.current.setSelectedModel('gemini-3.6-flash-high'));+ await waitFor(() => {+ expect(result.current.availableModels).toContain('gemini-3.6-flash-high');+ });+ // The base list is still there — the stale pin is appended, not substituted.+ expect(result.current.availableModels).toContain('gemini-3.6-flash');+ });++ it('leaves other providers\' model lists untouched', async () => {+ const { result } = await mountWith([CODEX]);+ // `gpt-5-high` is NOT an Antigravity id, so its `-high` is not a tier suffix.+ expect(result.current.availableModels).toEqual(['gpt-5', 'gpt-5-high']);+ });+});diff --git a/client/src/pages/ThreejsModelDetail.jsx b/client/src/pages/ThreejsModelDetail.jsxindex 668f83158a..4f02f12c53 100644--- a/client/src/pages/ThreejsModelDetail.jsx+++ b/client/src/pages/ThreejsModelDetail.jsx@@ -17,6 +17,7 @@ import {import toast from '../components/ui/Toast';import { copyToClipboard } from '../lib/clipboard';import { timeAgo } from '../utils/formatters';+import { isAntigravityProvider, splitAntigravityModel } from '../utils/providers';const providerFilter = (provider) =>provider.enabled !== false && ['api', 'cli', 'tui'].includes(provider.type);@@ -29,6 +30,7 @@ export default function ThreejsModelDetail() {const [notFound, setNotFound] = useState(false);const [feedback, setFeedback] = useState('');const [starting, setStarting] = useState(false);+ const [effort, setEffort] = useState('');const [confirmingDelete, setConfirmingDelete] = useState(false);const providerSyncRef = useRef('');const {@@ -76,11 +78,21 @@ export default function ThreejsModelDetail() {useEffect(() => {if (!record || providers.length === 0) return;- const key = `${record.id}:${record.providerId}:${record.model || ''}`;+ const key = `${record.id}:${record.providerId}:${record.model || ''}:${record.effort || ''}`;if (providerSyncRef.current === key) return;- if (providers.some((provider) => provider.id === record.providerId)) {+ const recordProvider = providers.find((provider) => provider.id === record.providerId);+ if (recordProvider) {+ // A record written before Antigravity split model from effort stores the+ // suffixed id (`gemini-3.6-flash-high`). Seed the two controls from its+ // two halves so the pin reads back as a base model + its effort rather+ // than an option that no longer exists. Scoped to Antigravity so another+ // provider's model that merely ends in `-high` isn't truncated.+ const { base, effort: bakedEffort } = isAntigravityProvider(recordProvider)+ ? splitAntigravityModel(record.model || '')+ : { base: record.model || '', effort: null };setSelectedProviderId(record.providerId);- setSelectedModel(record.model || '');+ setSelectedModel(base || '');+ setEffort(record.effort || bakedEffort || '');}providerSyncRef.current = key;}, [record, providers, setSelectedProviderId, setSelectedModel]);@@ -91,6 +103,9 @@ export default function ThreejsModelDetail() {const next = await generateThreejsModel(id, {providerId: selectedProviderId,model: selectedModel || undefined,+ // Always sent (as `''` when unset) so picking "Default effort" CLEARS the+ // record's stored override instead of silently re-applying it.+ effort,prompt: record.prompt || '',feedback: feedback.trim(),}, { silent: true }).catch((error) => {@@ -159,7 +174,7 @@ export default function ThreejsModelDetail() {</span></div><p className="mt-1 text-xs text-gray-500">- {record.providerId}{record.model ? ` · ${record.model}` : ''} · updated {timeAgo(record.updatedAt)}+ {record.providerId}{record.model ? ` · ${record.model}` : ''}{record.effort ? ` · ${record.effort} effort` : ''} · updated {timeAgo(record.updatedAt)}</p></div><div className="flex items-center gap-2">@@ -246,6 +261,8 @@ export default function ThreejsModelDetail() {availableModels={availableModels}onProviderChange={setSelectedProviderId}onModelChange={setSelectedModel}+ effort={effort}+ onEffortChange={setEffort}disabled={providersLoading || generating}alwaysShowModelemptyModelOption="Provider default"diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex 2475012727..3cbfdd8dc2 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -159,19 +159,103 @@ export const CLAUDE_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhiexport const CODEX_EFFORT_LEVELS = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra']);export const ANTIGRAVITY_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high']);+/**+ * Antigravity base-model ↔ effort-suffix split — MIRROR of+ * `splitAntigravityModel` / `antigravityBaseModels` / `antigravityModelEffortLevels`+ * in server/lib/providerModels.js; keep in lockstep.+ *+ * `agy models` enumerates the effort tiers as separate model ids+ * (`gemini-3.6-flash-low|-medium|-high`), which forces the effort choice into+ * the model dropdown. agy also accepts the BASE id with a separate `--effort`+ * flag, so PortOS lists base models and carries effort as its own control. agy+ * validates the PAIR, though (`gemini-3.1-pro` has no `medium`), so the tiers a+ * base model offers come from the provider's own catalog.+ */+const ANTIGRAVITY_EFFORT_SUFFIX_RE = new RegExp(`-(${ANTIGRAVITY_EFFORT_LEVELS.join('|')})$`);++/**+ * `gemini-3.6-flash-high` → `{ base: 'gemini-3.6-flash', effort: 'high' }`.+ * Unsuffixed ids, sentinels and non-strings → `{ base: <input>, effort: null }`.+ * @param {string|null|undefined} id+ * @returns {{base: string|null|undefined, effort: string|null}}+ */+export const splitAntigravityModel = (id) => {+ if (typeof id !== 'string' || id === '' || isConfiguredDefaultModel(id)) return { base: id, effort: null };+ const match = ANTIGRAVITY_EFFORT_SUFFIX_RE.exec(id);+ return match ? { base: id.slice(0, -match[0].length), effort: match[1] } : { base: id, effort: null };+};++/**+ * The user-selectable view of an Antigravity model list: effort suffixes+ * stripped, duplicates collapsed, order preserved. Sentinels and non-string+ * (`{ id, name }`) entries ride through untouched.+ * @param {unknown[]} models+ * @returns {unknown[]}+ */+export const antigravityBaseModels = (models) => {+ const out = [];+ const seen = new Set();+ for (const entry of Array.isArray(models) ? models : []) {+ if (typeof entry !== 'string') { out.push(entry); continue; }+ const { base } = splitAntigravityModel(entry);+ if (seen.has(base)) continue;+ seen.add(base);+ out.push(base);+ }+ return out;+};++/**+ * The effort tiers an Antigravity base model offers per the provider's catalog:+ * the present suffixes, `[]` when the model has none, or `null` when the catalog+ * is unknown (caller falls back to the full ladder).+ * @param {string|null|undefined} model+ * @param {unknown[]} models+ * @returns {readonly string[]|null}+ */+export const antigravityModelEffortLevels = (model, models) => {+ const list = (Array.isArray(models) ? models : []).filter(m => typeof m === 'string');+ if (list.length === 0) return null;+ const { base } = splitAntigravityModel(model);+ if (typeof base !== 'string' || base === '') return null;+ return Object.freeze(ANTIGRAVITY_EFFORT_LEVELS.filter(level => list.includes(`${base}-${level}`)));+};++/**+ * The provider's selectable model list as the pickers should show it. Today that+ * only rewrites Antigravity (base models instead of one row per effort tier);+ * every other provider's list passes through untouched. The single place the+ * normalization lives, so `useProviderModels` and any caller that reads+ * `provider.models` directly agree.+ * @param {{id?:string, command?:string}|null|undefined} provider+ * @param {unknown[]} models+ * @returns {unknown[]}+ */+export const selectableModelsForProvider = (provider, models) =>+ isAntigravityProvider(provider) ? antigravityBaseModels(models) : (models || []);+/*** The effort levels a provider's CLI accepts, or null when the provider has no* effort control (opencode, grok, kimi, HTTP API providers). Keyed on the launch* command basename plus the shipped provider ids, so path-configured or renamed* claude/codex/agy providers still qualify. Drives the "Effort (optional)"* select in task/schedule forms.- * @param {{id?:string, command?:string}|null|undefined} provider+ *+ * `model` narrows the Antigravity ladder to the tiers that base model actually+ * offers (see above). Omit it — or leave `provider.models` empty — for the full+ * low/medium/high ladder. MIRROR of the server helper; keep in lockstep.+ * @param {{id?:string, command?:string, models?:unknown[]}|null|undefined} provider+ * @param {string|null} [model]* @returns {readonly string[]|null}*/-export const effortLevelsForProvider = (provider) => {+export const effortLevelsForProvider = (provider, model = null) => {if (!provider) return null;if (isCodexProvider(provider)) return CODEX_EFFORT_LEVELS;- if (isAntigravityProvider(provider)) return ANTIGRAVITY_EFFORT_LEVELS;+ if (isAntigravityProvider(provider)) {+ const perModel = model ? antigravityModelEffortLevels(model, provider.models) : null;+ if (perModel === null) return ANTIGRAVITY_EFFORT_LEVELS;+ return perModel.length ? perModel : null;+ }const id = String(provider.id || '').toLowerCase();if (id.startsWith('claude-code') || commandBasename(provider.command) === 'claude') return CLAUDE_EFFORT_LEVELS;return null;@@ -192,12 +276,13 @@ const EFFORT_RANK = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh',* holds a value matching no option, renders blank — reading as "Default effort"* — while the run silently uses the clamped level.* @param {string|null|undefined} effort- * @param {{id?:string, command?:string}|null|undefined} provider+ * @param {{id?:string, command?:string, models?:unknown[]}|null|undefined} provider+ * @param {string|null} [model] - narrows the Antigravity ladder (see effortLevelsForProvider)* @returns {string|null}*/-export const resolveCliEffort = (effort, provider) => {+export const resolveCliEffort = (effort, provider, model = null) => {if (!effort) return null;- const levels = effortLevelsForProvider(provider);+ const levels = effortLevelsForProvider(provider, model);if (!levels) return null;if (levels.includes(effort)) return effort;const requested = EFFORT_RANK.indexOf(effort);diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex b7a786d4ab..0eb97b3fb8 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -46,12 +46,19 @@ import {enabledApiProviderFilter,providerTypeClass,getProviderTimeout,+ splitAntigravityModel,+ antigravityBaseModels,+ antigravityModelEffortLevels,+ selectableModelsForProvider,} from './providers.js';import { PROVIDER_TYPES as SERVER_PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';import {effortLevelsForProvider as serverEffortLevelsForProvider,isAntigravityProvider as serverIsAntigravityProvider,resolveCliEffort as serverResolveCliEffort,+ splitAntigravityModel as serverSplitAntigravityModel,+ antigravityBaseModels as serverAntigravityBaseModels,+ antigravityModelEffortLevels as serverAntigravityModelEffortLevels,} from '../../../server/lib/providerModels.js';// The client copy drives what EffortSelect DISPLAYS; the server copy decides@@ -102,6 +109,73 @@ describe('effortLevelsForProvider (server mirror)', () => {});});+// Antigravity lists one model id per effort tier (`gemini-3.6-flash-high`), but+// agy also takes the BASE id with a separate `--effort` flag — so the pickers+// show base models and carry effort as its own control. Both sides must agree on+// the split, or a client-side base id won't match what the server rebuilds.+describe('Antigravity base-model split (server mirror)', () => {+ // The catalog `agy models` prints — the shipped provider list mirrors it.+ const CATALOG = [+ ANTIGRAVITY_CONFIGURED_DEFAULT,+ 'gemini-3.6-flash-high', 'gemini-3.6-flash-medium', 'gemini-3.6-flash-low',+ 'gemini-3.1-pro-high', 'gemini-3.1-pro-low',+ 'claude-sonnet-4-6', 'claude-opus-4-6-thinking', 'gpt-oss-120b-medium',+ ];+ const BASES = [+ ANTIGRAVITY_CONFIGURED_DEFAULT,+ 'gemini-3.6-flash', 'gemini-3.1-pro',+ 'claude-sonnet-4-6', 'claude-opus-4-6-thinking', 'gpt-oss-120b',+ ];++ it.each([+ ['gemini-3.6-flash-high', { base: 'gemini-3.6-flash', effort: 'high' }],+ ['gpt-oss-120b-medium', { base: 'gpt-oss-120b', effort: 'medium' }],+ ['claude-opus-4-6-thinking', { base: 'claude-opus-4-6-thinking', effort: null }],+ [ANTIGRAVITY_CONFIGURED_DEFAULT, { base: ANTIGRAVITY_CONFIGURED_DEFAULT, effort: null }],+ ['', { base: '', effort: null }],+ ])('splitAntigravityModel(%s)', (id, expected) => {+ expect(splitAntigravityModel(id)).toEqual(expected);+ expect(serverSplitAntigravityModel(id)).toEqual(expected);+ });++ it('strips + dedupes the catalog into base models on both sides', () => {+ expect(antigravityBaseModels(CATALOG)).toEqual(BASES);+ expect(serverAntigravityBaseModels(CATALOG)).toEqual(BASES);+ });++ it.each([+ ['gemini-3.6-flash', ['low', 'medium', 'high']],+ // agy: `gemini-3.1-pro has no "medium" effort (available: low, high)`.+ ['gemini-3.1-pro', ['low', 'high']],+ ['gpt-oss-120b', ['medium']],+ ['claude-sonnet-4-6', []],+ ])('antigravityModelEffortLevels(%s)', (model, expected) => {+ expect(antigravityModelEffortLevels(model, CATALOG)).toEqual(expected);+ expect(serverAntigravityModelEffortLevels(model, CATALOG)).toEqual(expected);+ });++ it('narrows the picker ladder per selected model, and hides it for a tier-less model', () => {+ const agy = { id: 'antigravity-cli', command: 'agy', models: CATALOG };+ for (const [model, expected] of [+ ['gemini-3.6-flash', ['low', 'medium', 'high']],+ ['gemini-3.1-pro', ['low', 'high']],+ ['claude-sonnet-4-6', null],+ ]) {+ expect(effortLevelsForProvider(agy, model)).toEqual(expected);+ expect(serverEffortLevelsForProvider(agy, model)).toEqual(expected);+ }+ // Clamping follows the narrowed ladder, so agy never sees an invalid pair.+ expect(resolveCliEffort('medium', agy, 'gemini-3.1-pro')).toBe('low');+ expect(serverResolveCliEffort('medium', agy, 'gemini-3.1-pro')).toBe('low');+ });++ it('rewrites only Antigravity model lists', () => {+ expect(selectableModelsForProvider({ id: 'antigravity-cli', command: 'agy' }, CATALOG)).toEqual(BASES);+ expect(selectableModelsForProvider({ id: 'codex', command: 'codex' }, CATALOG)).toEqual(CATALOG);+ expect(selectableModelsForProvider(null, CATALOG)).toEqual(CATALOG);+ });+});+// Regression guard for the provider-edit form: an Antigravity provider publishes// a real `agy models` catalog while its defaultModel/tiers stay on the sentinel.// filterGenerationModels strips the sentinel, so the edit form needs this todiff --git a/server/lib/antigravity.js b/server/lib/antigravity.jsindex 3bc66b04d1..3c79723155 100644--- a/server/lib/antigravity.js+++ b/server/lib/antigravity.js@@ -1,4 +1,4 @@-import { buildEffortArgs, commandBasename, hasModelFlag, resolveCliModel, stripBrokenModelFlags } from './providerModels.js';+import { buildEffortArgs, commandBasename, extractBakedModel, hasModelFlag, resolveCliEffort, resolveCliModel, splitAntigravityModel, stripBrokenModelFlags } from './providerModels.js';export const ANTIGRAVITY_CLI_ID = 'antigravity-cli';export const ANTIGRAVITY_TUI_ID = 'antigravity-tui';@@ -40,23 +40,67 @@ export const ANTIGRAVITY_PRINT_FLAGS = ['--print', '-p', '--prompt'];* `claude-opus-4-6-thinking` through Google's own gateway, so rewriting those* to `global.anthropic.*` on a Bedrock host would hand agy an id it can't* resolve.+ *+ * See `resolveAntigravityModelAndEffort` for how the two are paired.*/-function appendAntigravityModelAndEffort(args, { model = null, effort = null } = {}) {+function appendAntigravityModelAndEffort(args, overrides = {}) {// Drop a dangling `--model` before appending: `hasModelFlag` (correctly)// reports a value-less flag as "not a pin", so leaving it in would hand agy// two `--model` occurrences.const out = stripBrokenModelFlags(args);- const effectiveModel = resolveCliModel(model);- if (effectiveModel && !hasModelFlag(out)) {- out.push('--model', effectiveModel);- }- out.push(...buildEffortArgs(effort, { id: ANTIGRAVITY_CLI_ID, command: 'agy' }, out));+ const { model, effort, base, provider } = resolveAntigravityModelAndEffort(out, overrides);+ if (model) out.push('--model', model);+ out.push(...buildEffortArgs(effort, provider, out, base));return out;}+/**+ * Pair an agy `--model` with an `--effort`, honoring a user-baked `--model` pin.+ *+ * `model` may arrive as either a BASE id (`gemini-3.6-flash` — what the pickers+ * now offer) or a legacy effort-suffixed id (`gemini-3.6-flash-high`, still what+ * older installs and federated peers have persisted). A suffixed id is split so+ * the base goes to `--model` and its baked tier becomes the `--effort` — an+ * explicitly selected `effort` wins over the baked one. That keeps a stored+ * suffixed id working unchanged (`--model X --effort high` is equivalent to+ * `--model X-high`) instead of orphaning it.+ *+ * `models` is the provider's model catalog; it narrows the effort ladder to the+ * tiers the chosen base actually offers, because agy validates the PAIR — it+ * rejects `--model gemini-3.1-pro --effort medium` outright. An unresolvable+ * effort leaves the model id untouched, so a suffix carrying the only usable+ * tier is never stripped away into an invalid invocation.+ *+ * When the saved argv already pins `--model`, that pin wins (same gate as+ * `buildCliArgs`) and `model` comes back null. The effort ladder is then read+ * off the PINNED id, and only an explicitly selected `effort` applies — a pin's+ * own baked suffix already says what it means and isn't restated as a redundant+ * `--effort`.+ *+ * @param {string[]} args - the argv built so far (post `stripBrokenModelFlags`)+ * @param {{model?:string|null, effort?:string|null, models?:unknown[]|null}} [overrides]+ * @returns {{model: string|null, effort: string|null, base: string|null, provider: object}}+ * `model` is the id to inject (null = don't), `provider` the synthetic agy+ * provider to hand `buildEffortArgs`.+ */+export function resolveAntigravityModelAndEffort(args = [], { model = null, effort = null, models = null } = {}) {+ const provider = { id: ANTIGRAVITY_CLI_ID, command: 'agy', models };+ const pinned = hasModelFlag(args);+ const requested = resolveCliModel(model);+ // The id agy will actually receive — a user-baked pin always wins.+ const { base, effort: bakedEffort } = splitAntigravityModel(pinned ? extractBakedModel(args) : requested);+ const effectiveEffort = resolveCliEffort(pinned ? effort : (effort || bakedEffort), provider, base);+ return {+ model: pinned ? null : (effectiveEffort ? base : requested),+ effort: effectiveEffort,+ base,+ provider,+ };+}+/*** @param {string[]} [args] - the provider's saved argv- * @param {{model?:string|null, effort?:string|null}} [overrides] - per-run selections+ * @param {{model?:string|null, effort?:string|null, models?:unknown[]|null}} [overrides] - per-run selections*/export function ensureAntigravityPrintArgs(args = [], overrides = {}) {// Drop any bare print flag the caller baked in — we re-add exactly one as the@@ -112,10 +156,11 @@ export function prepareAntigravityPrompt(args = [], prompt = '') {// permission auto-approval actually takes effect. Do NOT add --print here./*** Deliberately takes NO per-run model/effort overrides, unlike its `--print`- * sibling: the TUI path injects those in `agentTuiSpawning.js#appendModelArgs`- * + `buildEffortArgs`, after this normalizer has run (this is only reached via- * the provider-agnostic `applyCommandDefaults`). It still drops a dangling- * `--model` so that later append can't produce two of them.+ * sibling: the TUI paths inject those via `resolveAntigravityModelAndEffort` ++ * `buildEffortArgs` (in `tuiHandshake.js#buildTuiInvocation` and+ * `agentTuiSpawning.js#buildTuiSpawnConfig`), after this normalizer has run —+ * this is only reached via the provider-agnostic `applyCommandDefaults`. It+ * still drops a dangling `--model` so that later append can't produce two.* @param {string[]} [args] - the provider's saved argv*/export function ensureAntigravityTuiArgs(args = []) {diff --git a/server/lib/antigravity.test.js b/server/lib/antigravity.test.jsindex dac87f21a4..b34683ec9a 100644--- a/server/lib/antigravity.test.js+++ b/server/lib/antigravity.test.js@@ -108,8 +108,9 @@ describe('ensureAntigravityPrintArgs', () => {});it('drops a dangling --model rather than emitting it twice', () => {+ // The suffixed id splits into base + `--effort` (equivalent invocation).expect(ensureAntigravityPrintArgs(['--model'], { model: 'gemini-3.1-pro-low' }))- .toEqual(['--model', 'gemini-3.1-pro-low', '--dangerously-skip-permissions', '--print']);+ .toEqual(['--model', 'gemini-3.1-pro', '--effort', 'low', '--dangerously-skip-permissions', '--print']);});// This is the path every production caller uses (buildCliArgs,diff --git a/server/lib/cliProviderArgs.js b/server/lib/cliProviderArgs.jsindex 8f84e336f4..b05092dcfc 100644--- a/server/lib/cliProviderArgs.js+++ b/server/lib/cliProviderArgs.js@@ -18,7 +18,7 @@* - Claude Code: `-p -` (+ `--model <id>`)*/-import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs, stripBrokenModelFlags } from './providerModels.js';+import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs, buildEffortArgs, stripBrokenModelFlags } from './providerModels.js';import { ensureAntigravityPrintArgs, isAntigravityCliProvider, isAntigravityCommand, prepareAntigravityPrompt } from './antigravity.js';import { isGrokCommand, ensureGrokHeadlessArgs, prepareGrokPromptFile } from './grok.js';import { isKimiCommand, ensureKimiHeadlessArgs, prepareKimiPrompt } from './kimi.js';@@ -33,9 +33,16 @@ import { isKimiCommand, ensureKimiHeadlessArgs, prepareKimiPrompt } from './kimi* Model-flag injection is GATED on `provider.args` not already containing a* model flag — users who hard-coded e.g. `--model gemini-2.5-pro` in their* saved provider config keep that override and don't get a duplicate flag.+ *+ * `provider.effort` carries a per-run reasoning-effort override the same way+ * `provider.defaultModel` carries the per-run model: callers clone the provider+ * with both pinned (see `promptRunner.js#executeProviderRunOnce`). It becomes+ * `--effort <level>` on claude/agy and `-c model_reasoning_effort=<level>` on+ * codex, and is suppressed when the saved args already bake an effort pin.*/export function buildCliArgs(provider) {const providerId = provider?.id || '';+ const effort = provider?.effort || null;// Sanitize: drop any broken/dangling `--model` / `-m` tokens before// appending. hasModelFlag treats those as "not a real pin" so the// injection path fires — but if we kept the bogus token in baseArgs the@@ -59,6 +66,7 @@ export function buildCliArgs(provider) {if (effectiveDefaultModel) {args.push('--model', effectiveDefaultModel);}+ args.push(...buildEffortArgs(effort, provider, args));args.push('-'); // stdin markerreturn args;}@@ -69,7 +77,11 @@ export function buildCliArgs(provider) {// `--model` is honored like every other CLI here — the configured-default// sentinel resolves to null so agy falls back to its own configured model.if (isAntigravityCliProvider(provider)) {- return ensureAntigravityPrintArgs(baseArgs, { model: effectiveDefaultModel });+ return ensureAntigravityPrintArgs(baseArgs, {+ model: effectiveDefaultModel,+ effort,+ models: provider?.models,+ });}// Grok Build CLI (`grok`): headless one-shot. The prompt is delivered through@@ -135,6 +147,7 @@ export function buildCliArgs(provider) {});args.push('--model', model);}+ args.push(...buildEffortArgs(effort, provider, args));return args;}diff --git a/server/lib/cliProviderArgs.test.js b/server/lib/cliProviderArgs.test.jsindex e5d86274f0..9f8671cfd3 100644--- a/server/lib/cliProviderArgs.test.js+++ b/server/lib/cliProviderArgs.test.js@@ -193,6 +193,62 @@ describe('cliProviderArgs', () => {});});+ // `provider.effort` is how promptRunner hands a per-run reasoning-effort+ // override down to the arg builders (there is no `effort` parameter on+ // executeCliRun) — see executeProviderRunOnce's providerForRun clone.+ describe('buildCliArgs — provider.effort', () => {+ const AGY_CATALOG = [+ 'gemini-3.6-flash-high', 'gemini-3.6-flash-medium', 'gemini-3.6-flash-low',+ 'gemini-3.1-pro-high', 'gemini-3.1-pro-low',+ 'claude-sonnet-4-6',+ ];++ it('emits --effort for Claude Code', () => {+ expect(buildCliArgs({ id: 'claude-code', command: 'claude', defaultModel: 'claude-opus-5', effort: 'max' }))+ .toEqual(['-p', '-', '--model', 'claude-opus-5', '--effort', 'max']);+ });++ it('emits the -c config pair for Codex', () => {+ expect(buildCliArgs({ id: 'codex', command: 'codex', defaultModel: 'gpt-5', effort: 'xhigh' }))+ .toEqual([+ 'exec', '-c', 'check_for_update_on_startup=false',+ '--model', 'gpt-5', '-c', 'model_reasoning_effort=xhigh', '-',+ ]);+ });++ it('emits a base --model plus --effort for Antigravity', () => {+ expect(buildCliArgs({+ id: 'antigravity-cli', command: 'agy', defaultModel: 'gemini-3.6-flash', effort: 'high', models: AGY_CATALOG,+ })).toEqual(['--model', 'gemini-3.6-flash', '--effort', 'high', '--dangerously-skip-permissions', '--print']);+ });++ it('clamps an Antigravity effort the selected model does not offer', () => {+ // agy errors on `--model gemini-3.1-pro --effort medium`.+ expect(buildCliArgs({+ id: 'antigravity-cli', command: 'agy', defaultModel: 'gemini-3.1-pro', effort: 'medium', models: AGY_CATALOG,+ })).toEqual(['--model', 'gemini-3.1-pro', '--effort', 'low', '--dangerously-skip-permissions', '--print']);+ });++ it('splits a legacy suffixed Antigravity model into base + --effort', () => {+ expect(buildCliArgs({+ id: 'antigravity-cli', command: 'agy', defaultModel: 'gemini-3.6-flash-medium', models: AGY_CATALOG,+ })).toEqual(['--model', 'gemini-3.6-flash', '--effort', 'medium', '--dangerously-skip-permissions', '--print']);+ });++ it('is a no-op for providers with no effort control', () => {+ expect(buildCliArgs({ id: 'opencode', command: 'opencode', defaultModel: 'qwen3', effort: 'high' }))+ .toEqual(['run', '-m', 'qwen3']);+ expect(buildCliArgs({ id: 'grok-cli', command: 'grok', defaultModel: 'grok-4', effort: 'high' }))+ .not.toContain('--effort');+ });++ it('lets a user-baked --effort pin win', () => {+ expect(buildCliArgs({+ id: 'claude-code', command: 'claude', defaultModel: 'claude-opus-5', effort: 'max', args: ['--effort', 'low'],+ })).toEqual(['--effort', 'low', '-p', '-', '--model', 'claude-opus-5']);+ });+ });+describe('stripBrokenModelFlags', () => {it('drops dangling / empty model flags but keeps pinned ones', () => {expect(stripBrokenModelFlags(['--model'])).toEqual([]);diff --git a/server/lib/promptRunner.js b/server/lib/promptRunner.jsindex 3f15267a48..771eb0e739 100644--- a/server/lib/promptRunner.js+++ b/server/lib/promptRunner.js@@ -509,6 +509,12 @@ export function assertVisionRunUsedImages(result, requestedProvider) {* `'media-prompt-refine'`, `'messages-triage'`, `'staged-llm'`, etc.)* @param {string} [args.model] — model id hint; ignored when the* provider doesn't honor it (claude-code, antigravity-cli today).+ * @param {string} [args.effort] — reasoning-effort override for effort-capable+ * CLI/TUI providers (claude `--effort`, agy `--effort`, codex+ * `-c model_reasoning_effort=`). Clamped to the provider's (and, for agy, the+ * selected model's) ladder and dropped entirely for providers with no effort+ * control, so it is safe to pass unconditionally — including through the+ * fallback cascade, which may land on a provider that has none.* @param {string} [args.runId] — caller-supplied run id (skip createRun* round-trip when the caller has already created the run)* @param {(chunk: string) => void} [args.onData] — incremental stream@@ -1122,7 +1128,7 @@ function stripFallbackContext(err) {* swapped to a fallback when the requested provider was already marked* unavailable).*/-async function executeProviderRunOnce({ provider, prompt, source, model, runId: callerRunId, onData: onDataCallback, timeout: timeoutOverride, cwd: cwdOverride, screenshots = [] }) {+async function executeProviderRunOnce({ provider, prompt, source, model, effort = null, runId: callerRunId, onData: onDataCallback, timeout: timeoutOverride, cwd: cwdOverride, screenshots = [] }) {// Resolve the model that'll actually run BEFORE creating the run record// so the record reflects reality. resolveEffectiveModel handles both// the override-honored fallback chain AND the args-baked-CLI case@@ -1263,8 +1269,19 @@ async function executeProviderRunOnce({ provider, prompt, source, model, runId:// guard skips the clone when effectiveModel already equals// provider.defaultModel — typical for non-codex CLI providers where// resolveEffectiveModel falls through to defaultModel anyway.- const providerForRun = effectiveModel && effectiveModel !== effectiveProvider.defaultModel- ? { ...effectiveProvider, defaultModel: effectiveModel }+ //+ // A per-call reasoning-effort override rides the same clone (there is no+ // `effort` argument on executeCliRun/executeTuiRun): `buildCliArgs` and+ // `buildTuiInvocation` both read `provider.effort`. It is a no-op for+ // providers with no effort control, so a caller that always passes one+ // can't corrupt an opencode/grok/API run.+ const needsModelPin = effectiveModel && effectiveModel !== effectiveProvider.defaultModel;+ const providerForRun = (needsModelPin || effort)+ ? {+ ...effectiveProvider,+ ...(needsModelPin ? { defaultModel: effectiveModel } : {}),+ ...(effort ? { effort } : {}),+ }: effectiveProvider;if (effectiveProvider.type === PROVIDER_TYPES.CLI) {diff --git a/server/lib/promptRunner.test.js b/server/lib/promptRunner.test.jsindex 83c3d32484..ca21bfeb72 100644--- a/server/lib/promptRunner.test.js+++ b/server/lib/promptRunner.test.js@@ -289,6 +289,71 @@ describe('promptRunner — happy paths', () => {expect(out.text).toBe('ran with defaultModel=user-picked-this');});+ // `effort` has no parameter on executeCliRun/executeTuiRun — it rides the+ // provider clone, which is what buildCliArgs/buildTuiInvocation read.+ it('pins a per-call effort onto the CLI provider clone alongside the model', async () => {+ runner.executeCliRun.mockImplementation(async ({ provider: providerArg, onData, onComplete }) => {+ onData(`${providerArg.defaultModel}/${providerArg.effort}`);+ onComplete({ success: true });+ });++ const out = await runPromptThroughProvider({+ provider: cliProvider({ defaultModel: 'old' }), // id: 'codex'+ prompt: 'p',+ source: 't',+ model: 'new',+ effort: 'xhigh',+ });++ expect(out.text).toBe('new/xhigh');+ });++ it('pins a per-call effort even when the model needs no override', async () => {+ runner.executeCliRun.mockImplementation(async ({ provider: providerArg, onData, onComplete }) => {+ onData(`${providerArg.defaultModel}/${providerArg.effort}`);+ onComplete({ success: true });+ });++ const out = await runPromptThroughProvider({+ provider: cliProvider({ defaultModel: 'm-default' }),+ prompt: 'p',+ source: 't',+ effort: 'high',+ });++ expect(out.text).toBe('m-default/high');+ });++ it('leaves the provider untouched when no effort is given', async () => {+ runner.executeCliRun.mockImplementation(async ({ provider: providerArg, onData, onComplete }) => {+ onData(`effort=${'effort' in providerArg}`);+ onComplete({ success: true });+ });++ const out = await runPromptThroughProvider({+ provider: cliProvider({ defaultModel: 'm-default' }),+ prompt: 'p',+ source: 't',+ });++ expect(out.text).toBe('effort=false');+ });++ it('pins a per-call effort onto the TUI provider clone', async () => {+ tuiRunner.executeTuiRun.mockImplementation(async ({ provider: providerArg, onComplete }) => {+ onComplete({ success: true, text: `${providerArg.defaultModel}/${providerArg.effort}` });+ });++ const out = await runPromptThroughProvider({+ provider: tuiProvider({ defaultModel: 'm-default' }),+ prompt: 'p',+ source: 't',+ effort: 'max',+ });++ expect(out.text).toBe('m-default/max');+ });+it('does NOT clone CLI providers when args have a baked-in --model flag (args win)', async () => {// When the user has pinned a model in provider.args, runner.js// suppresses its own --model injection. Per-call override isdiff --git a/server/lib/providerModels.js b/server/lib/providerModels.jsindex 3b82954e5d..a9b495997d 100644--- a/server/lib/providerModels.js+++ b/server/lib/providerModels.js@@ -71,6 +71,87 @@ export const EFFORT_LEVELS = Object.freeze([...new Set([...ANTIGRAVITY_EFFORT_LEVELS,])]);+// ---------------------------------------------------------------------------+// Antigravity base-model ↔ effort-suffix split.+//+// `agy models` enumerates the effort tiers as separate model ids+// (`gemini-3.6-flash-low|-medium|-high`), which forces the user to pick their+// reasoning effort *inside* the model dropdown. agy also accepts the BASE id+// with a separate `--effort` flag (`--model gemini-3.6-flash --effort high`) —+// verified against the real binary — so PortOS lists base models and carries+// effort as its own control.+//+// agy validates the PAIR, though: `--model gemini-3.1-pro --effort medium`+// errors with `gemini-3.1-pro has no "medium" effort (available: low, high)`.+// So the tiers a base model offers are derived from the provider's own model+// catalog rather than assumed to be the full low/medium/high ladder.+// Mirrored in client/src/utils/providers.js — keep in lockstep.+// ---------------------------------------------------------------------------++const ANTIGRAVITY_EFFORT_SUFFIX_RE = new RegExp(`-(${ANTIGRAVITY_EFFORT_LEVELS.join('|')})$`);++/**+ * Split an Antigravity model id into its base id and baked-in effort tier —+ * `gemini-3.6-flash-high` → `{ base: 'gemini-3.6-flash', effort: 'high' }`.+ * Ids with no effort suffix (`claude-sonnet-4-6`), configured-default sentinels,+ * and non-strings come back as `{ base: <input>, effort: null }`.+ * @param {string|null|undefined} id+ * @returns {{base: string|null|undefined, effort: string|null}}+ */+export function splitAntigravityModel(id) {+ if (typeof id !== 'string' || id === '' || isConfiguredDefaultModel(id)) {+ return { base: id, effort: null };+ }+ const match = ANTIGRAVITY_EFFORT_SUFFIX_RE.exec(id);+ return match+ ? { base: id.slice(0, -match[0].length), effort: match[1] }+ : { base: id, effort: null };+}++/**+ * The user-selectable view of an Antigravity model list: effort suffixes+ * stripped, duplicates collapsed, original order preserved. Configured-default+ * sentinels and non-string entries (`{ id, name }` objects some pickers pass)+ * ride through untouched so callers can hand this any `provider.models`.+ * @param {unknown[]} models+ * @returns {unknown[]}+ */+export function antigravityBaseModels(models) {+ const out = [];+ const seen = new Set();+ for (const entry of Array.isArray(models) ? models : []) {+ if (typeof entry !== 'string') {+ out.push(entry);+ continue;+ }+ const { base } = splitAntigravityModel(entry);+ if (seen.has(base)) continue;+ seen.add(base);+ out.push(base);+ }+ return out;+}++/**+ * The effort tiers an Antigravity base model actually offers, read off the+ * provider's own model catalog:+ * - `['low','high']` — the suffixed variants present for that base.+ * - `[]` — the base is in the catalog with no suffixed variants+ * (`claude-sonnet-4-6`): agy has no effort knob for it.+ * - `null` — the catalog is unknown/empty, so the caller should+ * fall back to the full ladder rather than assume none.+ * @param {string|null|undefined} model - base or suffixed model id+ * @param {unknown[]} models - the provider's model list+ * @returns {readonly string[]|null}+ */+export function antigravityModelEffortLevels(model, models) {+ const list = (Array.isArray(models) ? models : []).filter(m => typeof m === 'string');+ if (list.length === 0) return null;+ const { base } = splitAntigravityModel(model);+ if (typeof base !== 'string' || base === '') return null;+ return Object.freeze(ANTIGRAVITY_EFFORT_LEVELS.filter(level => list.includes(`${base}-${level}`)));+}+/*** True when a provider is codex-flavored — the shipped `codex`/`codex-tui`* provider ids or any provider whose launch command basename is `codex`@@ -154,13 +235,24 @@ export function isAntigravityProvider(provider) {* `isClaudeCommand`/`isOpencodeCommand`. A blank command does NOT default to* Claude here (unlike `isClaudeCommand`): effort is an opt-in enhancement, and* only a provider we can positively identify should advertise levels.- * @param {{id?:string, command?:string}|null|undefined} provider+ *+ * `model` narrows the Antigravity ladder to the tiers that base model actually+ * offers (agy rejects `gemini-3.1-pro --effort medium`), read off+ * `provider.models`. Omit it — or leave the catalog empty — to get the full+ * low/medium/high ladder. Returns null for an Antigravity model the catalog+ * says has no tiers at all (`claude-sonnet-4-6`), so no `--effort` is emitted.+ * @param {{id?:string, command?:string, models?:unknown[]}|null|undefined} provider+ * @param {string|null} [model]* @returns {readonly string[]|null}*/-export function effortLevelsForProvider(provider) {+export function effortLevelsForProvider(provider, model = null) {if (!provider) return null;if (isCodexProvider(provider)) return CODEX_EFFORT_LEVELS;- if (isAntigravityProvider(provider)) return ANTIGRAVITY_EFFORT_LEVELS;+ if (isAntigravityProvider(provider)) {+ const perModel = model ? antigravityModelEffortLevels(model, provider.models) : null;+ if (perModel === null) return ANTIGRAVITY_EFFORT_LEVELS;+ return perModel.length ? perModel : null;+ }if (isClaudeProvider(provider)) return CLAUDE_EFFORT_LEVELS;return null;}@@ -180,12 +272,13 @@ const EFFORT_RANK = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh',* back to the provider's weakest level when nothing sits below it* (`minimal`→`low`) — rather than being dropped.* @param {string|null|undefined} effort- * @param {{id?:string, command?:string}|null|undefined} provider+ * @param {{id?:string, command?:string, models?:unknown[]}|null|undefined} provider+ * @param {string|null} [model] - narrows the Antigravity ladder (see effortLevelsForProvider)* @returns {string|null}*/-export function resolveCliEffort(effort, provider) {+export function resolveCliEffort(effort, provider, model = null) {if (!effort) return null;- const levels = effortLevelsForProvider(provider);+ const levels = effortLevelsForProvider(provider, model);if (!levels) return null;if (levels.includes(effort)) return effort;const requested = EFFORT_RANK.indexOf(effort);@@ -225,12 +318,13 @@ export function hasEffortFlag(args) {* home for both the detection AND the arg shape, so the two can't drift — spawn* builders just spread the result.* @param {string|null|undefined} effort- * @param {{id?:string, command?:string}|null|undefined} provider+ * @param {{id?:string, command?:string, models?:unknown[]}|null|undefined} provider* @param {unknown[]} [existingArgs]+ * @param {string|null} [model] - narrows the Antigravity ladder (see effortLevelsForProvider)* @returns {string[]}*/-export function buildEffortArgs(effort, provider, existingArgs = []) {- const effectiveEffort = resolveCliEffort(effort, provider);+export function buildEffortArgs(effort, provider, existingArgs = [], model = null) {+ const effectiveEffort = resolveCliEffort(effort, provider, model);if (!effectiveEffort || hasEffortFlag(existingArgs)) return [];return isCodexProvider(provider)? ['-c', `model_reasoning_effort=${effectiveEffort}`]diff --git a/server/lib/providerModels.test.js b/server/lib/providerModels.test.jsindex 5f836027b8..9370d2151a 100644--- a/server/lib/providerModels.test.js+++ b/server/lib/providerModels.test.js@@ -35,9 +35,20 @@ import {hasCodexUpdateCheckConfig,buildCodexStartupArgs,isCodexProvider,- isKimiProvider+ isKimiProvider,+ splitAntigravityModel,+ antigravityBaseModels,+ antigravityModelEffortLevels} from './providerModels.js';+// The catalog `agy models` prints — the shipped provider list mirrors it.+const AGY_CATALOG = [+ 'antigravity-configured-default',+ 'gemini-3.6-flash-high', 'gemini-3.6-flash-medium', 'gemini-3.6-flash-low',+ 'gemini-3.1-pro-high', 'gemini-3.1-pro-low',+ 'claude-sonnet-4-6', 'gpt-oss-120b-medium',+];+describe('providerModels', () => {describe('providerSuppliesGithubToken', () => {it('is true when envVars carries GH_TOKEN or GITHUB_TOKEN (even if empty-string)', () => {@@ -192,6 +203,90 @@ describe('providerModels', () => {expect(effortLevelsForProvider(null)).toBeNull();});+ it('narrows the agy ladder to the tiers the selected model actually offers', () => {+ const agy = { id: 'antigravity-cli', command: 'agy', models: AGY_CATALOG };+ expect(effortLevelsForProvider(agy, 'gemini-3.6-flash')).toEqual(['low', 'medium', 'high']);+ // agy: `gemini-3.1-pro has no "medium" effort (available: low, high)`.+ expect(effortLevelsForProvider(agy, 'gemini-3.1-pro')).toEqual(['low', 'high']);+ expect(effortLevelsForProvider(agy, 'gpt-oss-120b')).toEqual(['medium']);+ // A suffixed id resolves through its base — same tiers.+ expect(effortLevelsForProvider(agy, 'gemini-3.1-pro-high')).toEqual(['low', 'high']);+ });++ it('returns null for an agy model the catalog gives no tiers, so no --effort is emitted', () => {+ const agy = { id: 'antigravity-cli', command: 'agy', models: AGY_CATALOG };+ expect(effortLevelsForProvider(agy, 'claude-sonnet-4-6')).toBeNull();+ });++ it('falls back to the full agy ladder when the catalog is unknown', () => {+ expect(effortLevelsForProvider({ id: 'antigravity-cli', command: 'agy' }, 'gemini-3.1-pro'))+ .toBe(ANTIGRAVITY_EFFORT_LEVELS);+ expect(effortLevelsForProvider({ id: 'antigravity-cli', command: 'agy', models: [] }, 'gemini-3.1-pro'))+ .toBe(ANTIGRAVITY_EFFORT_LEVELS);+ });++ it('ignores `model` for non-antigravity providers', () => {+ expect(effortLevelsForProvider({ id: 'codex', command: 'codex' }, 'gpt-5-high')).toBe(CODEX_EFFORT_LEVELS);+ expect(effortLevelsForProvider({ id: 'claude-code', command: 'claude' }, 'claude-opus-5-high'))+ .toBe(CLAUDE_EFFORT_LEVELS);+ });+ });++ describe('splitAntigravityModel', () => {+ it('splits an effort-suffixed id into base + tier', () => {+ expect(splitAntigravityModel('gemini-3.6-flash-high')).toEqual({ base: 'gemini-3.6-flash', effort: 'high' });+ expect(splitAntigravityModel('gemini-3.6-flash-medium')).toEqual({ base: 'gemini-3.6-flash', effort: 'medium' });+ expect(splitAntigravityModel('gpt-oss-120b-medium')).toEqual({ base: 'gpt-oss-120b', effort: 'medium' });+ });++ it('leaves unsuffixed ids, sentinels and non-strings alone', () => {+ expect(splitAntigravityModel('claude-sonnet-4-6')).toEqual({ base: 'claude-sonnet-4-6', effort: null });+ // `-thinking` is not an effort tier.+ expect(splitAntigravityModel('claude-opus-4-6-thinking'))+ .toEqual({ base: 'claude-opus-4-6-thinking', effort: null });+ expect(splitAntigravityModel(ANTIGRAVITY_CONFIGURED_DEFAULT))+ .toEqual({ base: ANTIGRAVITY_CONFIGURED_DEFAULT, effort: null });+ expect(splitAntigravityModel('')).toEqual({ base: '', effort: null });+ expect(splitAntigravityModel(null)).toEqual({ base: null, effort: null });+ expect(splitAntigravityModel(undefined)).toEqual({ base: undefined, effort: null });+ });++ it('only strips the trailing tier, not a mid-id match', () => {+ expect(splitAntigravityModel('gemini-high-pro')).toEqual({ base: 'gemini-high-pro', effort: null });+ });+ });++ describe('antigravityBaseModels', () => {+ it('strips suffixes and dedupes, preserving order', () => {+ expect(antigravityBaseModels(AGY_CATALOG)).toEqual([+ 'antigravity-configured-default',+ 'gemini-3.6-flash',+ 'gemini-3.1-pro',+ 'claude-sonnet-4-6',+ 'gpt-oss-120b',+ ]);+ });++ it('passes non-string entries through and tolerates non-arrays', () => {+ const obj = { id: 'x', name: 'X' };+ expect(antigravityBaseModels(['a-low', obj, 'a-high'])).toEqual(['a', obj]);+ expect(antigravityBaseModels(null)).toEqual([]);+ expect(antigravityBaseModels(undefined)).toEqual([]);+ });+ });++ describe('antigravityModelEffortLevels', () => {+ it('reports only the tiers present in the catalog', () => {+ expect(antigravityModelEffortLevels('gemini-3.6-flash', AGY_CATALOG)).toEqual(['low', 'medium', 'high']);+ expect(antigravityModelEffortLevels('gemini-3.1-pro', AGY_CATALOG)).toEqual(['low', 'high']);+ expect(antigravityModelEffortLevels('claude-sonnet-4-6', AGY_CATALOG)).toEqual([]);+ });++ it('returns null (unknown, not "none") for an empty/absent catalog', () => {+ expect(antigravityModelEffortLevels('gemini-3.6-flash', [])).toBeNull();+ expect(antigravityModelEffortLevels('gemini-3.6-flash', null)).toBeNull();+ expect(antigravityModelEffortLevels('', AGY_CATALOG)).toBeNull();+ });});describe('isCodexProvider', () => {@@ -231,6 +326,13 @@ describe('providerModels', () => {expect(buildEffortArgs('high', { id: 'grok-cli', command: 'grok' })).toEqual([]);expect(buildEffortArgs('max', { id: 'claude-code', command: 'claude' }, ['--effort', 'low'])).toEqual([]);});++ it('honors the per-model agy ladder when a model is supplied', () => {+ const agy = { id: 'antigravity-cli', command: 'agy', models: AGY_CATALOG };+ expect(buildEffortArgs('medium', agy, [], 'gemini-3.6-flash')).toEqual(['--effort', 'medium']);+ expect(buildEffortArgs('medium', agy, [], 'gemini-3.1-pro')).toEqual(['--effort', 'low']);+ expect(buildEffortArgs('high', agy, [], 'claude-sonnet-4-6')).toEqual([]);+ });});describe('resolveCliEffort', () => {@@ -263,6 +365,19 @@ describe('providerModels', () => {expect(resolveCliEffort('bogus', { id: 'antigravity-cli', command: 'agy' })).toBeNull();expect(resolveCliEffort('high', { id: 'grok-cli', command: 'grok' })).toBeNull();});++ it('clamps to the tiers the selected agy model has, so agy never sees an invalid pair', () => {+ const agy = { id: 'antigravity-cli', command: 'agy', models: AGY_CATALOG };+ expect(resolveCliEffort('medium', agy, 'gemini-3.6-flash')).toBe('medium');+ // agy rejects `--model gemini-3.1-pro --effort medium` — clamp to `low`.+ expect(resolveCliEffort('medium', agy, 'gemini-3.1-pro')).toBe('low');+ expect(resolveCliEffort('high', agy, 'gemini-3.1-pro')).toBe('high');+ // gpt-oss-120b ships only a medium tier: everything lands on it.+ expect(resolveCliEffort('high', agy, 'gpt-oss-120b')).toBe('medium');+ expect(resolveCliEffort('low', agy, 'gpt-oss-120b')).toBe('medium');+ // No tiers at all → no flag.+ expect(resolveCliEffort('high', agy, 'claude-sonnet-4-6')).toBeNull();+ });});describe('isAntigravityProvider', () => {diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.jsindex dfd81dc071..a1b6c41ccf 100644--- a/server/lib/tuiHandshake.js+++ b/server/lib/tuiHandshake.js@@ -12,8 +12,8 @@* No cycle risk: this module imports nothing from either consumer.*/-import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs, commandBasename } from './providerModels.js';-import { ensureAntigravityTuiArgs, isAntigravityCommand } from './antigravity.js';+import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs, buildEffortArgs, commandBasename } from './providerModels.js';+import { ensureAntigravityTuiArgs, isAntigravityCommand, resolveAntigravityModelAndEffort } from './antigravity.js';import { ensureGrokTuiArgs, isGrokCommand } from './grok.js';import { ensureKimiTuiArgs, isKimiCommand } from './kimi.js';@@ -955,15 +955,36 @@ function codexHasApprovalPolicy(args) {* the per-call --model append — otherwise the CLI would see two flags and* either error or take the last one (provider-specific). Matches the same* gate `runner.js#buildCliArgs` uses for CLI providers.+ *+ * `provider.effort` carries a per-run reasoning-effort override (callers clone+ * the provider with it pinned, same as `defaultModel`) and becomes+ * `--effort <level>` / codex's `-c model_reasoning_effort=<level>`. For agy an+ * effort-suffixed model id is split so the base rides `--model` and its baked+ * tier becomes the `--effort` — see antigravity.js for why.*/export function buildTuiInvocation(provider, model) {const command = provider?.command || inferTuiCommand(provider?.id);const baseArgs = applyCommandDefaults(command, [...(provider?.args || [])]);+ const effort = provider?.effort || null;++ // Antigravity pairs `--model` with `--effort` under its own rules (an+ // effort-suffixed id is split; agy validates the pair) — see antigravity.js.+ if (isAntigravityCommand(command)) {+ const resolved = resolveAntigravityModelAndEffort(baseArgs, {+ model,+ effort,+ models: provider?.models,+ });+ const withModel = resolved.model ? [...baseArgs, '--model', resolved.model] : baseArgs;+ return {+ command,+ args: [...withModel, ...buildEffortArgs(resolved.effort, resolved.provider, withModel, resolved.base)],+ };+ }+const effectiveModel = resolveCliModel(model);const shouldInject = !!effectiveModel && !hasModelFlag(baseArgs);// OpenCode TUI: namespace the bare Ollama id (`opencode --model ollama/<id>`).- // Antigravity takes the id verbatim — its `claude-*` ids are served by Google's- // own gateway, so a Bedrock rewrite would produce an id agy can't resolve.// Otherwise map a bare Claude id to its Bedrock form when the box is in Bedrock// mode (no-op otherwise / for non-Claude ids) — mirrors buildCliArgs for the// claude-code-tui runner.@@ -971,14 +992,15 @@ export function buildTuiInvocation(provider, model) {? effectiveModel: isOpencodeCommand(command)? prefixOpencodeModel(provider, effectiveModel)- : isAntigravityCommand(command)- ? effectiveModel- : resolveBedrockCliModel(effectiveModel, {- env: { ...process.env, ...provider?.envVars },- providerId: provider?.id,- });- const args = shouldInject ? [...baseArgs, '--model', injectedModel] : baseArgs;- return { command, args };+ : resolveBedrockCliModel(effectiveModel, {+ env: { ...process.env, ...provider?.envVars },+ providerId: provider?.id,+ });+ const withModel = shouldInject ? [...baseArgs, '--model', injectedModel] : baseArgs;+ return {+ command,+ args: [...withModel, ...buildEffortArgs(effort, { id: provider?.id, command }, withModel)],+ };}/**diff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.jsindex b7684a29fb..b1ed67086f 100644--- a/server/lib/tuiHandshake.test.js+++ b/server/lib/tuiHandshake.test.js@@ -683,7 +683,63 @@ describe('tuiHandshake.buildTuiInvocation', () => {it('appends --model for Antigravity TUI when a real model is selected', () => {const out = buildTuiInvocation({ id: 'antigravity-tui', command: 'agy', args: [] }, 'gemini-3.1-pro-high');expect(out.command).toBe('agy');- expect(out.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.1-pro-high']);+ // A legacy effort-suffixed id splits into base + `--effort` — the same+ // invocation agy resolves `gemini-3.1-pro-high` to.+ expect(out.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.1-pro', '--effort', 'high']);+ });++ it('pairs a base Antigravity model with provider.effort', () => {+ const out = buildTuiInvocation(+ { id: 'antigravity-tui', command: 'agy', args: [], effort: 'medium' },+ 'gemini-3.6-flash',+ );+ expect(out.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.6-flash', '--effort', 'medium']);+ });++ it('clamps provider.effort to a tier the selected Antigravity model actually has', () => {+ // agy rejects `--model gemini-3.1-pro --effort medium` outright, so the+ // catalog narrows the ladder to the tiers that base really offers.+ const out = buildTuiInvocation(+ {+ id: 'antigravity-tui',+ command: 'agy',+ args: [],+ effort: 'medium',+ models: ['gemini-3.1-pro-low', 'gemini-3.1-pro-high'],+ },+ 'gemini-3.1-pro',+ );+ expect(out.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.1-pro', '--effort', 'low']);+ });++ it('emits no --effort for an Antigravity model the catalog gives no tiers', () => {+ const out = buildTuiInvocation(+ {+ id: 'antigravity-tui',+ command: 'agy',+ args: [],+ effort: 'high',+ models: ['gemini-3.6-flash-high', 'claude-sonnet-4-6'],+ },+ 'claude-sonnet-4-6',+ );+ expect(out.args).toEqual(['--dangerously-skip-permissions', '--model', 'claude-sonnet-4-6']);+ });++ it('appends --effort for a claude TUI provider carrying provider.effort', () => {+ const out = buildTuiInvocation(+ { id: 'claude-code-tui', command: 'claude', args: [], effort: 'max' },+ 'claude-opus-5',+ );+ expect(out.args).toEqual(['--model', 'claude-opus-5', '--effort', 'max']);+ });++ it('emits no --effort for a TUI provider with no effort control', () => {+ const out = buildTuiInvocation(+ { id: 'opencode-tui', command: 'opencode', args: [], effort: 'high' },+ 'qwen3',+ );+ expect(out.args).toEqual(['--model', 'qwen3']);});// agy serves its `claude-*` ids through Google's own gateway, so a Bedrock boxdiff --git a/server/routes/threejsModels.js b/server/routes/threejsModels.jsindex 32b8480718..9f6b211372 100644--- a/server/routes/threejsModels.js+++ b/server/routes/threejsModels.js@@ -2,6 +2,8 @@ import { Router } from 'express';import { z } from 'zod';import { asyncHandler, ServerError } from '../lib/errorHandler.js';import { validateRequest } from '../lib/validation.js';+import { EFFORT_LEVELS } from '../lib/providerModels.js';+import { emptyToNull } from '../lib/zodCompat.js';import {listModels,getModel,@@ -16,17 +18,24 @@ const router = Router();const galleryFilenameSchema = z.string().trim().min(1).max(256).regex(/^[^/\\]+\.png$/i, 'filename must be a gallery PNG basename');+// Reasoning-effort override. The picker's "Default effort" choice submits `''`,+// which maps to an explicit `null` CLEAR — distinct from the key being absent,+// which leaves the record's stored effort alone (see startGeneration).+const effortSchema = z.preprocess(emptyToNull, z.enum(EFFORT_LEVELS).nullable().optional());+const createSchema = z.object({name: z.string().trim().min(1).max(120),filename: galleryFilenameSchema,prompt: z.string().trim().max(2_000).default(''),providerId: z.string().trim().min(1).max(128),model: z.string().trim().max(256).optional(),+ effort: effortSchema,});const generateSchema = z.object({providerId: z.string().trim().min(1).max(128).optional(),model: z.string().trim().max(256).optional(),+ effort: effortSchema,prompt: z.string().trim().max(2_000).optional(),feedback: z.string().trim().max(2_000).default(''),});diff --git a/server/routes/threejsModels.test.js b/server/routes/threejsModels.test.jsindex 30c73d9391..395a2727e1 100644--- a/server/routes/threejsModels.test.js+++ b/server/routes/threejsModels.test.js@@ -68,6 +68,48 @@ describe('Three.js model routes', () => {});});+ it('forwards a reasoning-effort override on generate and create', async () => {+ models.startGeneration.mockResolvedValueOnce({ id: 'threejs-1', status: 'generating' });+ const res = await request(makeApp())+ .post('/api/threejs-models/threejs-1/generate')+ .send({ providerId: 'antigravity-cli', model: 'gemini-3.6-flash', effort: 'high' });+ expect(res.status).toBe(202);+ expect(models.startGeneration).toHaveBeenCalledWith('threejs-1', {+ providerId: 'antigravity-cli',+ model: 'gemini-3.6-flash',+ effort: 'high',+ feedback: '',+ });++ models.createModel.mockResolvedValueOnce({ id: 'threejs-2', status: 'generating' });+ await request(makeApp())+ .post('/api/threejs-models')+ .send({ name: 'R', filename: 'r.png', providerId: 'antigravity-cli', model: 'gemini-3.6-flash', effort: 'low' });+ expect(models.createModel).toHaveBeenCalledWith(expect.objectContaining({ effort: 'low' }));+ });++ it('maps the picker\'s empty "Default effort" to an explicit null clear', async () => {+ models.startGeneration.mockResolvedValueOnce({ id: 'threejs-1', status: 'generating' });+ const res = await request(makeApp())+ .post('/api/threejs-models/threejs-1/generate')+ .send({ providerId: 'antigravity-cli', effort: '' });+ expect(res.status).toBe(202);+ // `null` = clear, distinct from the key being absent (= keep what's stored).+ expect(models.startGeneration).toHaveBeenCalledWith('threejs-1', {+ providerId: 'antigravity-cli',+ effort: null,+ feedback: '',+ });+ });++ it('rejects an effort that is not a known level', async () => {+ const res = await request(makeApp())+ .post('/api/threejs-models/threejs-1/generate')+ .send({ providerId: 'antigravity-cli', effort: 'turbo' });+ expect(res.status).toBe(400);+ expect(models.startGeneration).not.toHaveBeenCalled();+ });+it('serves generated source as a JavaScript attachment', async () => {models.getModelSource.mockResolvedValueOnce({filename: 'example-robot.js',diff --git a/server/services/agentCliSpawning.js b/server/services/agentCliSpawning.jsindex f016bf9173..71febdee47 100644--- a/server/services/agentCliSpawning.js+++ b/server/services/agentCliSpawning.js@@ -297,7 +297,13 @@ export function buildCliSpawnConfig(provider, model, settingsEnv = {}, { systemP// Per-task `--model` / `--effort` overrides are threaded in the same way as// claude/codex — agy documents both as session-scoped flags.if (isAntigravityCliProvider(provider)) {- const args = ensureAntigravityPrintArgs(provider?.args || [], { model: effectiveModel, effort });+ // `models` narrows the effort ladder to the tiers the chosen base model+ // actually offers — agy rejects `--model gemini-3.1-pro --effort medium`.+ const args = ensureAntigravityPrintArgs(provider?.args || [], {+ model: effectiveModel,+ effort,+ models: provider?.models,+ });return {command: provider?.command || 'agy',args,diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.jsindex 50a239126c..f6a531111b 100644--- a/server/services/agentTuiSpawning.js+++ b/server/services/agentTuiSpawning.js@@ -31,7 +31,7 @@ import { resolveCliModel, buildEffortArgs, resolveBedrockCliModel, prefixOpencodimport { createStreamingAnsiStripper, stripAnsi } from '../lib/ansiStrip.js';import { createImmediateFallbackSignalDetector } from '../lib/aiToolkit/errorDetection.js';import { isMachineOnline } from '../lib/connectivity.js';-import { isAntigravityCommand } from '../lib/antigravity.js';+import { isAntigravityCommand, resolveAntigravityModelAndEffort } from '../lib/antigravity.js';import {DEFAULT_TUI_PROMPT_DELAY_MS,DEFAULT_TUI_IDLE_TIMEOUT_MS,@@ -233,13 +233,9 @@ function appendModelArgs(args, model, command, provider) {if (hasModelFlag(args)) return args;return [...args, '--model', prefixOpencodeModel(provider, effectiveModel)];}- // Antigravity (`agy --model <id>`). No Bedrock mapping: agy serves- // `claude-*` ids through Google's own gateway, so rewriting them to- // `global.anthropic.*` would hand it an id it can't resolve.- if (isAntigravityCommand(command)) {- if (hasModelFlag(args)) return args;- return [...args, '--model', effectiveModel];- }+ // Antigravity never reaches here: buildTuiSpawnConfig resolves its model and+ // effort together up front (agy validates the pair) — see antigravity.js.+// Bedrock box: map a bare Claude id to its region-prefixed form just-in-time// (no-op off Bedrock / for non-Claude ids).const injectedModel = resolveBedrockCliModel(effectiveModel, {@@ -252,10 +248,20 @@ function appendModelArgs(args, model, command, provider) {export function buildTuiSpawnConfig(provider, model, { systemPromptFile = null, effort = null } = {}) {const command = provider?.command || inferTuiCommand(provider?.id);const baseArgs = applyCommandDefaults(command, [...(provider?.args || [])]);- let args = appendModelArgs(baseArgs, model, command, provider);- // Reasoning-effort override — the provider is re-keyed on the RESOLVED launch- // command so an inferred command (blank provider.command) still qualifies.- args = [...args, ...buildEffortArgs(effort, { id: provider?.id, command }, args)];+ let args;+ if (isAntigravityCommand(command)) {+ // agy validates the (model, effort) PAIR — `gemini-3.1-pro` has no `medium`+ // tier — and a legacy suffixed id carries its own effort, so the two are+ // resolved together against the provider's catalog (see antigravity.js).+ const resolved = resolveAntigravityModelAndEffort(baseArgs, { model, effort, models: provider?.models });+ args = resolved.model ? [...baseArgs, '--model', resolved.model] : baseArgs;+ args = [...args, ...buildEffortArgs(resolved.effort, resolved.provider, args, resolved.base)];+ } else {+ args = appendModelArgs(baseArgs, model, command, provider);+ // Reasoning-effort override — the provider is re-keyed on the RESOLVED launch+ // command so an inferred command (blank provider.command) still qualifies.+ args = [...args, ...buildEffortArgs(effort, { id: provider?.id, command }, args)];+ }// Lean mode for Ollama-backed claude sessions (no-op otherwise) — must come// before the system-prompt flag so `--bare` is present when the contract// file rides along.diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.jsindex 0cac1068b3..e1e852a710 100644--- a/server/services/agentTuiSpawning.test.js+++ b/server/services/agentTuiSpawning.test.js@@ -345,7 +345,9 @@ describe('agent TUI spawning', () => {'gemini-3.1-pro-high',{ effort: 'low' },);- expect(agy.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.1-pro-high', '--effort', 'low']);+ // An explicitly selected effort wins over the tier baked into the model id,+ // and the id is passed as its base so agy sees exactly one effort source.+ expect(agy.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.1-pro', '--effort', 'low']);});it('adds lean-mode flags and the system-prompt file for an Ollama-backed claude TUI', () => {diff --git a/server/services/askService.js b/server/services/askService.jsindex 45faa46e0d..124be788d1 100644--- a/server/services/askService.js+++ b/server/services/askService.js@@ -585,7 +585,7 @@ async function* streamCompletion(provider, model, prompt, signal) {// the final token — anything appended after it (headlessArgs, --model) would// be swallowed as the prompt text. `--model` is injected here, gated on the// configured-default sentinel and any user-baked pin.- args = ensureAntigravityPrintArgs(args, { model: cliModel });+ args = ensureAntigravityPrintArgs(args, { model: cliModel, models: provider?.models });} else if (provider.id === 'gemini-cli') {if (!args.includes('--output-format') && !args.includes('-o')) args.push('--output-format', 'text');if (cliModel) args.push('--model', cliModel);diff --git a/server/services/askService.test.js b/server/services/askService.test.jsindex 8e1a2f2951..ad2942fd2a 100644--- a/server/services/askService.test.js+++ b/server/services/askService.test.js@@ -421,7 +421,8 @@ describe('runAsk', () => {// with the prompt after it — nothing else may follow the marker.expect(args.slice(0, -1)).toEqual(['--add-dir', '/tmp/x',- '--model', 'gemini-3.1-pro-high',+ // The suffixed id splits into base + `--effort` (equivalent invocation).+ '--model', 'gemini-3.1-pro', '--effort', 'high','--dangerously-skip-permissions','--print',]);diff --git a/server/services/threejsModels/db.js b/server/services/threejsModels/db.jsindex a331dfe244..901ab98450 100644--- a/server/services/threejsModels/db.js+++ b/server/services/threejsModels/db.js@@ -63,6 +63,10 @@ export async function createModel(input) {prompt: input.prompt || '',providerId: input.providerId,model: input.model || null,+ // Reasoning-effort override for effort-capable providers. Additive JSON+ // field — records written before this shipped simply read back `undefined`,+ // which every consumer treats the same as "no override".+ effort: input.effort || null,status: 'draft',spec: null,error: null,diff --git a/server/services/threejsModels/index.js b/server/services/threejsModels/index.jsindex aa8bed7f9f..e629a41f28 100644--- a/server/services/threejsModels/index.js+++ b/server/services/threejsModels/index.js@@ -65,6 +65,7 @@ async function executeGeneration({operationId,provider,requestedModel,+ requestedEffort,sourcePath,prompt,}) {@@ -72,6 +73,9 @@ async function executeGeneration({const result = await runPromptThroughProvider({provider,model: requestedModel || undefined,+ // No-op for API providers and for CLI/TUI providers with no effort+ // control — runPromptThroughProvider clamps/drops it per provider.+ effort: requestedEffort || undefined,prompt,source: 'threejs-model-generation',// CLI/TUI agents only need the gallery image and JSON contract. Keep@@ -134,6 +138,7 @@ export async function createModel(input) {return startGeneration(created.id, {providerId: input.providerId,model: input.model,+ effort: input.effort,prompt: input.prompt,});}@@ -141,6 +146,7 @@ export async function createModel(input) {export async function startGeneration(id, {providerId,model,+ effort,prompt,feedback = '',} = {}) {@@ -160,6 +166,9 @@ export async function startGeneration(id, {const operationId = randomUUID();const startedAt = new Date().toISOString();const effectivePrompt = prompt ?? current.prompt ?? '';+ // Absent (`undefined`) keeps whatever the record already had; an explicit+ // `null` — what the picker's "Default effort" choice sends — clears it.+ const effectiveEffort = effort === undefined ? (current.effort || null) : (effort || null);const generationPrompt = buildThreejsGenerationPrompt({sourcePath,name: current.name,@@ -176,6 +185,7 @@ export async function startGeneration(id, {prompt: effectivePrompt,providerId: provider.id,model: model || provider.defaultModel || null,+ effort: effectiveEffort,status: 'generating',error: null,generationOperationId: operationId,@@ -186,6 +196,7 @@ export async function startGeneration(id, {status: 'running',providerId: provider.id,model: model || provider.defaultModel || null,+ effort: effectiveEffort,feedback: feedback || null,startedAt,completedAt: null,@@ -203,6 +214,7 @@ export async function startGeneration(id, {operationId,provider,requestedModel: model,+ requestedEffort: effectiveEffort,sourcePath,prompt: generationPrompt,});diff --git a/server/services/threejsModels/index.test.js b/server/services/threejsModels/index.test.jsindex 200fcfeba9..f45064579e 100644--- a/server/services/threejsModels/index.test.js+++ b/server/services/threejsModels/index.test.js@@ -184,4 +184,81 @@ describe('Three.js model generation orchestration', () => {prompt: expect.stringContaining('/mock/data/images/example.png'),}));});++ describe('effort threading', () => {+ // A CLI provider whose CLI has an effort knob (`agy --effort <level>`).+ const agyProvider = {+ id: 'antigravity-cli',+ name: 'Antigravity',+ type: 'cli',+ enabled: true,+ command: 'agy',+ };++ const primeRecord = (overrides = {}) => {+ let current = {+ id: 'threejs-effort',+ name: 'Example Beacon',+ sourceImage: { filename: 'example.png' },+ providerId: 'antigravity-cli',+ model: 'gemini-3.6-flash',+ prompt: '',+ status: 'draft',+ spec: null,+ runs: [],+ ...overrides,+ };+ store.getModel.mockResolvedValue(current);+ store.mutateModel.mockImplementation(async (_id, mutate) => {+ const next = mutate(current);+ if (next) current = next;+ return current;+ });+ runPromptThroughProvider.mockResolvedValue({+ text: JSON.stringify(spec),+ runId: 'run-effort',+ provider: { id: 'antigravity-cli' },+ model: 'gemini-3.6-flash',+ });+ return () => current;+ };++ it('forwards the selected effort to the prompt runner and persists it', async () => {+ getProviderById.mockResolvedValue(agyProvider);+ const read = primeRecord();++ await startGeneration('threejs-effort', {+ providerId: 'antigravity-cli',+ model: 'gemini-3.6-flash',+ effort: 'high',+ });++ await vi.waitFor(() => expect(read().status).toBe('ready'));+ expect(runPromptThroughProvider).toHaveBeenCalledWith(expect.objectContaining({ effort: 'high' }));+ expect(read().effort).toBe('high');+ expect(read().runs.at(-1)).toMatchObject({ effort: 'high' });+ });++ it('keeps the stored effort when the caller omits the key entirely', async () => {+ getProviderById.mockResolvedValue(agyProvider);+ const read = primeRecord({ effort: 'medium' });++ await startGeneration('threejs-effort', { providerId: 'antigravity-cli' });++ await vi.waitFor(() => expect(read().status).toBe('ready'));+ expect(runPromptThroughProvider).toHaveBeenCalledWith(expect.objectContaining({ effort: 'medium' }));+ expect(read().effort).toBe('medium');+ });++ it('clears the stored effort on an explicit null (the picker\'s "Default effort")', async () => {+ getProviderById.mockResolvedValue(agyProvider);+ const read = primeRecord({ effort: 'medium' });++ await startGeneration('threejs-effort', { providerId: 'antigravity-cli', effort: null });++ await vi.waitFor(() => expect(read().status).toBe('ready'));+ expect(runPromptThroughProvider).toHaveBeenCalledWith(expect.objectContaining({ effort: undefined }));+ expect(read().effort).toBeNull();+ });+ });});