diff --git a/src/CodexAcpServer.ts b/src/CodexAcpServer.ts index 1903033..80486fe 100644 --- a/src/CodexAcpServer.ts +++ b/src/CodexAcpServer.ts @@ -784,7 +784,9 @@ export class CodexAcpServer { createReasoningEffortConfigOption(sessionState.supportedReasoningEfforts, currentModelId.effort), ); } - configOptions.push(createFastModeConfigOption(sessionState.fastModeEnabled)); + if (sessionState.currentModelSupportsFast) { + configOptions.push(createFastModeConfigOption(sessionState.fastModeEnabled)); + } return configOptions; } diff --git a/src/__tests__/CodexACPAgent/fast-mode-config.test.ts b/src/__tests__/CodexACPAgent/fast-mode-config.test.ts index 70716c8..ba8a71d 100644 --- a/src/__tests__/CodexACPAgent/fast-mode-config.test.ts +++ b/src/__tests__/CodexACPAgent/fast-mode-config.test.ts @@ -12,6 +12,7 @@ import { FAST_MODE_OFF, FAST_MODE_ON, } from "../../FastModeConfig"; +import {MODEL_CONFIG_ID} from "../../ModelConfigOption"; describe("Fast mode session config", () => { async function createSession( @@ -25,13 +26,14 @@ describe("Fast mode session config", () => { id: "fast-model", additionalSpeedTiers: ["fast"], }); + const slowModel = createTestModel({id: "slow-model"}); vi.spyOn(codexAcpClient, "authRequired").mockResolvedValue(false); vi.spyOn(codexAcpClient, "getAccount").mockResolvedValue({account: null, requiresOpenaiAuth: false}); vi.spyOn(codexAcpClient, "newSession").mockResolvedValue({ sessionId: "session-id", currentModelId: "fast-model[medium]", - models: [fastModel], + models: [fastModel, slowModel], currentServiceTier, additionalDirectories: [], }); @@ -183,6 +185,24 @@ describe("Fast mode session config", () => { })); }); + it("removes the Fast mode config option when switching to a non-fast model via session_config", async () => { + const {codexAcpAgent} = await createSession("fast"); + + const fastResponse = await codexAcpAgent.setSessionConfigOption({ + sessionId: "session-id", + configId: MODEL_CONFIG_ID, + value: "fast-model", + }); + expect(fastResponse.configOptions?.some(o => o.id === FAST_MODE_CONFIG_ID)).toBe(true); + + const slowResponse = await codexAcpAgent.setSessionConfigOption({ + sessionId: "session-id", + configId: MODEL_CONFIG_ID, + value: "slow-model", + }); + expect(slowResponse.configOptions?.some(o => o.id === FAST_MODE_CONFIG_ID)).toBe(false); + }); + it("keeps Fast mode selected across model switches but stops applying it for non-fast models", async () => { const {codexAcpAgent, codexAcpClient, fixture} = await createSession("fast"); const slowModel = createTestModel({id: "slow-model"}); diff --git a/src/__tests__/CodexACPAgent/session-config-options.test.ts b/src/__tests__/CodexACPAgent/session-config-options.test.ts index 391cc04..7377c90 100644 --- a/src/__tests__/CodexACPAgent/session-config-options.test.ts +++ b/src/__tests__/CodexACPAgent/session-config-options.test.ts @@ -19,6 +19,7 @@ function buildModels(): {fast: Model; slow: Model} { description: "Frontier", supportedReasoningEfforts: [lowEffort, mediumEffort, highEffort], defaultReasoningEffort: "medium", + additionalSpeedTiers: ["fast"], }); const slow = createTestModel({ id: "slow-model", @@ -95,7 +96,7 @@ describe("Session config options", () => { const {codexAcpAgent, response} = await createSession("custom-model[high]", [fast, slow]); const ids = response.configOptions?.map(o => o.id); - expect(ids).toEqual([MODE_CONFIG_ID, MODEL_CONFIG_ID, "fast-mode"]); + expect(ids).toEqual([MODE_CONFIG_ID, MODEL_CONFIG_ID]); const modelOption = response.configOptions?.find(o => o.id === MODEL_CONFIG_ID); expect(modelOption).toMatchObject({