History

fix: preserve existing runtimePayload fields when sendTurn upserts binding

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.

Cursor Agent committed 7 months ago

Commit 2c97a211 parent c44d17f1 file · +8 −0Browse files

Unified · Split

apps/server/src/provider/Layers/ProviderService.ts+8−0
@@ -368,12 +368,20 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) => · 367 unmodified lines
368368 allowRecovery: true,
369369 });
370370 const turn = yield* routed.adapter.sendTurn(input);
371+ const existingBinding = Option.getOrUndefined(yield* directory.getBinding(input.threadId));
372+ const existingPayload =
373+ existingBinding?.runtimePayload &&
374+ typeof existingBinding.runtimePayload === "object" &&
375+ !Array.isArray(existingBinding.runtimePayload)
376+ ? existingBinding.runtimePayload
377+ : {};
371378 yield* directory.upsert({
372379 threadId: input.threadId,
373380 provider: routed.adapter.provider,
374381 status: "running",
375382 ...(turn.resumeCursor !== undefined ? { resumeCursor: turn.resumeCursor } : {}),
376383 runtimePayload: {
384+ ...existingPayload,
377385 ...(input.modelSelection !== undefined ? { modelSelection: input.modelSelection } : {}),
378386 activeTurnId: turn.turnId,
379387 lastRuntimeEvent: "provider.sendTurn",