From e77dab79101c9f7c5301019297ca1d8e9a3955e2 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 9 Aug 2026 12:31:47 -0700 Subject: [PATCH] fix(grok): carry reasoning effort for models outside the seed catalog (#13365) Launch resolves options from the static seed, so a discovered model id had no options and silently dropped --reasoning-effort. unknownModelOptions keeps the effort menu for those ids. Leave the multi-host launch gate unchanged. --- .../agent-session-option-catalog-grok.test.ts | 37 +++++++++++++++++++ .../agent-session-option-catalog-grok.ts | 4 ++ 2 files changed, 41 insertions(+) diff --git a/src/shared/agent-session-option-catalog-grok.test.ts b/src/shared/agent-session-option-catalog-grok.test.ts index 1efb9f637..b20e6a0c6 100644 --- a/src/shared/agent-session-option-catalog-grok.test.ts +++ b/src/shared/agent-session-option-catalog-grok.test.ts @@ -45,6 +45,10 @@ describe('grok session option catalog', () => { } }) + it('gives unknown model ids the same effort menu launch reads from the seed', () => { + expect(GROK_SESSION_OPTION_CATALOG.unknownModelOptions?.map(({ id }) => id)).toEqual(['effort']) + }) + it('treats a successful discovery as authoritative, unlike the other agents', () => { expect(GROK_SESSION_OPTION_CATALOG.discoveredModelsAreAuthoritative).toBe(true) for (const agent of ['claude', 'codex', 'gemini', 'cursor'] as const) { @@ -88,6 +92,39 @@ describe('grok launch args', () => { }) }) + it('carries a picked effort onto a discovered model the seed never listed', () => { + // Regression: launch reads options off the static seed, so a discovered id + // resolved to no options and dropped `--reasoning-effort` from the argv. + expect(resolveAgentSessionOptionLaunch('grok', { model: 'grok-build', effort: 'low' })).toEqual( + { + args: ['-m', 'grok-build', '--reasoning-effort', 'low'], + appliedValues: { model: 'grok-build', effort: 'low' } + } + ) + }) + + it('drops an effort value the menu does not offer on an unseeded model', () => { + expect( + resolveAgentSessionOptionLaunch('grok', { model: 'grok-build', effort: 'none' }) + ).toEqual({ args: ['-m', 'grok-build'], appliedValues: { model: 'grok-build' } }) + }) + + it('honors a user effort flag over the picker on an unseeded model too', () => { + expect( + resolveAgentSessionOptionLaunch('grok', { model: 'grok-build', effort: 'low' }, [ + '--reasoning-effort=high' + ]).appliedValues + ).toEqual({ model: 'grok-build' }) + }) + + it('still adds no effort default for a model the seed does not carry', () => { + // An unseeded id has no verified menu, so only an explicit pick may reach argv. + expect(resolveAgentSessionOptionLaunch('grok', { model: 'grok-build' }).args).toEqual([ + '-m', + 'grok-build' + ]) + }) + it('spawns vanilla when no model was ever picked', () => { expect(resolveAgentSessionOptionLaunch('grok', undefined)).toEqual({ args: [], diff --git a/src/shared/agent-session-option-catalog-grok.ts b/src/shared/agent-session-option-catalog-grok.ts index 3f9ff697c..18f90ddb8 100644 --- a/src/shared/agent-session-option-catalog-grok.ts +++ b/src/shared/agent-session-option-catalog-grok.ts @@ -55,6 +55,10 @@ export const GROK_SESSION_OPTION_CATALOG: AgentSessionOptionCatalog = { // agent picker…" and never persist a model, so `-m` would never be emitted. midSession: { kind: 'command', build: (value) => `/model ${String(value)}` } }, + // Why: `--reasoning-effort` is a global grok flag, not a per-model capability, and + // launch resolves against this static seed. Without this, a discovered id the seed + // does not carry shows the effort menu but launches with the flag dropped. + unknownModelOptions: [GROK_EFFORT], // Why: grok's selectable ids retire between releases, so a stale seed entry // must be droppable — picking one is a fatal launch, not a warning. discoveredModelsAreAuthoritative: true,