From ba4348ee732d5d74675aaaaf5078f015ae57c264 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sun, 1 Nov 2026 10:31:28 +0100 Subject: [PATCH] fix(server): reset OMP Fast to its starting value only when a held option is removed Every options patch without fast_mode reset Fast to the value it had when the session started, so an unrelated patch undid a model family's own Fast setting. The reset now applies only when a fast_mode option that was held becomes absent. --- .../server/agent/providers/omp/agent.test.ts | 23 +++++++++++++++++++ .../src/server/agent/providers/omp/agent.ts | 6 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/server/src/server/agent/providers/omp/agent.test.ts b/packages/server/src/server/agent/providers/omp/agent.test.ts index f31cb4d995..96a7ab0d0c 100644 --- a/packages/server/src/server/agent/providers/omp/agent.test.ts +++ b/packages/server/src/server/agent/providers/omp/agent.test.ts @@ -659,6 +659,29 @@ describe("OMP agent client and session", () => { expect(omp.runtime().setFastModeRequests).toEqual([true, false]); }); + test("an options patch that never held fast_mode leaves the runtime's Fast setting alone", async () => { + const omp = new OmpHarness(); + await omp.start({ model: "openai/gpt-5" }); + const session = omp.requireSession(); + expect(omp.runtime().state.fastModeEnabled).toBe(false); + + // Another model family has Fast on natively. + omp.runtime().setModelResult = { provider: "anthropic", id: "claude-x" }; + omp.runtime().queueStateReports([ + { + ...omp.runtime().state, + model: omp.runtime().setModelResult, + fastModeEnabled: true, + fastModeActive: true, + }, + ]); + await session.setModel?.("anthropic/claude-x"); + + await session.applyOptions?.({ rpcTimeoutMs: 120000 }); + + expect(omp.runtime().setFastModeRequests).toEqual([]); + }); + test("shows Fast only when OMP reports its state fields", async () => { const omp = new OmpHarness(); await omp.start(); diff --git a/packages/server/src/server/agent/providers/omp/agent.ts b/packages/server/src/server/agent/providers/omp/agent.ts index 974d56f8d4..8080e68769 100644 --- a/packages/server/src/server/agent/providers/omp/agent.ts +++ b/packages/server/src/server/agent/providers/omp/agent.ts @@ -834,8 +834,10 @@ export class OmpAgentSession implements AgentSession { if (requested !== undefined && typeof requested !== "boolean") { throw new Error("OMP fast mode requires a boolean"); } - // An absent option means the runtime's own setting at session start. - const target = requested ?? this.fastModeBaseline; + // Removing a held option returns Fast to the runtime's own setting at session start; an + // option that was already absent leaves whatever the runtime reports alone. + const removed = requested === undefined && this.config.providerOptions?.fast_mode !== undefined; + const target = removed ? this.fastModeBaseline : requested; if (target !== undefined && target !== this.state.fastModeEnabled) { if (!hasOmpFastMode(this.state)) throw new Error("OMP fast mode is unavailable"); const result = await this.runtimeSession.setFastMode(target);