Documentation menu
Documentation

Scheduling

Run one-time, delayed, recurring, and cron work inside the agent that owns it.

Schedule methods by name

A scheduled callback is a method on the agent. Use a number for seconds from now, a Date for a specific time, a cron expression for calendar schedules, or scheduleEvery() for fixed intervals.

example
async onStart() {
  await this.scheduleEvery(60, "checkInbox");
  await this.schedule("0 9 * * 1-5", "dailyBrief");
}

async remind(taskId: string) {
  const schedule = await this.schedule(15 * 60, "sendReminder", { taskId });
  return schedule.id;
}

async sendReminder(payload: { taskId: string }) {
  // durable callback
}

Inspect and cancel

Use getScheduleById(), listSchedules(), and cancelSchedule(). Recurring and cron calls are idempotent where documented, which makes onStart() a safe place to ensure a recurring schedule exists.