Skip to content

Commit adbf87b

Browse files
fix(sdk): reset skipToTurnComplete when a new chat turn starts
1 parent d044670 commit adbf87b

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

.changeset/fluffy-pans-argue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
---
4+
5+
Fix chat transport discarding the next turn after stopping generation. `skipToTurnComplete` is now reset when a new message or action is sent, so a message sent after `stopGeneration` streams normally instead of leaving the chat stuck in a streaming state.

packages/trigger-sdk/src/v3/chat.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,10 @@ export class TriggerChatTransport implements ChatTransport<UIMessage> {
870870
this.activeStreams.delete(chatId);
871871
}
872872

873+
// A stop that never saw its TURN_COMPLETE leaves the flag set, and the new
874+
// turn would be skipped record by record.
875+
state.skipToTurnComplete = false;
876+
873877
state.isStreaming = true;
874878
this.notifySessionChange(chatId, state);
875879

@@ -1281,6 +1285,10 @@ export class TriggerChatTransport implements ChatTransport<UIMessage> {
12811285
this.activeStreams.delete(chatId);
12821286
}
12831287

1288+
// A stop that never saw its TURN_COMPLETE leaves the flag set, and the new
1289+
// turn would be skipped record by record.
1290+
state.skipToTurnComplete = false;
1291+
12841292
// Mark streaming + persist so a reload mid-action resumes (reconnectToStream
12851293
// no-ops when the persisted session says isStreaming: false).
12861294
state.isStreaming = true;

0 commit comments

Comments
 (0)