Skip to content

Commit fbc8f84

Browse files
fix: remove fast session config option if model doesn't support it (#254)
1 parent 3a3e8f6 commit fbc8f84

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/CodexAcpServer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,9 @@ export class CodexAcpServer {
784784
createReasoningEffortConfigOption(sessionState.supportedReasoningEfforts, currentModelId.effort),
785785
);
786786
}
787-
configOptions.push(createFastModeConfigOption(sessionState.fastModeEnabled));
787+
if (sessionState.currentModelSupportsFast) {
788+
configOptions.push(createFastModeConfigOption(sessionState.fastModeEnabled));
789+
}
788790
return configOptions;
789791
}
790792

src/__tests__/CodexACPAgent/fast-mode-config.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
FAST_MODE_OFF,
1313
FAST_MODE_ON,
1414
} from "../../FastModeConfig";
15+
import {MODEL_CONFIG_ID} from "../../ModelConfigOption";
1516

1617
describe("Fast mode session config", () => {
1718
async function createSession(
@@ -25,13 +26,14 @@ describe("Fast mode session config", () => {
2526
id: "fast-model",
2627
additionalSpeedTiers: ["fast"],
2728
});
29+
const slowModel = createTestModel({id: "slow-model"});
2830

2931
vi.spyOn(codexAcpClient, "authRequired").mockResolvedValue(false);
3032
vi.spyOn(codexAcpClient, "getAccount").mockResolvedValue({account: null, requiresOpenaiAuth: false});
3133
vi.spyOn(codexAcpClient, "newSession").mockResolvedValue({
3234
sessionId: "session-id",
3335
currentModelId: "fast-model[medium]",
34-
models: [fastModel],
36+
models: [fastModel, slowModel],
3537
currentServiceTier,
3638
additionalDirectories: [],
3739
});
@@ -183,6 +185,24 @@ describe("Fast mode session config", () => {
183185
}));
184186
});
185187

188+
it("removes the Fast mode config option when switching to a non-fast model via session_config", async () => {
189+
const {codexAcpAgent} = await createSession("fast");
190+
191+
const fastResponse = await codexAcpAgent.setSessionConfigOption({
192+
sessionId: "session-id",
193+
configId: MODEL_CONFIG_ID,
194+
value: "fast-model",
195+
});
196+
expect(fastResponse.configOptions?.some(o => o.id === FAST_MODE_CONFIG_ID)).toBe(true);
197+
198+
const slowResponse = await codexAcpAgent.setSessionConfigOption({
199+
sessionId: "session-id",
200+
configId: MODEL_CONFIG_ID,
201+
value: "slow-model",
202+
});
203+
expect(slowResponse.configOptions?.some(o => o.id === FAST_MODE_CONFIG_ID)).toBe(false);
204+
});
205+
186206
it("keeps Fast mode selected across model switches but stops applying it for non-fast models", async () => {
187207
const {codexAcpAgent, codexAcpClient, fixture} = await createSession("fast");
188208
const slowModel = createTestModel({id: "slow-model"});

src/__tests__/CodexACPAgent/session-config-options.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function buildModels(): {fast: Model; slow: Model} {
1919
description: "Frontier",
2020
supportedReasoningEfforts: [lowEffort, mediumEffort, highEffort],
2121
defaultReasoningEffort: "medium",
22+
additionalSpeedTiers: ["fast"],
2223
});
2324
const slow = createTestModel({
2425
id: "slow-model",
@@ -95,7 +96,7 @@ describe("Session config options", () => {
9596
const {codexAcpAgent, response} = await createSession("custom-model[high]", [fast, slow]);
9697

9798
const ids = response.configOptions?.map(o => o.id);
98-
expect(ids).toEqual([MODE_CONFIG_ID, MODEL_CONFIG_ID, "fast-mode"]);
99+
expect(ids).toEqual([MODE_CONFIG_ID, MODEL_CONFIG_ID]);
99100

100101
const modelOption = response.configOptions?.find(o => o.id === MODEL_CONFIG_ID);
101102
expect(modelOption).toMatchObject({

0 commit comments

Comments
 (0)