Skip to content

Commit 2c97a21

Browse files
committed
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.
1 parent c44d17f commit 2c97a21

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/server/src/provider/Layers/ProviderService.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,20 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
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",

0 commit comments

Comments
 (0)