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.
This commit is contained in:
Cursor Agent committed 2026-03-24 22:48:01 +00:00
1 parent c44d17f174
commit 2c97a21b07
1 file changed
+8
@@ -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",