Skip to content

Commit 32767e4

Browse files
test(server): queued message starts after the usage-limit continuation
Docs: only Send cancels a pending continuation; a queued message waits for it.
1 parent 50879cc commit 32767e4

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5015,11 +5015,45 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
50155015

50165016
yield* send(1, "queue_after_active");
50175017
yield* orchestrator.resumeQueuedRuns;
5018-
const queued = (yield* orchestrator.getThreadProjection(threadId)).runs.find(
5019-
(run) => run.userMessageId === MessageId.make(`${threadId}:1`),
5020-
);
5018+
const runFor = (index: number) =>
5019+
Effect.map(orchestrator.getThreadProjection(threadId), ({ runs }) =>
5020+
runs.find((run) => run.userMessageId === MessageId.make(`${threadId}:${index}`)),
5021+
);
5022+
const queued = yield* runFor(1);
50215023
assert.equal(queued?.status, "queued");
50225024
assert.notEqual(queued?.queueHeld, true);
5025+
5026+
yield* orchestrator.dispatch({
5027+
type: "message.dispatch",
5028+
commandId: CommandId.make(`${threadId}:2`),
5029+
threadId,
5030+
messageId: MessageId.make(`${threadId}:2`),
5031+
manualContinuationOfRunId: limited.id,
5032+
text: "Continue where you left off.",
5033+
attachments: [],
5034+
createdBy: "user",
5035+
creationSource: "web",
5036+
dispatchMode: { type: "start_immediately" },
5037+
});
5038+
const continuation = yield* runFor(2);
5039+
assert.equal(continuation?.status, "starting");
5040+
assert.equal((yield* runFor(1))?.status, "queued");
5041+
const completedAt = yield* DateTime.now;
5042+
yield* eventSink.write({
5043+
events: [
5044+
{
5045+
id: EventId.make(`${threadId}:continuation:completed`),
5046+
type: "run.updated",
5047+
threadId,
5048+
runId: continuation!.id,
5049+
providerInstanceId: continuation!.providerInstanceId,
5050+
occurredAt: completedAt,
5051+
payload: { ...continuation!, status: "completed", startedAt: completedAt, completedAt },
5052+
},
5053+
],
5054+
});
5055+
yield* orchestrator.resumeQueuedRuns;
5056+
assert.equal((yield* runFor(1))?.status, "starting");
50235057
}),
50245058
);
50255059

‎docs/user/thread-sidebar.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ When the provider reports a reset time, choose **Resume at reset** to schedule a
247247
continuation. You can cancel it from the thread. Enable **Resume after
248248
usage limits** in **Settings → Threads** to schedule limit stops by default.
249249
The environment must be running when the reset arrives; it resumes overdue
250-
continuations after a restart. Stopping the thread, sending a new message,
251-
archiving, or settling it prevents a pending continuation from starting.
250+
continuations after a restart. Stopping the thread, sending a new message with
251+
**Send**, archiving, or settling it prevents a pending continuation from starting.
252252

253253
Choose **Snooze until reset** to hide the thread until its allowance returns.
254254
Snooze and auto-resume are independent: snooze alone wakes the thread without

0 commit comments

Comments
 (0)