> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add schedules to Managed Deep Agents

> Run Managed Deep Agents on a schedule so agents act without a user message, with static declarations or runtime tools.

Schedules make a Managed Deep Agents agent proactive: it can run without a user message. Declare fixed schedules in `schedules/`, or let the agent create recurring and one-time schedules at runtime through tools you expose.

When you deploy the project, `mda deploy` provisions each declaration in `schedules/` as a LangSmith cron after the deployment is live.

Common patterns:

* **Memory refresh**: A daily or nightly cron reviews [durable memory](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-memory.md) and stores condensed learnings. Use a [persistent thread](#choose-thread-behavior) when runs should share history.
* **Proactive digests**: A fixed schedule prompts the agent to surface deadlines, open threads, or progress toward a goal. See [Add a schedule](#add-a-schedule).
* **Smart triage**: A frequent cron checks a stream such as Slack or email and notifies only when something matters. Pair with [channels](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-channels.md) and [Slack delivery](#deliver-results-to-slack).
* **Follow-ups and reminders**: Runtime tools create one-time or recurring schedules when a user asks. See [Create schedules at runtime](#create-schedules-at-runtime).
* **Orchestration check-ins**: A one-time schedule wakes the agent after a background job or subagent finishes. See [Create a one-time schedule](#create-a-one-time-schedule).

> [!NOTE]
>
> Managed Deep Agents is in **public [beta](https://docs.langchain.com/langsmith/release-stages.md)** on [LangSmith Cloud](https://docs.langchain.com/langsmith/cloud.md) and [Bring Your Own Cloud (BYOC)](https://docs.langchain.com/langsmith/byoc.md). Use Managed Deep Agents CLI and SDK v0.10 or later for BYOC.

## Project structure

Schedule declarations live in the project-level `schedules/` directory, with one schedule per file:

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
my-agent/
  agent.ts
  schedules/
    daily-digest.ts
```

## Add a schedule

The file name becomes the managed schedule name.

The schedule module must export a named `schedule` declaration.

```ts schedules/daily-digest.ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { defineSchedule } from "managed-deepagents";

export const schedule = defineSchedule({
  cron: "0 8 * * 1-5",
  timezone: "America/Los_Angeles",
  prompt: "Write the daily digest.",
});
```

## Configure schedule input

Each schedule must define exactly one of:

* `prompt`: A natural-language prompt. Managed Deep Agents converts it to a user message when the cron fires.
* `input`: A structured LangGraph input object. Use this when you need to pass custom graph input instead of a single prompt.

```ts schedules/nightly-sweep.ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { defineSchedule } from "managed-deepagents";

export const schedule = defineSchedule({
  cron: "30 2 * * *",
  input: {
    messages: [
      { role: "user", content: "Sweep stale tickets and summarize changes." },
    ],
  },
});
```

`cron` must be a standard five-field cron expression: minute, hour, day of month, month, and day of week. If `timezone` is omitted, LangSmith crons use UTC.

## Choose thread behavior

Schedules use ephemeral threads by default. Managed Deep Agents creates a fresh thread for each run and asks LangSmith to delete that temporary thread after the run completes.

Use a persistent thread when scheduled runs should share one thread history. When you omit `id`, `mda deploy` creates a thread for the schedule, keyed on the agent and schedule names. Renaming the schedule file starts a new thread. To use a specific thread, set `id` to a UUID. `mda deploy` creates the thread if it does not exist, and refuses a thread that another caller owns.

> [!NOTE]
>
> Omitting `id` requires `managed-deepagents` version 0.10.2 or later. Earlier versions require the UUID of an existing thread.

### Declare the persistent schedule

> [!NOTE]
>
> The following example requires [durable memory](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-memory.md).

```ts schedules/nightly-memory.ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { defineSchedule } from "managed-deepagents";

export const schedule = defineSchedule({
  cron: "0 3 * * *",
  prompt: "Review the current project memory and list follow-up tasks.",
  thread: { mode: "persistent" },
});
```

## Deliver results to Slack

Set `deliverTo` to post the final response through a configured [Slack channel](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-channels-slack.md).

Use a Slack channel ID because scheduled runs have no originating thread.

> [!NOTE]
>
> Schedule delivery requires `managed-deepagents` version 0.4.0 or later.

```ts schedules/monday-greeting.ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { defineSchedule } from "managed-deepagents";

export const schedule = defineSchedule({
  cron: "0 9 * * 1",
  prompt: "Write a short Monday greeting.",
  deliverTo: {
    channel: "slack",
    to: {
      type: "provider_conversation",
      conversationId: "C0123456789",
    },
  },
});
```

The Slack bot must have access to the destination.

## Use static declarations

Schedule declarations are extracted at compile time. Keep schedule configuration statically serializable:

* Use literals, arrays, objects, and references to top-level literal constants.

* Do not read environment variables, call functions, spread objects, or compute schedule values dynamically.

* Put dynamic behavior in the agent, tools, middleware, or runtime context instead.

## Test schedules locally

The TypeScript dev server does not run cron jobs. `mda dev` lists each schedule at startup and warns that schedules are not active locally.

To test the agent behavior a schedule triggers, send the schedule's `prompt` or `input` to the agent directly in local Studio. To test the schedule itself, deploy the project to a development deployment.

## Deploy schedules

Test the project locally with [`mda dev`](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-cli#develop-locally), then deploy it with [`mda deploy`](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-deploy). Open deployment traces in LangSmith to inspect model calls, tool calls, errors, and latency.

When the deployment reaches `DEPLOYED`, `mda deploy` deletes the cron jobs that earlier `schedules/` declarations created and creates cron jobs for the current declarations. Removing a local schedule file and redeploying removes the corresponding managed cron. Schedules created at runtime are unaffected.

> [!WARNING]
>
> If you deploy with `--no-wait`, the CLI triggers the remote build and exits before the deployment reaches `DEPLOYED`, so it does not reconcile schedules during that invocation. Run `mda deploy` without `--no-wait` when adding, changing, or removing schedules.

## Create schedules at runtime

> [!NOTE]
>
> Runtime schedules require `managed-deepagents` 0.9.0 or later.

Declarations in `schedules/` are fixed when you deploy. `runtime.schedules` creates schedules while the agent runs, so the agent can set up recurring or one-time work in response to a conversation. It is available on the runtime that tools and [middleware](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-middleware.md) receive, and it acts for the caller of the current run. Each schedule belongs to the current user or to the agent.

The agent reaches this API only through tools that you write. Expose the calls the agent needs, and leave out the ones it should not reach.

When a tool creates a schedule during a [channel](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-channels.md) run, such as a Slack conversation, the schedule inherits that channel. Each run posts its final answer back to it. A new thread posts a new Slack message, and the current thread replies in the existing Slack thread.

`newThread` decides which of the two a schedule uses.

Managed Deep Agents sets `runtime.schedules` on every tool and middleware runtime. Its TypeScript type is optional only because annotated tools must still match LangChain's native runtime type, so the examples use `runtime.schedules!`.

### Create a recurring schedule

`remind_me` gives the agent a way to set up a recurring reminder for the person it is talking to. The agent calls it with the prompt to run and a cron expression for how often to run it. Each time the cron fires, a new run starts with that prompt as its user message. The agent decides what each scheduled run is asked to do.

```ts tools/schedules.ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { tool } from "langchain";
import { z } from "zod";
import type { ManagedDeepAgentRuntime } from "managed-deepagents";

export const remindMe = tool(
  async ({ prompt, cron, timezone }, runtime: ManagedDeepAgentRuntime) => {
    const item = await runtime.schedules!.create({
      owner: { type: "user" },
      cron,
      timezone,
      prompt,
    });
    return `Created schedule ${item.id}.`;
  },
  {
    name: "remind_me",
    description: "Run a prompt for the current user on a cron schedule.",
    schema: z.object({
      prompt: z.string(),
      cron: z.string(),
      timezone: z.string().default("UTC"),
    }),
  },
);
```

Asked in Slack to send a standup reminder every weekday, the agent calls `remind_me`. It passes a prompt of its own wording and the cron `0 9 * * 1-5`. Each weekday run posts its answer to that Slack conversation as a new message, because `cron` schedules default to a new thread.

### Create a one-time schedule

Pass `at` in place of `cron` for work that runs once. `follow_up_later` gives the agent a way to set a single follow-up, such as checking a deploy after it finishes.

```ts tools/follow-up.ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { tool } from "langchain";
import { z } from "zod";
import type { ManagedDeepAgentRuntime } from "managed-deepagents";

export const followUpLater = tool(
  async ({ prompt, hours }, runtime: ManagedDeepAgentRuntime) => {
    const item = await runtime.schedules!.create({
      owner: { type: "user" },
      at: new Date(Date.now() + hours * 60 * 60_000),
      prompt,
    });
    return `Scheduled a one-time follow-up: ${item.id}.`;
  },
  {
    name: "follow_up_later",
    description: "Run a prompt once, a number of hours from now.",
    schema: z.object({
      prompt: z.string(),
      hours: z.number(),
    }),
  },
);
```

A one-time schedule defaults to the current thread, so its run continues the conversation that created it and replies in the same Slack thread.

### Create options

**owner** `object` *required*

`{ type: "user" }` selects the authenticated person of the current run, and the schedule runs as that person. An optional `id` must match that person. `{ type: "agent" }` selects the schedules the agent owns, which run as the agent's service identity.

**cron** `string`

A five-field cron expression for a recurring schedule. Give exactly one of `cron` and `at`.

**at** `Date | string`

A `Date`, or an ISO 8601 timestamp that ends with `Z` or a UTC offset. The schedule runs once. The runtime rounds it up to the next whole minute. It must be at least one minute and at most 365 days in the future.

**timezone** `string` (default: UTC)

An IANA time zone for `cron`, such as `America/Los_Angeles`. Do not pass it with `at`.

**prompt** `string`

A prompt that each run receives as a user message. Give exactly one of `prompt` and `input`.

**input** `object | object[]`

A structured LangGraph input for each run.

**newThread** `boolean`

`true` starts each run on a new thread. `false` continues the current thread. Defaults to `true` with `cron` and `false` with `at`.

**paused** `boolean` (default: false)

Create the schedule without running it.

**metadata** `object`

JSON metadata for your own use. Keys that start with `mda_` are reserved.

### Manage schedules

`list`, `get`, `update`, and `delete` on `runtime.schedules` cover the rest of a schedule's life. Expose them as tools when the agent should manage the schedules it created. An agent with `list` and `delete` can answer "what reminders do I have?" and cancel one on request. Pause a schedule with `update` instead of deleting it when the person wants it back later.

```ts theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
const owner = { type: "user" } as const;

const page = await runtime.schedules!.list({ owner, limit: 20 });
const item = await runtime.schedules!.get(page.items[0].id, { owner });
await runtime.schedules!.update(item.id, { paused: true }, { owner });
await runtime.schedules!.delete(item.id, { owner });
```

`update` accepts `cron`, `at`, `timezone`, `prompt`, `input`, `paused`, and `metadata`. The channel and the thread choice are fixed at creation. `list` hides expired one-time schedules unless you pass `includeExpired: true`. For the agent owner, `list` and `get` also return the schedules in `schedules/`, which you change in code.

### Schedule limits

Each owner can have at most 20 runtime schedules per agent. Paused schedules count. Expired one-time schedules and schedules in `schedules/` do not count. A create or update past the limit fails with `Schedule limit reached`.

To change the limit, set these variables in the deployment environment:

| Variable | Limit for |
| - | - |
| `MDA_MAX_AGENT_SCHEDULES` | Schedules owned by the agent |
| `MDA_MAX_USER_SCHEDULES` | Schedules owned by each user |

> [!NOTE]
>
> Schedule limits require `managed-deepagents>=0.9.3`.

## Troubleshoot schedules

* `must export a named schedule declaration`: Export a top-level `schedule` from each file in `schedules/`.

* `must define exactly one of prompt or input`: Add either `prompt` or `input`, but not both.

* `cron must be a standard 5-field expression`: Use five cron fields, not seconds-based cron syntax.

* `schedule is not static`: Replace computed values with literals or top-level literal constants.

* `failed to create cron for schedule`: Open the deployment URL in LangSmith and confirm the deployed Agent Server is healthy.

* `schedule '<name>' persistent thread id must be a UUID`: A persistent schedule declares a thread ID that is not a UUID. Earlier versions report `Invalid thread ID: must be a UUID (HTTP 422)` from the Agent Server. Replace it with a UUID, or omit `id`. See [Choose thread behavior](#choose-thread-behavior).

* `Schedule limit reached`: The owner has reached the runtime schedule limit. Delete a schedule, or raise the limit. See [Schedule limits](#schedule-limits).

* **A schedule does not run during local development**: The TypeScript dev server does not run schedules. See [Test schedules locally](#test-schedules-locally).

## Next steps

> [card] [Deploy an agent](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-deploy.md)
>
> Deploy and reconcile schedule changes.

> [card] [Paid media agent template](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-paid-media-agent.md)
>
> A full project with weekly and monthly report schedules.

> [card] [CLI reference](https://docs.langchain.com/langsmith/javascript/managed-deep-agents-cli.md)
>
> Look up `mda deploy` flags and troubleshooting.

***

[Connect these docs](https://docs.langchain.com/use-these-docs.md) to your agent of choice via MCP for real-time answers.

[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/managed-deep-agents-schedules.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
