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,