fix(server): Codex keeps the speed it opened with when the legacy Fast key is removed

Opening moves a legacy fast_mode into service_tier, so removing fast_mode afterwards changed the runtime speed to Normal while the stored options still said Fast. Removing the alias now changes no speed.
This commit is contained in:
Mohamed Boudra
2026-11-01 17:30:53 +01:00
parent 0c378889d1
commit 5cdbfef48b
2 changed files with 15 additions and 1 deletions
@@ -521,6 +521,19 @@ describe("Codex app-server provider controls", () => {
});
});
test("removing the legacy Fast key after opening leaves the speed the session opened with", async () => {
const { session, appServer } = await createConnectedSession({
providerOptions: { fast_mode: true },
});
expect(session.openOptionsPatch).toEqual({ service_tier: "priority", fast_mode: null });
// The stored options now hold `service_tier`; `fast_mode` is an alias no longer in them.
await expect(session.applyOptions?.({ fast_mode: null })).resolves.toEqual({});
await session.startTurn("hello");
await expect(appServer.waitForTurnStart()).resolves.toMatchObject({ serviceTier: "priority" });
});
test("a patch that sets another option keeps the running sandbox and an explicit speed", async () => {
const { session, appServer } = await createConnectedSession({
providerOptions: { sandbox_mode: "read-only", service_tier: "default", fast_mode: true },
@@ -4752,7 +4752,8 @@ export class CodexAppServerAgentSession implements AgentSession {
private requestedTierFrom(options: ProviderOptions): string | null {
if ("service_tier" in options) return readCodexServiceTier(options);
if (options.fast_mode === null) return null;
// Opening moved a legacy Fast into `service_tier`, so removing the alias changes no speed.
if (options.fast_mode === null) return this.requestedServiceTier;
return options.fast_mode ? "fast" : "default";
}