Skip to content

Commit 1765118

Browse files
committed
fix(server): honor stop when batching queued messages
1 parent cdf3a98 commit 1765118

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,12 +1476,20 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
14761476
readonly queuedRunId?: RunId;
14771477
},
14781478
) {
1479-
if (options?.endedRunId !== undefined) {
1479+
if (
1480+
options?.endedRunId !== undefined &&
1481+
(yield* serverSettings.getSettings.pipe(Effect.orDie)).batchQueuedMessages
1482+
) {
14801483
const before = yield* readCommandProjection(threadId);
14811484
const ended = before.runs.find((run) => run.id === options.endedRunId);
1482-
const held =
1485+
const stopped =
14831486
ended?.status === "completed" &&
1484-
(yield* serverSettings.getSettings.pipe(Effect.orDie)).batchQueuedMessages
1487+
(yield* projectionStore.getThreadRecords(threadId, ["turnItems"], {
1488+
turnItemTypes: ["run_interrupt_request"],
1489+
turnItemRunIds: [ended.id],
1490+
})).turnItems.length > 0;
1491+
const held =
1492+
ended?.status === "completed" && !stopped
14851493
? before.runs.filter((run) => run.status === "queued" && run.queueHeld === true)
14861494
: [];
14871495
if (held.length > 0) {

‎apps/server/src/orchestration-v2/QueuedRunBatch.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function batchableMessage(
4747
message.workflowScript === true ||
4848
message.scheduledTaskId !== undefined ||
4949
message.idleCompaction !== undefined ||
50+
message.text.trimStart().startsWith("/") ||
5051
isNativeMaintenanceCommand(message) ||
5152
parseGoalCommand(message) !== null
5253
) {

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ export function ChatSettingsPanel() {
12281228
{...searchableSetting("batch-queued-messages")}
12291229
serverScoped
12301230
settingKeys={["batchQueuedMessages"]}
1231-
description="When a turn ends, start every queued message on the thread together as one turn instead of one turn each."
1231+
description="When a turn ends, start up to 20 compatible queued messages on the thread together as one turn instead of one turn each."
12321232
resetAction={
12331233
settings.batchQueuedMessages !== DEFAULT_UNIFIED_SETTINGS.batchQueuedMessages ? (
12341234
<SettingResetButton

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ export const SETTINGS_SEARCH_ITEMS = [
546546
{
547547
id: "batch-queued-messages",
548548
title: "Send queued messages together",
549-
to: "/settings/chat",
549+
to: "/settings/maintenance",
550550
scope: "environment-defaults",
551551
searchTerms: ["queue queued messages batch combine together one turn release drain follow up"],
552552
},

‎docs/user/composer.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Press **Resume** in an empty composer on web and desktop, or **Resume queue** on
214214
continue. Sending a new message also resumes the queue, unless it steers a turn that is already
215215
running. You can edit or remove held messages without starting them.
216216

217-
With **Settings → Chat → Send queued messages together** on, queued messages start together as
217+
With **Settings → Maintenance → Send queued messages together** on, up to 20 compatible queued messages start together as
218218
one turn when the agent finishes, in order with their senders. The setting is off by default, and a
219219
completed turn releases held messages.
220220

0 commit comments

Comments
 (0)