Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/CodexAcpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
22 changes: 21 additions & 1 deletion src/__tests__/CodexACPAgent/fast-mode-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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: [],
});
Expand Down Expand Up @@ -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"});
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/CodexACPAgent/session-config-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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({
Expand Down