Skip to content

Schedules

Arivie supports scheduled workflows through defineSchedule / defineSchedules in ArivieConfig. Schedules compile to Mastra Workflows with cron triggers, so the same agent that answers ad-hoc questions can also run recurring reports.

  • Daily/weekly metric recaps emailed to leadership.
  • Automated anomaly alerts when a KPI crosses a threshold.
  • Periodic data-quality checks against the semantic layer.

Schedules are an array of ArivieSchedule objects passed to defineArivie:

import { defineArivie, defineSchedule } from "@arivie/core";
const dailyRecap = defineSchedule({
id: "daily-recap",
cron: "0 9 * * 1-5", // 9 AM, weekdays
prompt: "Run the daily-recap skill for yesterday and write the result to reports/daily-recap.md",
});

Then wire into config:

defineArivie({
// ...
schedules: [dailyRecap],
});

Each schedule compiles to a Mastra Workflow with:

  • A single step that calls agent.generate(prompt) as the owner user
  • A Mastra cron schedule that supplies the prompt via inputData
  • Memory scoped to thread: "schedule-<id>", resource: owner.id
import { defineSchedules } from "@arivie/core";
const schedules = defineSchedules([
{ id: "daily-recap", cron: "0 9 * * 1-5", prompt: "Generate yesterday's revenue recap" },
{ id: "weekly-trends", cron: "0 10 * * 1", prompt: "Summarize this week's order trends" },
]);

Schedules share the same agent, sources, semantic layer, and skills as the rest of the instance.

Terminal window
pnpm dlx arivie add schedule daily-recap

This creates a schedule file and wires it into arivie.config.ts.

Mastra’s workflow engine evaluates the cron expression and invokes the agent with the configured prompt. The host app is responsible for deploying the workflow scheduler in production (e.g. Mastra’s built-in runner, a separate worker, or a platform cron service).