Skip to content
Sign up
Deploy and scale

Scheduling messages

Schedule agent messages at specific times or recurring intervals.

Schedule messages to be sent to your agent at a specific time or on a recurring basis. This enables autonomous agent behaviors like daily summaries, periodic check-ins, and scheduled maintenance tasks.

Schedule a message to be sent at a specific time:

import os
from letta_client import Letta
import time
client = Letta(api_key=os.getenv("LETTA_API_KEY"))
# Schedule a message for 1 hour from now
scheduled_time = int(time.time() * 1000) + (60 * 60 * 1000)
response = client.agents.schedule.create(
agent_id=agent.id,
schedule={"type": "one-time", "scheduled_at": scheduled_time},
messages=[{"role": "user", "content": "Generate your daily summary report"}]
)
print(f"Scheduled message ID: {response.id}")
print(f"Will execute at: {response.next_scheduled_at}")

Schedule a message to be sent on a recurring basis using a cron expression:

# Schedule a message to run every day at 9 AM UTC
response = client.agents.schedule.create(
agent_id=agent.id,
schedule={"type": "recurring", "cron_expression": "0 9 * * *"},
messages=[{"role": "user", "content": "Good morning! Review overnight alerts and summarize."}]
)
print(f"Recurring schedule ID: {response.id}")
print(f"Next execution: {response.next_scheduled_at}")
AspectOne-timeRecurring
Use caseSingle future eventPeriodic tasks
Configurationscheduled_at (Unix ms)cron_expression
ExecutesOnce, then removedRepeatedly until deleted
ExampleMeeting reminderDaily summary

One-time messages execute at a specific timestamp and are automatically removed after execution.

  • scheduled_at: Unix timestamp in milliseconds (not seconds)
  • Must be in the future - scheduling in the past returns a 400 error
from datetime import datetime, timedelta
# Schedule for tomorrow at 2 PM UTC
tomorrow_2pm = datetime.utcnow().replace(
hour=14, minute=0, second=0, microsecond=0
) + timedelta(days=1)
scheduled_at = int(tomorrow_2pm.timestamp() * 1000)
response = client.agents.schedule.create(
agent_id=agent.id,
schedule={"type": "one-time", "scheduled_at": scheduled_at},
messages=[{
"role": "user",
"content": "Reminder: Team standup starts in 15 minutes. Prepare your update."
}]
)

Recurring messages use cron expressions to define the schedule. They continue executing until explicitly deleted.

Letta uses standard 5-field cron expressions:

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sunday=0)
│ │ │ │ │
* * * * *
PatternExpressionDescription
Every 5 minutes*/5 * * * *Frequent monitoring
Every hour0 * * * *Hourly tasks
Daily at 9 AM0 9 * * *Morning summaries
Daily at midnight0 0 * * *End-of-day processing
Weekdays at 9 AM0 9 * * 1-5Business day tasks
Weekly on Monday0 9 * * 1Weekly reports
First of month0 0 1 * *Monthly tasks
# Run daily at midnight UTC to clean up agent memory
response = client.agents.schedule.create(
agent_id=agent.id,
schedule={"type": "recurring", "cron_expression": "0 0 * * *"},
messages=[{
"role": "user",
"content": "Review your memory blocks for outdated information. Archive completed tasks and consolidate redundant entries."
}]
)

Retrieve all active scheduled messages for an agent:

response = client.agents.schedule.list(agent_id=agent.id)
for msg in response.scheduled_messages:
print(f"ID: {msg.id}")
print(f"Next run: {msg.next_scheduled_time}")
if msg.schedule.type == "recurring":
print(f"Cron: {msg.schedule.cron_expression}")
print("---")

Get details about a specific scheduled message:

scheduled_msg = client.agents.schedule.retrieve(
agent_id=agent.id,
scheduled_message_id="sm-abc123"
)
print(f"Next execution: {scheduled_msg.next_scheduled_time}")

Delete a scheduled message to prevent future executions:

client.agents.schedule.delete(
agent_id=agent.id,
scheduled_message_id="sm-abc123"
)
print("Schedule cancelled")

Daily summaries: Schedule morning briefings that review overnight activity and prepare the agent for the day.

Memory maintenance: Periodic cleanup of agent memory blocks to remove outdated information and consolidate entries.

Proactive check-ins: Regular prompts that ask the agent to review pending tasks or check on long-running processes.

System monitoring: Scheduled health checks where the agent reviews logs, metrics, or external systems.

Deadline reminders: One-time messages triggered before important events or deadlines.

  1. All times are UTC: Cron expressions and timestamps are interpreted as UTC. Account for timezone differences when scheduling.

  2. Timestamps are milliseconds: The scheduled_at field uses Unix timestamps in milliseconds, not seconds. Multiply seconds by 1000.

  3. Validate cron expressions: Invalid cron expressions return a 400 error. Use a cron expression validator to test expressions before scheduling.

  4. Handle errors gracefully: Scheduling in the past returns a 400 error. Always check that your scheduled time is in the future.

  5. Clean up unused schedules: Recurring schedules continue until deleted. Periodically review and remove schedules that are no longer needed.