Introducing Schedules for Mastra Agents and Workflows

A unified API for managing automated recurring tasks

Paul ScanlonPaul Scanlon·

Jul 8, 2026

·

3 min read

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:

  1. Threadless for simple, one-shot runs
  2. 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:

GNU BashTerminal
npm install @mastra/core@latest @mastra/libsql @mastra/memory
note
Requires @mastra/core@1.50.0 or later, added in PR #18874.

Create an agent and configure Memory:

TypeScriptsrc/mastra/agents/uptime-agent.ts
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:

TypeScriptsrc/mastra/index.ts
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 thread
  • ifIdle: { behavior: "wake" } — wakes an idle thread and invokes a run

For more information and full configuration options, see:

Share:
Paul Scanlon
Paul ScanlonTechnical Product Marketing Manager

Paul Scanlon sits between Developer Education and Product Marketing at Mastra. Previously, he was a Technical Product Marketing Manager at Neon and worked in Developer Relations at Gatsby, where he created educational content and developer experiences.

All articles by Paul Scanlon