Skip to content

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

feat(providers): thread --model and --effort through to the Antigravity CLI

[._.]/ Adam Eivyd7189140910f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7277ae3270..8e17a0093b 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -63,3 +63,11 @@
## Layered Intelligence
- **[issue-3085] The self-improvement loop can now see whether its approved proposals actually get delivered, not just whether its agent runs finish.** The `cosMetrics` block it reasons over reported per-task-type run success — "did the agent's task complete?" — and nothing about delivery, so a 90% run rate sat there looking healthy beside a pipeline that had landed none of ten approved proposals. That same block now carries a `delivery` figure (approved, delivered, and the current delivery rate) plus a per-scope breakdown, so the two numbers are read side by side. The rate is reported as unknown rather than 0% until something has actually been approved — a loop with no track record shouldn't read as a loop that fails everything.
+
+## Antigravity model and effort selection
+
+- **The Antigravity CLI (`agy`) can now be given a model and a thinking effort per task, the same as Claude Code and Codex.** `agy` grew session-scoped `--model` and `--effort` flags; PortOS had been treating it as a provider with neither, so it silently stripped any `--model` you configured and hid the effort picker entirely. The CoS task form, scheduled-task settings, pipeline stage config, Jobs tab, and the resume-agent dialog now all offer both for Antigravity providers — CLI and TUI alike.
+- Effort for `agy` is `low`/`medium`/`high`. An effort saved against a Claude or Codex provider clamps down to the nearest level `agy` accepts when you switch a task's provider (`max` and `xhigh` become `high`, `minimal` becomes `low`) instead of being dropped, so switching providers doesn't silently reset the setting.
+- The model list comes from `agy models` — click Refresh Models on the AI Providers page and it pulls whatever your installed binary actually offers, rather than a list baked into PortOS that goes stale. Existing installs get the shipped catalog added automatically on first read; a model list you'd customized yourself is left alone.
+- Leaving the model unset keeps the previous behavior exactly: no `--model` flag is passed and `agy` uses its own configured default. Nothing changes for existing tasks and schedules until you pick a model.
+- A `--model` you'd hard-coded into the provider's own arguments now survives (it used to be stripped) and takes precedence over the per-task selection. The legacy Gemini-CLI spellings `agy` still rejects (`-m`, `--output-format`, `--yolo`) are stripped as before.
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsx
index ced7ab4b6d..580446f83e 100644
--- a/client/src/pages/AIProviders.jsx
+++ b/client/src/pages/AIProviders.jsx
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
import toast from '../components/ui/Toast';
import * as api from '../services/api';
import socket from '../services/socket';
-import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isOllamaBackedProvider, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow } from '../utils/providers';
+import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isOllamaBackedProvider, isAntigravityProvider, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow } from '../utils/providers';
import useLocalModels from '../hooks/useLocalModels';
import EmptyState from '../components/EmptyState';
import {
@@ -161,12 +161,19 @@ export default function AIProviders() {
if (isOllamaBackedProvider(provider)) {
return true;
}
+ // Antigravity (`agy`) exposes a per-session `--model` flag and an
+ // `agy models` catalog, so BOTH its CLI and TUI providers refresh (the
+ // server has a type==='tui' branch for it) — checked before the generic
+ // TUI gate, same as Claude Ollama above.
+ if (isAntigravityProvider(provider)) {
+ return true;
+ }
if (isTuiProvider(provider)) {
return false;
}
- // Antigravity/Gemini/Grok Build CLIs use their own local model configuration
- // (no PortOS model list to refresh — same as the configured-default sentinel).
- if (provider.type === 'cli' && (provider.command === 'agy' || provider.command === 'gemini' || provider.command === 'grok')) {
+ // Gemini/Grok Build CLIs use their own local model configuration (no PortOS
+ // model list to refresh — same as the configured-default sentinel).
+ if (provider.type === 'cli' && (provider.command === 'gemini' || provider.command === 'grok')) {
return false;
}
// All other providers support refresh (API and CLI)
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 9405126a93..dd65955809 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -81,6 +81,22 @@ export const isKimiProvider = (provider) => {
return id === 'kimi-cli' || id === 'kimi-tui' || commandBasename(provider?.command) === 'kimi';
};
+/**
+ * True when a provider is Antigravity-flavored — the shipped
+ * `antigravity-cli`/`antigravity-tui` ids or any provider whose launch command
+ * basename is `agy`/`antigravity` (path/exe tolerant). MIRROR of
+ * `isAntigravityProvider` in server/lib/providerModels.js — keep in lockstep.
+ * @param {{id?:string, command?:string}|null|undefined} provider
+ * @returns {boolean}
+ */
+export const isAntigravityProvider = (provider) => {
+ if (!provider) return false;
+ const id = String(provider.id || '').toLowerCase();
+ if (id === 'antigravity-cli' || id === 'antigravity-tui') return true;
+ const base = commandBasename(provider.command);
+ return base === 'agy' || base === 'antigravity';
+};
+
export const knownProviderContextWindow = (provider) => {
if (!isProcessProvider(provider)) return null;
const id = String(provider?.id || '').toLowerCase();
@@ -117,25 +133,28 @@ export const filterSelectableModels = (models) =>
/**
* Reasoning-effort levels per effort-capable CLI — MIRROR of
- * `CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `effortLevelsForProvider` in
- * server/lib/providerModels.js; keep in lockstep. Claude Code takes
- * `--effort <level>`, Codex takes `-c model_reasoning_effort=<level>`.
+ * `CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_EFFORT_LEVELS` /
+ * `effortLevelsForProvider` in server/lib/providerModels.js; keep in lockstep.
+ * Claude Code and agy take `--effort <level>`, Codex takes
+ * `-c model_reasoning_effort=<level>`.
*/
export const CLAUDE_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
export const CODEX_EFFORT_LEVELS = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra']);
+export const ANTIGRAVITY_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high']);
/**
* The effort levels a provider's CLI accepts, or null when the provider has no
- * effort control (antigravity, opencode, grok, HTTP API providers). Keyed on
- * the launch command basename plus the shipped provider ids, so path-configured
- * or renamed claude/codex providers still qualify. Drives the "Effort
- * (optional)" select in task/schedule forms.
+ * 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
* @returns {readonly string[]|null}
*/
export const effortLevelsForProvider = (provider) => {
if (!provider) return null;
if (isCodexProvider(provider)) return CODEX_EFFORT_LEVELS;
+ if (isAntigravityProvider(provider)) return ANTIGRAVITY_EFFORT_LEVELS;
const id = String(provider.id || '').toLowerCase();
if (id.startsWith('claude-code') || commandBasename(provider.command) === 'claude') return CLAUDE_EFFORT_LEVELS;
return null;
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index 7f42d02c82..070f78bf3e 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -34,6 +34,11 @@ import {
isOllamaBackedProvider,
isGrokBuildCli,
isKimiProvider,
+ isAntigravityProvider,
+ effortLevelsForProvider,
+ CLAUDE_EFFORT_LEVELS,
+ CODEX_EFFORT_LEVELS,
+ ANTIGRAVITY_EFFORT_LEVELS,
isConfiguredDefaultModel,
isLocalEndpoint,
enabledApiProviderFilter,
@@ -41,6 +46,43 @@ import {
getProviderTimeout,
} from './providers.js';
import { PROVIDER_TYPES as SERVER_PROVIDER_TYPES } from '../../../server/lib/aiToolkit/constants.js';
+import {
+ effortLevelsForProvider as serverEffortLevelsForProvider,
+ isAntigravityProvider as serverIsAntigravityProvider,
+} from '../../../server/lib/providerModels.js';
+
+// These drive the Effort/model pickers in the CoS task + schedule forms. The
+// client copy is a hand-mirror of server/lib/providerModels.js (the client can't
+// import server modules at runtime), so pin both sides together here.
+describe('effortLevelsForProvider (server mirror)', () => {
+ const CASES = [
+ ['antigravity CLI', { id: 'antigravity-cli', command: 'agy' }, ANTIGRAVITY_EFFORT_LEVELS],
+ ['antigravity TUI', { id: 'antigravity-tui' }, ANTIGRAVITY_EFFORT_LEVELS],
+ ['path-configured agy', { id: 'custom', command: '/Users/x/.local/bin/agy' }, ANTIGRAVITY_EFFORT_LEVELS],
+ ['claude code', { id: 'claude-code', command: 'claude' }, CLAUDE_EFFORT_LEVELS],
+ ['codex', { id: 'codex', command: 'codex' }, CODEX_EFFORT_LEVELS],
+ ['grok (no effort control)', { id: 'grok-cli', command: 'grok' }, null],
+ ['blank command is not claude', { id: 'ollama' }, null],
+ ];
+
+ it.each(CASES)('%s', (_label, provider, expected) => {
+ expect(effortLevelsForProvider(provider)).toEqual(expected);
+ expect(serverEffortLevelsForProvider(provider)).toEqual(expected);
+ });
+});
+
+describe('isAntigravityProvider (server mirror)', () => {
+ it.each([
+ [{ id: 'antigravity-cli' }, true],
+ [{ id: 'antigravity-tui' }, true],
+ [{ id: 'custom', command: 'agy.exe' }, true],
+ [{ id: 'claude-code', command: 'claude' }, false],
+ [null, false],
+ ])('%o → %s', (provider, expected) => {
+ expect(isAntigravityProvider(provider)).toBe(expected);
+ expect(serverIsAntigravityProvider(provider)).toBe(expected);
+ });
+});
describe('PROVIDER_TYPES', () => {
it('exposes the three provider-type values', () => {
diff --git a/data.reference/providers.json b/data.reference/providers.json
index 171e10af40..4e37e9dd3e 100644
--- a/data.reference/providers.json
+++ b/data.reference/providers.json
@@ -75,7 +75,7 @@
"type": "cli",
"command": "agy",
"args": ["--print", "--dangerously-skip-permissions"],
- "models": ["antigravity-configured-default"],
+ "models": ["antigravity-configured-default","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.5-flash-high","gemini-3.5-flash-medium","gemini-3.5-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"],
"defaultModel": "antigravity-configured-default",
"lightModel": "antigravity-configured-default",
"mediumModel": "antigravity-configured-default",
@@ -197,7 +197,7 @@
"type": "tui",
"command": "agy",
"args": ["--dangerously-skip-permissions"],
- "models": ["antigravity-configured-default"],
+ "models": ["antigravity-configured-default","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.5-flash-high","gemini-3.5-flash-medium","gemini-3.5-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"],
"defaultModel": "antigravity-configured-default",
"lightModel": "antigravity-configured-default",
"mediumModel": "antigravity-configured-default",
diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.json
index 169f015c0f..f208b7853e 100644
--- a/server/lib/aiToolkit/defaults/providers.sample.json
+++ b/server/lib/aiToolkit/defaults/providers.sample.json
@@ -190,7 +190,7 @@
"type": "tui",
"command": "agy",
"args": ["--dangerously-skip-permissions"],
- "models": ["antigravity-configured-default"],
+ "models": ["antigravity-configured-default","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.5-flash-high","gemini-3.5-flash-medium","gemini-3.5-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"],
"defaultModel": "antigravity-configured-default",
"lightModel": "antigravity-configured-default",
"mediumModel": "antigravity-configured-default",
@@ -209,7 +209,7 @@
"type": "cli",
"command": "agy",
"args": ["--print", "--dangerously-skip-permissions"],
- "models": ["antigravity-configured-default"],
+ "models": ["antigravity-configured-default","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.5-flash-high","gemini-3.5-flash-medium","gemini-3.5-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"],
"defaultModel": "antigravity-configured-default",
"lightModel": "antigravity-configured-default",
"mediumModel": "antigravity-configured-default",
diff --git a/server/lib/aiToolkit/internal/antigravity.js b/server/lib/aiToolkit/internal/antigravity.js
index 39d34f1126..75a6eecf18 100644
--- a/server/lib/aiToolkit/internal/antigravity.js
+++ b/server/lib/aiToolkit/internal/antigravity.js
@@ -25,18 +25,24 @@ export function isAntigravityCliProvider(provider) {
return provider?.id === ANTIGRAVITY_CLI_ID || isAntigravityCommand(provider?.command);
}
+// `--yolo` is a Gemini-CLI flag agy never accepted, and `-m` /
+// `--output-format` / `-o` are legacy Gemini-CLI spellings agy still rejects (it
+// takes the long `--model` only, and has no output-format flag). The LONG
+// `--model` is deliberately NOT stripped — agy documents it as a per-session
+// flag, so a user-baked pin is a real selection to preserve. Keep in sync with
+// server/lib/antigravity.js#stripAntigravityUnsupportedArgs.
export function stripAntigravityUnsupportedArgs(args = []) {
const out = [];
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === '--yolo') continue;
- if (arg === '--model' || arg === '-m' || arg === '--output-format' || arg === '-o') {
+ if (arg === '-m' || arg === '--output-format' || arg === '-o') {
i += 1;
continue;
}
if (
typeof arg === 'string'
- && (arg.startsWith('--model=') || arg.startsWith('-m=') || arg.startsWith('--output-format=') || arg.startsWith('-o='))
+ && (arg.startsWith('-m=') || arg.startsWith('--output-format=') || arg.startsWith('-o='))
) {
continue;
}
@@ -49,7 +55,11 @@ export function stripAntigravityUnsupportedArgs(args = []) {
// NOT read stdin. So the print flag must be the FINAL token (a marker); the host
// runner splices the prompt in right after it at spawn time. Keep in sync with
// server/lib/antigravity.js#ensureAntigravityPrintArgs — the host overrides the
-// runner (setCliRunner), so the prompt injection itself lives host-side.
+// runner (setCliRunner), so the prompt injection itself lives host-side — as
+// does per-run `--model` / `--effort` injection (it needs the shared
+// providerModels helpers this vendored copy must not import). These two
+// builders are only used by the legacy-Gemini→agy provider migration, which has
+// no per-run model to thread.
const ANTIGRAVITY_PRINT_FLAGS = ['--print', '-p', '--prompt'];
export function ensureAntigravityPrintArgs(args = []) {
diff --git a/server/lib/aiToolkit/providers.js b/server/lib/aiToolkit/providers.js
index 31cbd498a5..6b3b4fb408 100644
--- a/server/lib/aiToolkit/providers.js
+++ b/server/lib/aiToolkit/providers.js
@@ -12,6 +12,7 @@ import {
ANTIGRAVITY_TUI_ID,
ensureAntigravityPrintArgs,
ensureAntigravityTuiArgs,
+ isAntigravityCommand,
LEGACY_GEMINI_CLI_ID,
LEGACY_GEMINI_TUI_ID,
} from './internal/antigravity.js';
@@ -160,6 +161,30 @@ const CODEX_MODEL_DEFAULTS = {
heavyModel: 'gpt-5.6-sol',
};
const ANTIGRAVITY_MODEL_KEYS = ['defaultModel', 'lightModel', 'mediumModel', 'heavyModel'];
+// agy exposes a per-session `--model` flag and lists its catalog via
+// `agy models`. This is the shipped fallback list (agy 2026-07) used to seed a
+// fresh install and when the live `agy models` probe can't run; the AI Providers
+// "Refresh models" button replaces it with whatever the installed binary
+// reports, which is the authoritative list for that user's plan.
+const ANTIGRAVITY_MODELS = [
+ 'gemini-3.6-flash-high',
+ 'gemini-3.6-flash-medium',
+ 'gemini-3.6-flash-low',
+ 'gemini-3.5-flash-high',
+ 'gemini-3.5-flash-medium',
+ 'gemini-3.5-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',
+];
+// The sentinel stays FIRST in the list and remains the value of every
+// `*Model` key: an install that never picks a model keeps agy's own configured
+// default (no `--model` flag), exactly as before. The real ids ride alongside so
+// the task/schedule model pickers (which filter the sentinel out) can offer a
+// per-run override.
+const ANTIGRAVITY_MODEL_CATALOG = [ANTIGRAVITY_CONFIGURED_DEFAULT, ...ANTIGRAVITY_MODELS];
const CODEX_CONTEXT_WINDOW = 1_000_000;
const GEMINI_CONTEXT_WINDOW = 1_048_576;
const STALE_GENERIC_CONTEXT_WINDOW = 128_000;
@@ -225,7 +250,7 @@ function migrateAntigravityProviders(data) {
args: mapping.type === 'cli'
? ensureAntigravityPrintArgs(legacy.args || [])
: ensureAntigravityTuiArgs(legacy.args || []),
- models: [ANTIGRAVITY_CONFIGURED_DEFAULT],
+ models: [...ANTIGRAVITY_MODEL_CATALOG],
timeout: legacy.timeout || mapping.timeout,
envVars,
};
@@ -255,6 +280,31 @@ function migrateAntigravityProviders(data) {
return changed;
}
+// Installs that already migrated to `agy` carry the sentinel-only model list
+// from before agy grew a `--model` flag. Widen it to the shipped catalog so the
+// task/schedule pickers have something to offer. Guarded on "sentinel-only" so a
+// user's own list (or one already refreshed from `agy models`) is never
+// overwritten, and the `*Model` keys are left alone so run behavior is unchanged
+// until the user actually picks a model.
+function migrateAntigravityModelCatalog(data) {
+ if (!data?.providers) return false;
+ let changed = false;
+ for (const provider of Object.values(data.providers)) {
+ const isAntigravityProcessProvider = (provider?.id === ANTIGRAVITY_CLI_ID || provider?.id === ANTIGRAVITY_TUI_ID)
+ && (provider?.type === 'cli' || provider?.type === 'tui');
+ if (!isAntigravityProcessProvider) continue;
+
+ const isSentinelOnly = Array.isArray(provider.models)
+ && provider.models.length === 1
+ && provider.models[0] === ANTIGRAVITY_CONFIGURED_DEFAULT;
+ if (!isSentinelOnly) continue;
+
+ provider.models = [...ANTIGRAVITY_MODEL_CATALOG];
+ changed = true;
+ }
+ return changed;
+}
+
function migrateProviderContextWindows(data) {
if (!data?.providers) return false;
let changed = false;
@@ -367,11 +417,13 @@ export function createProviderService(config = {}) {
const migratedCodex = migrateCodexProvider(data);
const migratedAntigravity = migrateAntigravityProviders(data);
+ const migratedAntigravityModels = migrateAntigravityModelCatalog(data);
const migratedContextWindows = migrateProviderContextWindows(data);
- if (migratedCodex || migratedAntigravity || migratedContextWindows) {
+ if (migratedCodex || migratedAntigravity || migratedAntigravityModels || migratedContextWindows) {
await atomicWrite(PROVIDERS_PATH, data);
if (migratedCodex) console.log('🔧 Migrated Codex providers to the selectable GPT-5.6 model tiers');
if (migratedAntigravity) console.log('🔧 Migrated Gemini provider config to Antigravity CLI (agy)');
+ if (migratedAntigravityModels) console.log('🔧 Migrated Antigravity providers to the selectable agy model catalog');
if (migratedContextWindows) console.log('🔧 Migrated provider context windows to current canonical values');
}
@@ -678,6 +730,10 @@ export function createProviderService(config = {}) {
// CLI/config), but the Claude-Ollama TUI variant still needs its
// tool-use-capable Ollama model list pulled live, same as the CLI one.
models = await this._fetchOllamaToolCapableModels(provider);
+ } else if (provider.type === 'tui' && (provider.id === ANTIGRAVITY_TUI_ID || isAntigravityCommand(provider.command))) {
+ // Same exception for the Antigravity TUI: `agy --model` applies to the
+ // interactive session too, so its catalog must refresh like the CLI's.
+ models = await this._fetchAntigravityModels(provider);
}
} catch (error) {
console.error(`Failed to refresh models for ${provider.name}:`, error.message);
@@ -760,7 +816,7 @@ export function createProviderService(config = {}) {
}
if (providerName.includes('antigravity') || provider.command === 'agy') {
- return [ANTIGRAVITY_CONFIGURED_DEFAULT];
+ return await this._fetchAntigravityModels(provider);
}
if (providerName.includes('gemini') || provider.command === 'gemini') {
@@ -770,6 +826,44 @@ export function createProviderService(config = {}) {
throw new Error('Model refresh not supported for this CLI provider');
},
+ /**
+ * agy ships an `agy models` subcommand that prints one model id per line —
+ * the authoritative catalog for this user's plan and binary version, which
+ * a hardcoded list can only go stale against. Falls back to the shipped
+ * catalog when the binary isn't runnable (not installed yet, PATH doesn't
+ * resolve under the service env) so a refresh never empties a working
+ * provider's model list.
+ *
+ * The sentinel is always re-prepended: it is what keeps "use agy's own
+ * configured default" selectable after a refresh.
+ */
+ async _fetchAntigravityModels(provider) {
+ const bin = provider?.command || 'agy';
+ const { command, args } = prepareWindowsSafeSpawn(bin, ['models']);
+ const pending = execFileAsync(command, args, {
+ timeout: 15000,
+ env: { ...process.env, ...provider?.envVars },
+ });
+ // Close the child's stdin immediately. `agy models` blocks on an open
+ // stdin and prints NOTHING until it closes — with execFile's default pipe
+ // that's a full 15s hang ending in SIGTERM and an empty catalog. (execFile
+ // ignores an `stdio` option, so ending the stream is the way to do it.)
+ pending.child?.stdin?.end();
+ const { stdout } = await pending.catch(() => ({ stdout: '' }));
+
+ const listed = stdout
+ .split(/\r?\n/)
+ .map(line => line.trim())
+ // Drop blanks, banner/status lines, and anything that isn't a bare id.
+ .filter(line => /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(line) && line !== ANTIGRAVITY_CONFIGURED_DEFAULT);
+
+ if (listed.length === 0) {
+ console.error(`⚠️ '${bin} models' returned no model ids — keeping the shipped Antigravity catalog`);
+ return [...ANTIGRAVITY_MODEL_CATALOG];
+ }
+ return [ANTIGRAVITY_CONFIGURED_DEFAULT, ...new Set(listed)];
+ },
+
async _fetchOllamaToolCapableModels(provider) {
const base = ollamaBaseFromProvider(provider);
const res = await fetch(`${base}/api/tags`, { signal: AbortSignal.timeout(8000) }).catch(() => null);
diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.js
index b3d1575dd7..a721606471 100644
--- a/server/lib/aiToolkit/providers.test.js
+++ b/server/lib/aiToolkit/providers.test.js
@@ -558,6 +558,57 @@ describe('Provider Service', () => {
expect(antigravityTui.command).toBe('agy');
expect(antigravityTui.args).toEqual(['--dangerously-skip-permissions']);
expect(antigravityTui.contextWindow).toBe(1048576);
+ // agy takes a per-session --model, so the migrated provider ships the
+ // selectable catalog alongside the sentinel.
+ expect(antigravity.models[0]).toBe('antigravity-configured-default');
+ expect(antigravity.models).toContain('gemini-3.1-pro-high');
+ });
+
+ it('widens a sentinel-only Antigravity model list to the selectable catalog', async () => {
+ await writeProvidersFile({
+ activeProvider: 'antigravity-cli',
+ providers: {
+ 'antigravity-cli': {
+ id: 'antigravity-cli',
+ name: 'Antigravity CLI',
+ type: 'cli',
+ command: 'agy',
+ contextWindow: 1048576,
+ models: ['antigravity-configured-default'],
+ defaultModel: 'antigravity-configured-default',
+ lightModel: 'antigravity-configured-default'
+ }
+ }
+ });
+
+ const antigravity = await providerService.getProviderById('antigravity-cli');
+ expect(antigravity.models.length).toBeGreaterThan(1);
+ expect(antigravity.models[0]).toBe('antigravity-configured-default');
+ expect(antigravity.models).toContain('claude-sonnet-4-6');
+ // The *Model keys are untouched: an install that never picks a model keeps
+ // agy's own configured default (no --model flag), exactly as before.
+ expect(antigravity.defaultModel).toBe('antigravity-configured-default');
+ expect(antigravity.lightModel).toBe('antigravity-configured-default');
+ });
+
+ it('leaves a user-customized Antigravity model list alone', async () => {
+ await writeProvidersFile({
+ activeProvider: 'antigravity-cli',
+ providers: {
+ 'antigravity-cli': {
+ id: 'antigravity-cli',
+ name: 'Antigravity CLI',
+ type: 'cli',
+ command: 'agy',
+ contextWindow: 1048576,
+ models: ['antigravity-configured-default', 'my-tuned-model'],
+ defaultModel: 'my-tuned-model'
+ }
+ }
+ });
+
+ const antigravity = await providerService.getProviderById('antigravity-cli');
+ expect(antigravity.models).toEqual(['antigravity-configured-default', 'my-tuned-model']);
});
});
diff --git a/server/lib/antigravity.js b/server/lib/antigravity.js
index ced580ff25..37352b347e 100644
--- a/server/lib/antigravity.js
+++ b/server/lib/antigravity.js
@@ -1,4 +1,4 @@
-import { commandBasename } from './providerModels.js';
+import { buildEffortArgs, commandBasename, hasModelFlag, resolveCliModel, stripBrokenModelFlags } from './providerModels.js';
export const ANTIGRAVITY_CLI_ID = 'antigravity-cli';
export const ANTIGRAVITY_TUI_ID = 'antigravity-tui';
@@ -27,11 +27,43 @@ export function isAntigravityCliProvider(provider) {
// prompt spliced in right after it at spawn time by prepareAntigravityPrompt.
export const ANTIGRAVITY_PRINT_FLAGS = ['--print', '-p', '--prompt'];
-export function ensureAntigravityPrintArgs(args = []) {
+/**
+ * Append `--model <id>` / `--effort <level>` to an agy argv when the caller has
+ * a per-run override and the provider args don't already pin one. `agy --help`
+ * documents both as session-scoped flags ("Model for the current CLI session",
+ * "Reasoning effort for the current CLI session (low|medium|high)"), so PortOS
+ * threads the task's model/effort selection through exactly like it does for
+ * claude. Configured-default sentinels resolve to null → no `--model`, i.e. agy
+ * keeps using whatever model its own config selects.
+ *
+ * Deliberately NOT Bedrock-mapped: agy offers `claude-sonnet-4-6` /
+ * `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.
+ */
+function appendAntigravityModelAndEffort(args, { model = null, effort = null } = {}) {
+ // 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));
+ return out;
+}
+
+/**
+ * @param {string[]} [args] - the provider's saved argv
+ * @param {{model?:string|null, effort?:string|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
// trailing marker. (PortOS always supplies the prompt itself, so a
// user-configured print flag never carries a prompt value to preserve.)
- const out = stripAntigravityUnsupportedArgs(args).filter((arg) => !ANTIGRAVITY_PRINT_FLAGS.includes(arg));
+ const stripped = stripAntigravityUnsupportedArgs(args).filter((arg) => !ANTIGRAVITY_PRINT_FLAGS.includes(arg));
+ const out = appendAntigravityModelAndEffort(stripped, overrides);
if (!out.includes('--dangerously-skip-permissions') && !out.includes('--sandbox')) {
out.push('--dangerously-skip-permissions');
}
@@ -78,26 +110,36 @@ export function prepareAntigravityPrompt(args = [], prompt = '') {
// argv value. So, unlike the CLI path, there is no print flag to accidentally
// swallow --dangerously-skip-permissions: the flag stays a real boolean and the
// permission auto-approval actually takes effect. Do NOT add --print here.
-export function ensureAntigravityTuiArgs(args = []) {
- const out = stripAntigravityUnsupportedArgs(args);
+/**
+ * @param {string[]} [args] - the provider's saved argv
+ * @param {{model?:string|null, effort?:string|null}} [overrides] - per-run selections
+ */
+export function ensureAntigravityTuiArgs(args = [], overrides = {}) {
+ const out = appendAntigravityModelAndEffort(stripAntigravityUnsupportedArgs(args), overrides);
if (!out.includes('--dangerously-skip-permissions') && !out.includes('--sandbox')) {
out.push('--dangerously-skip-permissions');
}
return out;
}
+// `--yolo` is a Gemini-CLI flag agy never accepted, and `-m` / `--output-format`
+// / `-o` are legacy Gemini-CLI spellings agy still rejects (it takes the long
+// `--model` only, and has no output-format flag). The LONG `--model` is
+// deliberately NOT stripped: agy documents it as a per-session flag, so a
+// user-baked pin is a real selection to preserve — and `hasModelFlag` sees it,
+// which is what suppresses PortOS's own injected `--model`.
export function stripAntigravityUnsupportedArgs(args = []) {
const out = [];
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === '--yolo') continue;
- if (arg === '--model' || arg === '-m' || arg === '--output-format' || arg === '-o') {
+ if (arg === '-m' || arg === '--output-format' || arg === '-o') {
i += 1;
continue;
}
if (
typeof arg === 'string'
- && (arg.startsWith('--model=') || arg.startsWith('-m=') || arg.startsWith('--output-format=') || arg.startsWith('-o='))
+ && (arg.startsWith('-m=') || arg.startsWith('--output-format=') || arg.startsWith('-o='))
) {
continue;
}
diff --git a/server/lib/antigravity.test.js b/server/lib/antigravity.test.js
index 649d7ca895..0faa3244ed 100644
--- a/server/lib/antigravity.test.js
+++ b/server/lib/antigravity.test.js
@@ -42,20 +42,25 @@ describe('stripAntigravityUnsupportedArgs', () => {
expect(stripAntigravityUnsupportedArgs(['--yolo'])).toEqual([]);
});
- it('drops the space-separated model/output-format flag AND its value', () => {
+ it('drops the space-separated legacy-Gemini flag AND its value', () => {
expect(stripAntigravityUnsupportedArgs(['-m', 'gemini-2.5-pro'])).toEqual([]);
- expect(stripAntigravityUnsupportedArgs(['--model', 'x', 'keep'])).toEqual(['keep']);
expect(stripAntigravityUnsupportedArgs(['--output-format', 'text'])).toEqual([]);
expect(stripAntigravityUnsupportedArgs(['-o', 'json'])).toEqual([]);
});
- it('drops the equals-form model/output-format flag', () => {
- expect(stripAntigravityUnsupportedArgs(['--model=x'])).toEqual([]);
+ it('drops the equals-form legacy-Gemini flag', () => {
expect(stripAntigravityUnsupportedArgs(['-m=x'])).toEqual([]);
expect(stripAntigravityUnsupportedArgs(['--output-format=text'])).toEqual([]);
expect(stripAntigravityUnsupportedArgs(['-o=json'])).toEqual([]);
});
+ // agy grew a per-session `--model` flag, so a long-form pin is a real user
+ // selection to keep — only the legacy `-m` spelling it never accepted goes.
+ it('preserves a long-form --model pin (both spellings)', () => {
+ expect(stripAntigravityUnsupportedArgs(['--model', 'x', 'keep'])).toEqual(['--model', 'x', 'keep']);
+ expect(stripAntigravityUnsupportedArgs(['--model=x'])).toEqual(['--model=x']);
+ });
+
it('preserves unrelated flags', () => {
expect(stripAntigravityUnsupportedArgs(['--print', '--foo', 'bar'])).toEqual(['--print', '--foo', 'bar']);
});
@@ -85,6 +90,28 @@ describe('ensureAntigravityPrintArgs', () => {
.toEqual(['--dangerously-skip-permissions', '--print']);
});
+ // Per-run model/effort must land BEFORE the trailing --print marker, or agy
+ // would consume `--model` as the prompt text.
+ it('injects the per-run model and effort ahead of the trailing --print', () => {
+ expect(ensureAntigravityPrintArgs([], { model: 'claude-sonnet-4-6', effort: 'medium' }))
+ .toEqual(['--model', 'claude-sonnet-4-6', '--effort', 'medium', '--dangerously-skip-permissions', '--print']);
+ });
+
+ it('omits --model for the configured-default sentinel (agy keeps its own default)', () => {
+ expect(ensureAntigravityPrintArgs([], { model: 'antigravity-configured-default' }))
+ .toEqual(['--dangerously-skip-permissions', '--print']);
+ });
+
+ it('clamps an out-of-range effort to agy\'s top level', () => {
+ expect(ensureAntigravityPrintArgs([], { effort: 'max' }))
+ .toEqual(['--effort', 'high', '--dangerously-skip-permissions', '--print']);
+ });
+
+ it('drops a dangling --model rather than emitting it twice', () => {
+ expect(ensureAntigravityPrintArgs(['--model'], { model: 'gemini-3.1-pro-low' }))
+ .toEqual(['--model', 'gemini-3.1-pro-low', '--dangerously-skip-permissions', '--print']);
+ });
+
it('normalizes any pre-baked print flag (--print / -p / --prompt) to a single trailing --print', () => {
expect(ensureAntigravityPrintArgs(['--print'])).toEqual(['--dangerously-skip-permissions', '--print']);
expect(ensureAntigravityPrintArgs(['-p'])).toEqual(['--dangerously-skip-permissions', '--print']);
@@ -131,13 +158,23 @@ describe('prepareAntigravityPrompt', () => {
describe('ensureAntigravityTuiArgs', () => {
it('strips legacy flags and adds --dangerously-skip-permissions (no --print)', () => {
- expect(ensureAntigravityTuiArgs(['--yolo', '--model', 'gemini-2.5-pro']))
+ expect(ensureAntigravityTuiArgs(['--yolo', '-m', 'gemini-2.5-pro']))
.toEqual(['--dangerously-skip-permissions']);
});
it('respects an existing --sandbox', () => {
expect(ensureAntigravityTuiArgs(['--sandbox'])).toEqual(['--sandbox']);
});
+
+ it('appends the per-run model and effort', () => {
+ expect(ensureAntigravityTuiArgs([], { model: 'gemini-3.1-pro-high', effort: 'high' }))
+ .toEqual(['--model', 'gemini-3.1-pro-high', '--effort', 'high', '--dangerously-skip-permissions']);
+ });
+
+ it('lets a user-baked --model pin win over the per-run model', () => {
+ expect(ensureAntigravityTuiArgs(['--model', 'claude-sonnet-4-6'], { model: 'gemini-3.1-pro-high' }))
+ .toEqual(['--model', 'claude-sonnet-4-6', '--dangerously-skip-permissions']);
+ });
});
describe('ANTIGRAVITY_CONFIGURED_DEFAULT', () => {
diff --git a/server/lib/cliProviderArgs.js b/server/lib/cliProviderArgs.js
index 2c495fa702..8f84e336f4 100644
--- a/server/lib/cliProviderArgs.js
+++ b/server/lib/cliProviderArgs.js
@@ -11,14 +11,14 @@
*
* Each CLI reads its prompt from stdin under a different convention:
* - Codex: `codex exec -` (+ `--model` when not the sentinel)
- * - Antigravity: `agy --print` with prompt piped to stdin
+ * - Antigravity: `agy --print <prompt>` (argv value, not stdin; + `--model`)
* - Gemini CLI: legacy prompt piped to stdin (+ `-m <model>`)
* - Grok Build: `grok --prompt-file /dev/stdin` (+ `--model <id>`, see grok.js)
* - Kimi Code: `kimi --print --prompt <value>` (argv value, not stdin; see kimi.js)
* - Claude Code: `-p -` (+ `--model <id>`)
*/
-import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs } from './providerModels.js';
+import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs, 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';
@@ -64,10 +64,12 @@ export function buildCliArgs(provider) {
}
// Antigravity CLI (`agy`) replaces the old Gemini CLI for Google's coding
- // agent. Print mode is the headless one-shot interface; prompt text still
- // travels over stdin so large PortOS prompts do not hit OS argv limits.
+ // agent. Print mode is the headless one-shot interface; the prompt is spliced
+ // in as the trailing `--print` value at spawn time (see prepareCliPrompt).
+ // `--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);
+ return ensureAntigravityPrintArgs(baseArgs, { model: effectiveDefaultModel });
}
// Grok Build CLI (`grok`): headless one-shot. The prompt is delivered through
@@ -166,25 +168,7 @@ export function prepareCliPrompt(command, args, prompt) {
return prepareGrokPromptFile(args, prompt);
}
-// Strip dangling/empty `--model` / `-m` tokens (no value follows, or the
-// joined form has an empty value). Those would survive into the spawned
-// argv unchanged and cause the CLI to reject the invocation — see the
-// comment on hasModelFlag for the full reasoning. Pinned-with-value tokens
-// are preserved untouched so user-baked model selections still win.
-export function stripBrokenModelFlags(args) {
- if (!Array.isArray(args) || args.length === 0) return [];
- const out = [];
- for (let i = 0; i < args.length; i++) {
- const a = args[i];
- if (typeof a === 'string' && (a === '--model=' || a === '-m=')) {
- continue; // empty joined form
- }
- if (a === '--model' || a === '-m') {
- const next = args[i + 1];
- const hasValue = typeof next === 'string' && next.length > 0 && !next.startsWith('-');
- if (!hasValue) continue; // dangling separated form
- }
- out.push(a);
- }
- return out;
-}
+// Re-exported from providerModels.js (its home, next to `hasModelFlag`, so the
+// antigravity arg builders can share it without importing this module and
+// creating a cycle). Kept here for the existing importers of this module.
+export { stripBrokenModelFlags };
diff --git a/server/lib/providerModels.js b/server/lib/providerModels.js
index 87676fefe9..3b82954e5d 100644
--- a/server/lib/providerModels.js
+++ b/server/lib/providerModels.js
@@ -52,18 +52,24 @@ export function commandBasename(command) {
export const resolveCliModel = (model) => isConfiguredDefaultModel(model) ? null : (model || null);
// ---------------------------------------------------------------------------
-// Reasoning-effort levels — Claude Code (`--effort <level>`) and Codex
-// (`-c model_reasoning_effort=<level>`) both accept a per-invocation override
-// of how hard the model thinks. Value sets verified against claude CLI
-// v2.1.x (`--help`) and codex-cli 0.144 (config enum). Mirrored in
-// client/src/utils/providers.js — keep in sync.
+// Reasoning-effort levels — Claude Code (`--effort <level>`), Antigravity
+// (`--effort <level>`) and Codex (`-c model_reasoning_effort=<level>`) all
+// accept a per-invocation override of how hard the model thinks. Value sets
+// verified against claude CLI v2.1.x (`--help`), codex-cli 0.144 (config enum)
+// and agy (`--help`: "Reasoning effort for the current CLI session
+// (low|medium|high)"). Mirrored in client/src/utils/providers.js — keep in sync.
// ---------------------------------------------------------------------------
export const CLAUDE_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
export const CODEX_EFFORT_LEVELS = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra']);
+export const ANTIGRAVITY_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high']);
/** Union of every accepted effort value across effort-capable CLIs, low→high. */
-export const EFFORT_LEVELS = Object.freeze([...new Set([...CODEX_EFFORT_LEVELS, ...CLAUDE_EFFORT_LEVELS])]);
+export const EFFORT_LEVELS = Object.freeze([...new Set([
+ ...CODEX_EFFORT_LEVELS,
+ ...CLAUDE_EFFORT_LEVELS,
+ ...ANTIGRAVITY_EFFORT_LEVELS,
+])]);
/**
* True when a provider is codex-flavored — the shipped `codex`/`codex-tui`
@@ -121,11 +127,30 @@ export function isKimiProvider(provider) {
return id === 'kimi-cli' || id === 'kimi-tui' || commandBasename(provider?.command) === 'kimi';
}
+/**
+ * True when a provider is Antigravity-flavored — the shipped
+ * `antigravity-cli`/`antigravity-tui` ids or any provider whose launch command
+ * basename is `agy`/`antigravity` (path/exe tolerant). The provider-shaped
+ * companion to `isAntigravityCommand` in antigravity.js; lives here (rather
+ * than there) so `effortLevelsForProvider` can key on it without this
+ * dependency-light module importing a sibling. Mirrored in
+ * client/src/utils/providers.js — keep in lockstep.
+ * @param {{id?:string, command?:string}|null|undefined} provider
+ * @returns {boolean}
+ */
+export function isAntigravityProvider(provider) {
+ if (!provider) return false;
+ const id = String(provider.id || '').toLowerCase();
+ if (id === 'antigravity-cli' || id === 'antigravity-tui') return true;
+ const base = commandBasename(provider.command);
+ return base === 'agy' || base === 'antigravity';
+}
+
/**
* The effort levels a provider's CLI accepts, or null when the provider has no
- * effort control (antigravity, opencode, grok, HTTP API providers). Keyed on the
+ * 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 providers still qualify — same detection posture as
+ * renamed claude/codex/agy providers still qualify — same detection posture as
* `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.
@@ -135,19 +160,25 @@ export function isKimiProvider(provider) {
export function effortLevelsForProvider(provider) {
if (!provider) return null;
if (isCodexProvider(provider)) return CODEX_EFFORT_LEVELS;
+ if (isAntigravityProvider(provider)) return ANTIGRAVITY_EFFORT_LEVELS;
if (isClaudeProvider(provider)) return CLAUDE_EFFORT_LEVELS;
return null;
}
-// Codex-only values mapped to their nearest Claude equivalent, so an effort
-// saved against a codex pin survives a provider switch instead of vanishing.
-const EFFORT_CLAMP = Object.freeze({ minimal: 'low', ultra: 'max' });
+// Every effort value any CLI accepts, ordered weakest→strongest. The clamp
+// below walks this so an effort saved against one provider survives a switch to
+// a provider with a narrower ladder (agy tops out at `high`; claude has no
+// `minimal`/`ultra`) instead of vanishing.
+const EFFORT_RANK = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra']);
/**
* Resolve a stored effort override to the value the provider's CLI actually
* accepts, or null when the flag should be omitted entirely (no override set,
- * provider has no effort control, or the value is unrecognized). Out-of-range
- * values are clamped (`minimal`→`low`, `ultra`→`max`) rather than dropped.
+ * provider has no effort control, or the value isn't a known effort at all).
+ * An out-of-range value is clamped to the nearest supported level at or below
+ * it (`ultra`→`max` on claude, `xhigh`/`max`/`ultra`→`high` on agy), falling
+ * 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
* @returns {string|null}
@@ -157,8 +188,12 @@ export function resolveCliEffort(effort, provider) {
const levels = effortLevelsForProvider(provider);
if (!levels) return null;
if (levels.includes(effort)) return effort;
- const clamped = EFFORT_CLAMP[effort];
- return clamped && levels.includes(clamped) ? clamped : null;
+ const requested = EFFORT_RANK.indexOf(effort);
+ if (requested === -1) return null; // not an effort value at all
+ const supported = levels.map(l => EFFORT_RANK.indexOf(l)).filter(i => i !== -1).sort((a, b) => a - b);
+ if (supported.length === 0) return null;
+ const below = supported.filter(i => i < requested);
+ return EFFORT_RANK[below.length ? below[below.length - 1] : supported[0]];
}
/**
@@ -184,7 +219,7 @@ export function hasEffortFlag(args) {
/**
* The argv fragment that applies an effort override to an effort-capable CLI:
- * `['--effort', <level>]` for claude, `['-c', 'model_reasoning_effort=<level>']`
+ * `['--effort', <level>]` for claude and agy, `['-c', 'model_reasoning_effort=<level>']`
* for codex, `[]` when the flag should be omitted (no override, provider has no
* effort control, or a user-baked pin already sits in `existingArgs`). The one
* home for both the detection AND the arg shape, so the two can't drift — spawn
@@ -433,6 +468,35 @@ export function hasModelFlag(args) {
return false;
}
+/**
+ * Strip dangling/empty `--model` / `-m` tokens (no value follows, or the joined
+ * form has an empty value). Those would survive into the spawned argv unchanged
+ * and cause the CLI to reject the invocation — see the comment on `hasModelFlag`
+ * for the full reasoning (it deliberately reports such a token as NOT a pin, so
+ * the injection path fires; without this strip the CLI would then see two
+ * `--model` occurrences). Pinned-with-value tokens are preserved untouched so
+ * user-baked model selections still win.
+ * @param {unknown[]} args
+ * @returns {unknown[]}
+ */
+export function stripBrokenModelFlags(args) {
+ if (!Array.isArray(args) || args.length === 0) return [];
+ const out = [];
+ for (let i = 0; i < args.length; i++) {
+ const a = args[i];
+ if (typeof a === 'string' && (a === '--model=' || a === '-m=')) {
+ continue; // empty joined form
+ }
+ if (a === '--model' || a === '-m') {
+ const next = args[i + 1];
+ const hasValue = typeof next === 'string' && next.length > 0 && !next.startsWith('-');
+ if (!hasValue) continue; // dangling separated form
+ }
+ out.push(a);
+ }
+ return out;
+}
+
/**
* True when a provider command points at the Claude Code binary — the bare
* `claude` on PATH, an absolute/relative path to it, or an optional Windows
diff --git a/server/lib/providerModels.test.js b/server/lib/providerModels.test.js
index ce97b0a5fc..5f836027b8 100644
--- a/server/lib/providerModels.test.js
+++ b/server/lib/providerModels.test.js
@@ -24,7 +24,9 @@ import {
providerSuppliesGithubToken,
CLAUDE_EFFORT_LEVELS,
CODEX_EFFORT_LEVELS,
+ ANTIGRAVITY_EFFORT_LEVELS,
EFFORT_LEVELS,
+ isAntigravityProvider,
effortLevelsForProvider,
resolveCliEffort,
hasEffortFlag,
@@ -177,8 +179,13 @@ describe('providerModels', () => {
expect(effortLevelsForProvider({ id: 'claude-ollama', command: '/usr/local/bin/claude' })).toBe(CLAUDE_EFFORT_LEVELS);
});
+ it('returns the narrower agy ladder for antigravity ids and the agy command', () => {
+ expect(effortLevelsForProvider({ id: 'antigravity-cli', command: 'agy' })).toBe(ANTIGRAVITY_EFFORT_LEVELS);
+ expect(effortLevelsForProvider({ id: 'antigravity-tui' })).toBe(ANTIGRAVITY_EFFORT_LEVELS);
+ expect(effortLevelsForProvider({ id: 'custom', command: '/Users/x/.local/bin/agy' })).toBe(ANTIGRAVITY_EFFORT_LEVELS);
+ });
+
it('returns null for providers without an effort control (and does NOT default blank commands to claude)', () => {
- expect(effortLevelsForProvider({ id: 'antigravity-cli', command: 'agy' })).toBeNull();
expect(effortLevelsForProvider({ id: 'opencode-ollama', command: 'opencode' })).toBeNull();
expect(effortLevelsForProvider({ id: 'grok-cli', command: 'grok' })).toBeNull();
expect(effortLevelsForProvider({ id: 'ollama' })).toBeNull();
@@ -237,14 +244,39 @@ describe('providerModels', () => {
expect(resolveCliEffort('ultra', { id: 'claude-code', command: 'claude' })).toBe('max');
});
+ // agy tops out at `high`, so an effort saved against claude/codex must clamp
+ // DOWN to the nearest supported level rather than vanish when the user
+ // switches the task's provider to Antigravity.
+ it('clamps down to agy\'s narrower ladder', () => {
+ const agy = { id: 'antigravity-cli', command: 'agy' };
+ expect(resolveCliEffort('medium', agy)).toBe('medium');
+ expect(resolveCliEffort('xhigh', agy)).toBe('high');
+ expect(resolveCliEffort('max', agy)).toBe('high');
+ expect(resolveCliEffort('ultra', agy)).toBe('high');
+ expect(resolveCliEffort('minimal', agy)).toBe('low');
+ });
+
it('returns null for unset/unknown values and effort-less providers', () => {
expect(resolveCliEffort(null, { id: 'codex', command: 'codex' })).toBeNull();
expect(resolveCliEffort('', { id: 'codex', command: 'codex' })).toBeNull();
expect(resolveCliEffort('bogus', { id: 'codex', command: 'codex' })).toBeNull();
+ expect(resolveCliEffort('bogus', { id: 'antigravity-cli', command: 'agy' })).toBeNull();
expect(resolveCliEffort('high', { id: 'grok-cli', command: 'grok' })).toBeNull();
});
});
+ describe('isAntigravityProvider', () => {
+ it('matches shipped ids and agy/antigravity command basenames', () => {
+ expect(isAntigravityProvider({ id: 'antigravity-cli' })).toBe(true);
+ expect(isAntigravityProvider({ id: 'antigravity-tui' })).toBe(true);
+ expect(isAntigravityProvider({ id: 'custom', command: '/Users/x/.local/bin/agy' })).toBe(true);
+ expect(isAntigravityProvider({ id: 'custom', command: 'antigravity.exe' })).toBe(true);
+ expect(isAntigravityProvider({ id: 'claude-code', command: 'claude' })).toBe(false);
+ expect(isAntigravityProvider({ id: 'blank' })).toBe(false);
+ expect(isAntigravityProvider(null)).toBe(false);
+ });
+ });
+
describe('hasEffortFlag', () => {
it('detects a baked --effort pin in both arg shapes', () => {
expect(hasEffortFlag(['--effort', 'high'])).toBe(true);
diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.js
index c8480f75da..6bbb2ddebd 100644
--- a/server/lib/tuiHandshake.js
+++ b/server/lib/tuiHandshake.js
@@ -857,8 +857,10 @@ export function buildTuiInvocation(provider, model) {
const command = provider?.command || inferTuiCommand(provider?.id);
const baseArgs = applyCommandDefaults(command, [...(provider?.args || [])]);
const effectiveModel = resolveCliModel(model);
- const shouldInject = !isAntigravityCommand(command) && effectiveModel && !hasModelFlag(baseArgs);
+ 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.
@@ -866,10 +868,12 @@ export function buildTuiInvocation(provider, model) {
? effectiveModel
: isOpencodeCommand(command)
? prefixOpencodeModel(provider, effectiveModel)
- : resolveBedrockCliModel(effectiveModel, {
- env: { ...process.env, ...provider?.envVars },
- providerId: provider?.id,
- });
+ : isAntigravityCommand(command)
+ ? effectiveModel
+ : resolveBedrockCliModel(effectiveModel, {
+ env: { ...process.env, ...provider?.envVars },
+ providerId: provider?.id,
+ });
const args = shouldInject ? [...baseArgs, '--model', injectedModel] : baseArgs;
return { command, args };
}
diff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.js
index 8df66a10d1..b49d4764af 100644
--- a/server/lib/tuiHandshake.test.js
+++ b/server/lib/tuiHandshake.test.js
@@ -509,11 +509,19 @@ describe('tuiHandshake.applyCommandDefaults', () => {
});
it('adds Antigravity permission bypass and strips legacy Gemini flags', () => {
- expect(applyCommandDefaults('agy', ['--yolo', '--model', 'gemini-2.5-pro'])).toEqual([
+ expect(applyCommandDefaults('agy', ['--yolo', '-m', 'gemini-2.5-pro'])).toEqual([
'--dangerously-skip-permissions',
]);
});
+ // agy accepts the long `--model` now, so a baked pin survives (and suppresses
+ // the per-run model injection in buildTuiInvocation).
+ it('preserves a long-form --model pin for Antigravity', () => {
+ expect(applyCommandDefaults('agy', ['--model', 'gemini-3.1-pro-high'])).toEqual([
+ '--model', 'gemini-3.1-pro-high', '--dangerously-skip-permissions',
+ ]);
+ });
+
it('preserves the original arg list when injecting (caller can still mutate before spawn)', () => {
const args = ['exec', '-'];
const result = applyCommandDefaults('codex', args);
@@ -656,12 +664,32 @@ describe('tuiHandshake.buildTuiInvocation', () => {
expect(out.args).toEqual(['--model', 'opus-x']);
});
- it('does not append --model for Antigravity TUI', () => {
+ it('does not append --model for the Antigravity configured-default sentinel', () => {
const out = buildTuiInvocation({ id: 'antigravity-tui', command: 'agy', args: [] }, 'antigravity-configured-default');
expect(out.command).toBe('agy');
expect(out.args).toEqual(['--dangerously-skip-permissions']);
});
+ 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']);
+ });
+
+ // agy serves its `claude-*` ids through Google's own gateway, so a Bedrock box
+ // must NOT rewrite them to `global.anthropic.*` (agy can't resolve that).
+ it('does not Bedrock-map an Antigravity claude-* model id', () => {
+ const prev = process.env.CLAUDE_CODE_USE_BEDROCK;
+ process.env.CLAUDE_CODE_USE_BEDROCK = '1';
+ try {
+ const out = buildTuiInvocation({ id: 'antigravity-tui', command: 'agy', args: [] }, 'claude-sonnet-4-6');
+ expect(out.args).toEqual(['--dangerously-skip-permissions', '--model', 'claude-sonnet-4-6']);
+ } finally {
+ if (prev === undefined) delete process.env.CLAUDE_CODE_USE_BEDROCK;
+ else process.env.CLAUDE_CODE_USE_BEDROCK = prev;
+ }
+ });
+
it('handles a missing provider with no id (falls back to claude)', () => {
const out = buildTuiInvocation(undefined, 'opus-x');
expect(out.command).toBe('claude');
diff --git a/server/services/agentCliSpawning.js b/server/services/agentCliSpawning.js
index 524766eb88..d97643112b 100644
--- a/server/services/agentCliSpawning.js
+++ b/server/services/agentCliSpawning.js
@@ -289,9 +289,11 @@ export function buildCliSpawnConfig(provider, model, settingsEnv = {}, { systemP
}
// Antigravity CLI (`agy`) replaces Gemini CLI. Use print mode for a
- // headless agent run and keep prompt delivery on stdin.
+ // headless agent run; the prompt rides as the trailing `--print` value.
+ // 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 || []);
+ const args = ensureAntigravityPrintArgs(provider?.args || [], { model: effectiveModel, effort });
return {
command: provider?.command || 'agy',
args,
diff --git a/server/services/agentCliSpawning.test.js b/server/services/agentCliSpawning.test.js
index 88dd816b0e..32f024f435 100644
--- a/server/services/agentCliSpawning.test.js
+++ b/server/services/agentCliSpawning.test.js
@@ -205,13 +205,33 @@ describe('buildCliSpawnConfig', () => {
expect(config.args).toContain('check_for_update_on_startup=false');
});
- it('uses agy print mode for Antigravity without model flags', () => {
+ it('uses agy print mode for Antigravity without model flags on the configured-default sentinel', () => {
const config = buildCliSpawnConfig({ id: 'antigravity-cli', command: 'agy', args: [] }, 'antigravity-configured-default');
expect(config.command).toBe('agy');
expect(config.args).toEqual(['--dangerously-skip-permissions', '--print']);
});
+ // agy takes the prompt as the trailing --print VALUE, so every injected flag
+ // must land before it or agy reads the flag name as its task.
+ it('threads the per-task model and effort into agy ahead of --print', () => {
+ const config = buildCliSpawnConfig(
+ { id: 'antigravity-cli', command: 'agy', args: [] },
+ 'claude-sonnet-4-6',
+ {},
+ { effort: 'medium' },
+ );
+
+ expect(config.command).toBe('agy');
+ expect(config.args).toEqual([
+ '--model', 'claude-sonnet-4-6',
+ '--effort', 'medium',
+ '--dangerously-skip-permissions',
+ '--print',
+ ]);
+ expect(config.args[config.args.length - 1]).toBe('--print');
+ });
+
it('runs `opencode run -m ollama/<model>` for a headless OpenCode Ollama agent', () => {
const config = buildCliSpawnConfig(
{ id: 'opencode-ollama', command: 'opencode', args: ['run'], ollamaBacked: true },
diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.js
index 49bff3ab2d..d6b34e1733 100644
--- a/server/services/agentTuiSpawning.js
+++ b/server/services/agentTuiSpawning.js
@@ -155,7 +155,6 @@ function shellHasLiveChild(shellPid) {
}
function appendModelArgs(args, model, command, provider) {
- if (isAntigravityCommand(command)) return args;
const effectiveModel = resolveCliModel(model);
if (!effectiveModel) return args;
// OpenCode TUI launches with `opencode --model ollama/<id>` (the top-level
@@ -166,6 +165,13 @@ 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];
+ }
// 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, {
diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.js
index 9a539fb308..6f3bcb2eee 100644
--- a/server/services/agentTuiSpawning.test.js
+++ b/server/services/agentTuiSpawning.test.js
@@ -295,8 +295,25 @@ describe('agent TUI spawning', () => {
const noEffort = buildTuiSpawnConfig({ id: 'claude-code-tui', command: 'claude', type: 'tui', args: [] }, null);
expect(noEffort.args).not.toContain('--effort');
+ const grok = buildTuiSpawnConfig({ id: 'grok-tui', command: 'grok', type: 'tui', args: [] }, null, { effort: 'high' });
+ expect(grok.args.join(' ')).not.toContain('effort');
+ });
+
+ it('passes --effort through to the Antigravity TUI, clamped to its low|medium|high ladder', () => {
const agy = buildTuiSpawnConfig({ id: 'antigravity-tui', command: 'agy', type: 'tui', args: [] }, null, { effort: 'high' });
- expect(agy.args.join(' ')).not.toContain('effort');
+ expect(agy.args).toEqual(['--dangerously-skip-permissions', '--effort', 'high']);
+
+ const clamped = buildTuiSpawnConfig({ id: 'antigravity-tui', command: 'agy', type: 'tui', args: [] }, null, { effort: 'max' });
+ expect(clamped.args).toEqual(['--dangerously-skip-permissions', '--effort', 'high']);
+ });
+
+ it('passes the per-task model through to the Antigravity TUI', () => {
+ const agy = buildTuiSpawnConfig(
+ { id: 'antigravity-tui', command: 'agy', type: 'tui', args: [] },
+ 'gemini-3.1-pro-high',
+ { effort: 'low' },
+ );
+ expect(agy.args).toEqual(['--dangerously-skip-permissions', '--model', 'gemini-3.1-pro-high', '--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.js
index b05eba4251..9bbc207c10 100644
--- a/server/services/askService.js
+++ b/server/services/askService.js
@@ -571,9 +571,7 @@ async function* streamCompletion(provider, model, prompt, signal) {
// sources + history are concatenated, which exceeds OS argv limits
// (especially on Windows ~32k).
const { spawn } = await import('child_process');
- let args = isAntigravityCliProvider(provider)
- ? ensureAntigravityPrintArgs(provider.args || [])
- : [...(provider.args || [])];
+ let args = [...(provider.args || [])];
// OpenCode runs headless via the `run` subcommand (reads the prompt from
// stdin); ensure it leads the argv even if a customized/TUI provider config
// omitted it — a bare `opencode` launches the interactive TUI, which never
@@ -582,7 +580,11 @@ async function* streamCompletion(provider, model, prompt, signal) {
if (provider.headlessArgs?.length) args.push(...provider.headlessArgs);
const cliModel = resolveCliModel(model);
if (isAntigravityCliProvider(provider)) {
- // Antigravity (`agy`) picks its model from its own configuration.
+ // Antigravity (`agy --print <prompt>`): built LAST so the print marker stays
+ // 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 });
} 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.js
index 3bb78c21a9..8e1a2f2951 100644
--- a/server/services/askService.test.js
+++ b/server/services/askService.test.js
@@ -391,6 +391,73 @@ describe('runAsk', () => {
expect(child.stdin.end).toHaveBeenCalled();
});
+ it('runs `agy --model <id> --print <prompt>` with headlessArgs still ahead of the print marker', async () => {
+ providers.getActiveProvider.mockResolvedValue({
+ id: 'antigravity-cli',
+ type: 'cli',
+ enabled: true,
+ command: 'agy',
+ args: [],
+ headlessArgs: ['--add-dir', '/tmp/x'],
+ defaultModel: 'gemini-3.1-pro-high',
+ timeout: 5000,
+ });
+
+ const child = new EventEmitter();
+ child.stdout = new EventEmitter();
+ child.stderr = new EventEmitter();
+ child.stdin = { on: vi.fn(), end: vi.fn(), write: vi.fn() };
+ child.kill = vi.fn();
+ setImmediate(() => {
+ child.stdout.emit('data', Buffer.from('answer text'));
+ child.emit('close', 0);
+ });
+ spawn.mockReturnValue(child);
+
+ for await (const _evt of askService.runAsk({ question: 'test question' })) { /* drain */ }
+
+ const [, args] = spawn.mock.calls.at(-1);
+ // agy takes the prompt as the --print VALUE, so --print must be second-to-last
+ // 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',
+ '--dangerously-skip-permissions',
+ '--print',
+ ]);
+ expect(args.at(-1)).toContain('test question');
+ });
+
+ it('omits --model for the Antigravity configured-default sentinel', async () => {
+ providers.getActiveProvider.mockResolvedValue({
+ id: 'antigravity-cli',
+ type: 'cli',
+ enabled: true,
+ command: 'agy',
+ args: [],
+ defaultModel: 'antigravity-configured-default',
+ timeout: 5000,
+ });
+
+ const child = new EventEmitter();
+ child.stdout = new EventEmitter();
+ child.stderr = new EventEmitter();
+ child.stdin = { on: vi.fn(), end: vi.fn(), write: vi.fn() };
+ child.kill = vi.fn();
+ setImmediate(() => {
+ child.stdout.emit('data', Buffer.from('answer text'));
+ child.emit('close', 0);
+ });
+ spawn.mockReturnValue(child);
+
+ for await (const _evt of askService.runAsk({ question: 'test question' })) { /* drain */ }
+
+ const [, args] = spawn.mock.calls.at(-1);
+ expect(args).not.toContain('--model');
+ expect(args.slice(0, -1)).toEqual(['--dangerously-skip-permissions', '--print']);
+ expect(args.at(-1)).toContain('test question');
+ });
+
it('runs `opencode run --model ollama/<id>` for an OpenCode Ollama provider', async () => {
providers.getActiveProvider.mockResolvedValue({
id: 'opencode-ollama',