Skip to content

Commit 174ba12

Browse files
committed
fix(sdk): seed the custom-loop resume cursor without a continuation gate
The wire can omit the continuation flag on a run that still has prior turns. The cursor scan doubles as the prior-state probe (a fresh session has no turn-complete on .out and seeds nothing), so run it on every custom-loop boot instead of gating on continuation or attempt number, mirroring the snapshot-exists arm of chat.agent's boot check.
1 parent 1a935dd commit 174ba12

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • packages/trigger-sdk/src/v3

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,12 @@ export async function __findLatestSessionInCursorForTests(
242242
async function seedSessionInResumeCursorForCustomLoop(
243243
payload: Pick<ChatTaskWirePayload, "chatId" | "continuation">
244244
): Promise<void> {
245-
const attemptNumber = taskContext.ctx?.attempt.number ?? 1;
246-
if (payload.continuation !== true && attemptNumber <= 1) return;
247245
if (sessionStreams.lastSeqNum(payload.chatId, "in") !== undefined) return;
246+
// No continuation/attempt gate: the wire may omit `continuation` on a
247+
// run that still has prior turns (chat.agent covers that case via its
248+
// snapshot). The scan doubles as the prior-state probe — a fresh
249+
// session has no turn-complete on `.out`, returns no cursor, and
250+
// seeds nothing. Cost on fresh boots is one non-blocking records read.
248251
try {
249252
const cursor = await findLatestSessionInCursor(payload.chatId);
250253
if (cursor !== undefined) {

0 commit comments

Comments
 (0)