From 593773a3819179bf1258d06895ed9997f65c8e0a Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sun, 1 Nov 2026 18:57:05 +0100 Subject: [PATCH] fix(server): an OMP replacement runtime starts with the Fast the session has now A restart (for example an approval-mode change) restored Fast from the options the session opened with, turning back on a Fast the user had switched off. The session now keeps the Fast it applied or the provider changed, which is what a replacement reads. --- .../src/server/agent/providers/omp/agent.test.ts | 14 ++++++++++++++ .../server/src/server/agent/providers/omp/agent.ts | 9 +++++++++ 2 files changed, 23 insertions(+) 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 2ed4846eac..74c6558022 100644 --- a/packages/server/src/server/agent/providers/omp/agent.test.ts +++ b/packages/server/src/server/agent/providers/omp/agent.test.ts @@ -753,6 +753,20 @@ describe("OMP agent client and session", () => { ]); }); + test("a replacement runtime starts with the Fast the session has now, not the one it opened with", async () => { + const omp = new OmpHarness(); + await omp.start({ modeId: "full", providerOptions: { fast_mode: true } }); + const session = omp.requireSession(); + omp.runtime().fastModeResult = { enabled: false, active: false }; + await session.applyOptions?.({ fast_mode: false }); + + await omp.setMode("ask"); + + // The approval-mode restart starts a second runtime; it must not turn Fast back on. + expect(omp.runtimeLaunches()).toHaveLength(2); + expect(omp.runtime().setFastModeRequests).toEqual([]); + }); + test("restores Fast from the initial OMP state on create and resume", async () => { const created = new OmpHarness(); await created.start({ providerOptions: { fast_mode: true } }); diff --git a/packages/server/src/server/agent/providers/omp/agent.ts b/packages/server/src/server/agent/providers/omp/agent.ts index ab0246cee4..c0e0905089 100644 --- a/packages/server/src/server/agent/providers/omp/agent.ts +++ b/packages/server/src/server/agent/providers/omp/agent.ts @@ -847,9 +847,17 @@ export class OmpAgentSession implements AgentSession { fastModeActive: result.active, }; } + if (typeof this.state.fastModeEnabled === "boolean") { + this.rememberFastMode(this.state.fastModeEnabled); + } return this.fastModeDifference(requested); } + /** A replacement runtime starts from the Fast the session has now, not the one it opened with. */ + private rememberFastMode(enabled: boolean): void { + this.config.providerOptions = { ...this.config.providerOptions, fast_mode: enabled }; + } + /** The option patch when the runtime's fast mode is not what `given` stands for; unset is off. */ private fastModeDifference(given: unknown): Record { if (!hasOmpFastMode(this.state)) return {}; @@ -2257,6 +2265,7 @@ export class OmpAgentSession implements AgentSession { const before = this.state.fastModeEnabled; this.state = await this.runtimeSession.getState(); if (this.state.fastModeEnabled !== before && typeof this.state.fastModeEnabled === "boolean") { + this.rememberFastMode(this.state.fastModeEnabled); this.emit({ type: "options_changed", provider: this.provider,