---
title: "Scheduled Tasks Code Agent SDK"
source: https://docs.autohand.ai/agent-sdk/automation/scheduled-tasks
---

# Scheduled Tasks

Scheduled tasks let agents run recurring work such as dependency updates, report generation, and health checks without a human prompt.

## Scheduling options

-   **Cloudflare Workers cron triggers** - run a lightweight scheduler that starts an agent session.
-   **Durable Object alarms** - persist the next run time and resume reliably after restarts.
-   **System cron** - run a local script with cron on a server or container.
-   **Workflow schedulers** - use Kubernetes CronJobs, AWS EventBridge, or GitHub Actions scheduled workflows.

## Cron trigger example

The following Cloudflare Worker runs every hour, checks for stale issues, and asks an agent to draft follow-up comments.

## Durable scheduling

For tasks that must not run twice or must resume after a crash, store state in a Durable Object. Set an alarm for the next execution time and confirm completion before scheduling the next run.

## Best practices

-   Use short timeouts for scheduled agents to avoid runaway costs.
-   Write output to durable storage, not stdout, so you can inspect results later.
-   Track the last run timestamp and avoid overlapping executions.
-   Alert on repeated failures with a separate hook.