Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix(task): start cron schedules by default (#17709)

YuTengjing5af4f096df76
diff --git a/packages/builtin-tool-task/src/systemRole.test.ts b/packages/builtin-tool-task/src/systemRole.test.ts
new file mode 100644
index 00000000000..ff9a4092567
--- /dev/null
+++ b/packages/builtin-tool-task/src/systemRole.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, it } from 'vitest';
+
+import { systemPrompt } from './systemRole';
+
+describe('systemPrompt', () => {
+ it('starts a configured cron schedule by default without running it immediately', () => {
+ expect(systemPrompt).toContain(
+ 'start its schedule by default with updateTaskStatus(identifier, "scheduled")',
+ );
+ // Guard against re-arming running or already scheduled tasks: updateStatus
+ // interrupts in-flight runs when leaving 'running', and re-entering
+ // 'scheduled' resets the maxExecutions counting window.
+ expect(systemPrompt).toContain('neither currently running nor already scheduled');
+ expect(systemPrompt).toContain('Never call updateTaskStatus on a currently running task');
+ expect(systemPrompt).toContain(
+ 're-calling updateTaskStatus would reset its execution-count window',
+ );
+ expect(systemPrompt).toContain('Do NOT call runTask just to start the schedule');
+ // Draft/paused intent must be an explicit 'paused' status: the cron
+ // dispatcher picks up schedule-mode tasks in any non-excluded status,
+ // including 'backlog', so merely leaving the task unstarted is not enough.
+ expect(systemPrompt).toContain('call updateTaskStatus(identifier, "paused") instead');
+ });
+});
diff --git a/packages/builtin-tool-task/src/systemRole.ts b/packages/builtin-tool-task/src/systemRole.ts
index ccfb564d42c..19f44f05f42 100644
--- a/packages/builtin-tool-task/src/systemRole.ts
+++ b/packages/builtin-tool-task/src/systemRole.ts
@@ -19,6 +19,8 @@ Schedule fields (setTaskSchedule):
- **heartbeatInterval**: seconds between ticks; used by heartbeat mode (recommend β‰₯600s). Pass 0 to clear
- **maxExecutions**: cap on total scheduled runs; null means unlimited
+After configuring a cron-based schedule (automationMode="schedule") on a task that is neither currently running nor already scheduled, start its schedule by default with updateTaskStatus(identifier, "scheduled") so it waits for the next scheduled run. When the user explicitly asks to keep it paused or as a draft, call updateTaskStatus(identifier, "paused") instead β€” a schedule-mode task left in any other non-terminal status is still picked up by the cron dispatcher. Never call updateTaskStatus on a currently running task just to arm the schedule β€” that interrupts the in-flight run, and the task returns to "scheduled" automatically once the run completes. A task already in "scheduled" stays armed after schedule edits β€” re-calling updateTaskStatus would reset its execution-count window. Do NOT call runTask just to start the schedule β€” runTask executes the task immediately.
+
Verify fields (setTaskVerify):
- **enabled**: true to require a verify gate when the task completes, false to disable, null to clear
- **requirement**: a one-sentence description of what "done" means for the task; the server synthesizes acceptance criteria from it. This is usually all you need