# Cron-Driven Agents: Autonomous Workflows on a Schedule

> Source: <https://dev.to/sandbaseai/cron-driven-agents-autonomous-workflows-on-a-schedule-50g6>
> Published: 2026-11-24 16:07:36+00:00

**Recommendation:** Key each cron run to its scheduled slot and check completion before acting, and add a one-line model fallback so unattended jobs fail loudly instead of silently.
More in the playbook "Running AI in production": <https://wpnews.pro/playbooks/production-ops>

*Originally published on the [SandBase Blog](https://blog.sandbase.ai/cron-driven-agents-autonomous-workflows-2026/).*

**TL;DR** — A cron-driven agent runs on a schedule instead of waiting for you to prompt it — daily summaries, monitoring, recurring research. The architecture is simple (scheduler triggers agent run), but the hard parts are idempotency (what if it runs twice?), failure handling (what if the LLM is down at 3am?), and cost control (an agent that wakes up every minute gets expensive fast). Here's how to build one that won't surprise you with a bill.

Most agents are reactive: you ask, they answer. A cron-driven agent flips this — it wakes up on a schedule and does work without anyone prompting it. Build a cron-driven agent and you move from "tool you operate" to "colleague who handles things while you're away."

Concrete examples I've built or seen work well:

Hermes Agent ships a cron system as one of its five pillars precisely because scheduled autonomy is what separates an assistant from a tool. Let's build the pattern.

Reactive and cron-driven agents differ on a few axes worth being clear about:

|  | Reactive agent | Cron-driven agent | 
|---|---|---|
| Trigger | User prompt | Schedule / timer | 
| Failure visibility | Immediate (you see it) | Silent (3am, nobody watching) | 
| Cost driver | Per user request | Per scheduled run | 
| Main risk | Bad answer | Double-run, silent failure, runaway cost | 

At its simplest, a cron-driven agent is a scheduler plus an agent run:

``` php
Scheduler (cron) --> trigger --> Agent run --> action (Slack post, email, etc.)
     |                              |
     |                              +--> persist results to memory
     +--> next scheduled time
```

The scheduler can be literal cron, a cloud scheduler, or a framework's built-in cron (like Hermes'). When it fires, it kicks off an agent run with a predefined task ("summarize overnight issues"), the agent does its work using whatever tools it has, takes an action, and persists anything worth remembering.

```
# A cron-driven agent definition
jobs:
  - name: morning-triage
    schedule: "0 7 * * *"   # 7am daily
    task: |
      Read GitHub issues opened since 6pm yesterday.
      Triage by severity. Post a summary to #eng-standup.
    tools: [github, slack]
    model: anthropic/claude-sonnet-4
```

That's the happy path. Now the parts that actually matter.

Schedulers retry. Networks hiccup. Your 7am job might fire twice if the first run times out and the scheduler retries. If your agent isn't idempotent, that means two Slack posts, two emails, or worse — two purchases, two deployments.

Design every cron agent assuming it might run more than once for a single scheduled slot:

`morning-triage-2026-06-04`). Before acting, check whether that key already completed.
This is the single most common way cron agents go wrong in production. The agent logic is fine; it just ran twice and double-posted.

A reactive agent's failure is visible — you're sitting there, you see the error. A cron agent fails silently at 3am while you sleep. You find out when the morning summary never arrives.

Build for unattended failure:

```
# Cron agent pointed at an OpenAI-compatible endpoint (one key, many providers' models)
OPENAI_API_BASE=https://api.sandbase.ai/v1
OPENAI_API_KEY=your-sandbase-api-key
MODEL=anthropic/claude-sonnet-4
```

Because one SandBase key covers models from many providers, the fallback is a one-line change of `MODEL` in your retry logic. For unattended automation, that retry path is the difference between "ran fine" and "silently broken for a week."

Here's the bill-shock scenario: you set a monitoring agent to run every minute, each run loads 3000 tokens of context and calls a frontier model, and a month later you're staring at a surprising invoice. An agent that wakes up 1,440 times a day adds up.

How to keep cron agents cheap:

Routing scheduled work through SandBase lets you assign a cheap model to high-frequency jobs and a strong one to the occasional heavy task, all from the same setup.

The cron agents that work in production share a shape: a cheap, fast "should I do anything?" check that runs frequently, escalating to expensive reasoning only when warranted. The monitoring agent that pings you only when a metric breaks is the canonical example — 99% of runs are a cheap no-op, 1% are a real alert.

This keeps cost proportional to actual events rather than to schedule frequency, which is the whole game for always-on automation.

**Q: What's the difference between a cron agent and a regular scheduled script?**

A scheduled script runs fixed code. A cron agent runs an LLM reasoning loop on a schedule — it can adapt to what it finds, use tools dynamically, and make judgment calls a static script can't. The tradeoff is it's less predictable and costs tokens per run.

**Q: How do I stop a cron agent from doing something twice?**

Idempotency keys. Tag each scheduled run with a unique identifier and check whether it already completed before taking any irreversible action. Gate side effects (posts, emails, purchases) behind that check, even if you let the reasoning re-run freely.

**Q: What happens if my LLM provider is down when the job fires?**

With a single provider, the job fails silently. Add a retry on a second provider's model (one SandBase key covers several) so the run doesn't just die. Also add a dead-man's switch that alerts when an expected run hasn't succeeded.

**Q: How do I keep scheduled agents from getting expensive?**

Right-size the schedule (every 15 min beats every minute), use cheap models for routine runs, trim the context you load each run, and short-circuit early so most runs do almost nothing. Cost should track real events, not schedule frequency.

**Q: Can existing frameworks do this, or do I build it?**

Hermes Agent has a built-in cron system. For others, you can pair a scheduler ([system cron](https://man7.org/linux/man-pages/man5/crontab.5.html), cloud scheduler) with an agent run. The scheduling is the easy part — idempotency, failure handling, and cost control are what you actually need to design.
