Skip to content

Commit ca1867f

Browse files
test(server): cover failed automation sends to bound threads
1 parent 213a4d1 commit ca1867f

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎apps/server/src/mcp/toolkits/thread/tools.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ const ThreadSearchTool = Tool.make("t3_thread_search", {
257257
const ScheduledTaskRunTool = Tool.make("run_scheduled_task_now", {
258258
...commandTool,
259259
description:
260-
"Run a scheduled task now through the existing scheduler. Requires a full-access/default caller. Each call is a new manual run; completion means dispatch/bookkeeping completed, not that the provider turn finished.",
260+
"Run a scheduled task now through the existing scheduler. Requires a full-access/default caller. Returns the thread this run dispatched to, or null if dispatch failed. Each call is a new manual run; completion means dispatch/bookkeeping completed, not that the provider turn finished.",
261261
parameters: Schema.Struct({ taskId: ScheduledTaskId }),
262262
success: Schema.Struct({
263263
taskId: ScheduledTaskId,

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,45 @@ it.effect.each(
375375
},
376376
);
377377

378+
it.effect(
379+
"returns no dispatched thread when sending an automation to a missing thread fails",
380+
() => {
381+
const harness = makeHarness();
382+
const layerScheduledTasks = ScheduledTasks.layer.pipe(
383+
Layer.provide(
384+
Layer.mergeAll(
385+
harness.layer,
386+
NodeCrypto.layer,
387+
Scheduler.layer,
388+
Layer.mock(SecretRequests.SecretRequests)({}),
389+
),
390+
),
391+
);
392+
return Effect.gen(function* () {
393+
const tasks = yield* ScheduledTasks.ScheduledTaskService;
394+
const threadId = ThreadId.make("thread:missing");
395+
const { task } = yield* tasks.upsert({
396+
title: "Daily audit",
397+
prompt: "Audit performance and crashes.",
398+
enabled: false,
399+
schedule: { type: "interval", everyMs: 60_000 },
400+
projectId,
401+
threadId,
402+
workspaceStrategy: { type: "root" },
403+
modelSelection,
404+
runtimeMode: "full-access",
405+
interactionMode: "default",
406+
createdBy: "user",
407+
creationSource: "web",
408+
});
409+
const result = yield* tasks.runNow({ id: task.id });
410+
assert.equal(result.task.lastRunStatus, "failed");
411+
assert.isNull(result.threadId);
412+
assert.equal(result.task.threadId, threadId);
413+
}).pipe(Effect.provide(Layer.mergeAll(harness.layer, layerScheduledTasks)));
414+
},
415+
);
416+
378417
it.effect("retains automation and sender attribution while a message waits in the queue", () => {
379418
const harness = makeHarness({ runSetup: () => Effect.never });
380419
return Effect.gen(function* () {

0 commit comments

Comments
 (0)