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:
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",
|
||||
|
||||
Reference in new issue
Block a user