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
368 allowRecovery: true,368 allowRecovery: true,
369 });369 });
370 const turn = yield* routed.adapter.sendTurn(input);370 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 : {};
371 yield* directory.upsert({378 yield* directory.upsert({
372 threadId: input.threadId,379 threadId: input.threadId,
373 provider: routed.adapter.provider,380 provider: routed.adapter.provider,
374 status: "running",381 status: "running",
375 ...(turn.resumeCursor !== undefined ? { resumeCursor: turn.resumeCursor } : {}),382 ...(turn.resumeCursor !== undefined ? { resumeCursor: turn.resumeCursor } : {}),
376 runtimePayload: {383 runtimePayload: {
384 ...existingPayload,
377 ...(input.modelSelection !== undefined ? { modelSelection: input.modelSelection } : {}),385 ...(input.modelSelection !== undefined ? { modelSelection: input.modelSelection } : {}),
378 activeTurnId: turn.turnId,386 activeTurnId: turn.turnId,
379 lastRuntimeEvent: "provider.sendTurn",387 lastRuntimeEvent: "provider.sendTurn",