You can now run your agents and workflows on schedules. Configure them using cron syntax and a default prompt for agents or inputData for workflows — letting you more easily set a cadence for recurring tasks.
Agent schedules have two modes:
- Threadless for simple, one-shot runs
- Threaded for when conversation context is required
Both run types can be traced, but only threaded runs show up in an agent's conversation history.
Workflow schedules have no thread mode — each run behaves like a standard invocation.
Before schedules, running a workflow meant configuration lived on the workflow definition, and to schedule agent runs, you'd need to call them using .generate() or .stream() from a workflow step, or by adding the agent as a step.
Schedules unify the approach. Both agents and workflows can now be managed using a CRUD-like API with methods for .create(), .delete(), .pause(), .resume(), and .run(). Additional lifecycle hooks are available to help manage errors, or trigger actions when a run completes.
Get started
Install the latest @mastra/core, @mastra/memory (for the thread), and a storage adapter that supports the schedules domain:
npm install @mastra/core@latest @mastra/libsql @mastra/memory@mastra/core@1.50.0 or later, added in PR #18874.Create an agent and configure Memory:
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";
import { pingUrlTool } from "../tools/ping-url-tool";
export const uptimeAgent = new Agent({
id: "uptime-agent",
name: "Uptime Agent",
instructions: "Check the URL and report the status in one sentence.",
model: "anthropic/claude-opus-4-8",
tools: { pingUrlTool },
memory: new Memory()
});Set the scheduler to enabled: true, and register your agent and storage adapter:
import { Mastra } from "@mastra/core/mastra";
import { LibSQLStore } from "@mastra/libsql";
import { uptimeAgent } from "./agents/uptime-agent";
export const mastra = new Mastra({
agents: { uptimeAgent },
scheduler: { enabled: true },
storage: new LibSQLStore({ url: "file:./mastra.db" })
});In this example a memory thread is created so the schedule's underlying signal knows which thread to send its message to.
import { mastra } from "../mastra";
const resourceId = "uptime-monitor";
const threadId = "uptime-thread";
const agent = mastra.getAgent("uptimeAgent");
const memory = await agent.getMemory();
await memory.createThread({
threadId,
resourceId,
title: "Scheduled Uptime"
});
await mastra.schedules.create({
id: threadId,
agentId: "uptime-agent",
cron: "0 * * * *", // Runs every hour on the hour
prompt: "Check https://mastra.ai and report the uptime.",
threadId,
resourceId,
signalType: "user",
ifIdle: { behavior: "wake" }
});signalType: "user"— renders as a user message in the threadifIdle: { behavior: "wake" }— wakes an idle thread and invokes a run
For more information and full configuration options, see:
