From 2c97a21b072bddf85e41f2dbb05769be0733d616 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 24 Mar 2026 22:48:01 +0000 Subject: [PATCH] fix: preserve existing runtimePayload fields when sendTurn upserts binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sendTurn was constructing a fresh runtimePayload with only modelSelection, activeTurnId, lastRuntimeEvent, and lastRuntimeEventAt—completely overwriting persisted fields like cwd, model, and providerOptions set during startSession. Now reads the existing binding's runtimePayload and spreads it as the base, so fields persisted by startSession survive through sendTurn updates. --- apps/server/src/provider/Layers/ProviderService.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/server/src/provider/Layers/ProviderService.ts b/apps/server/src/provider/Layers/ProviderService.ts index 364e30fd0e..79f3a69b89 100644 --- a/apps/server/src/provider/Layers/ProviderService.ts +++ b/apps/server/src/provider/Layers/ProviderService.ts @@ -368,12 +368,20 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) => allowRecovery: true, }); const turn = yield* routed.adapter.sendTurn(input); + const existingBinding = Option.getOrUndefined(yield* directory.getBinding(input.threadId)); + const existingPayload = + existingBinding?.runtimePayload && + typeof existingBinding.runtimePayload === "object" && + !Array.isArray(existingBinding.runtimePayload) + ? existingBinding.runtimePayload + : {}; yield* directory.upsert({ threadId: input.threadId, provider: routed.adapter.provider, status: "running", ...(turn.resumeCursor !== undefined ? { resumeCursor: turn.resumeCursor } : {}), runtimePayload: { + ...existingPayload, ...(input.modelSelection !== undefined ? { modelSelection: input.modelSelection } : {}), activeTurnId: turn.turnId, lastRuntimeEvent: "provider.sendTurn",