{"slug": "cron-driven-agents-autonomous-workflows-on-a-schedule", "title": "Cron-Driven Agents: Autonomous Workflows on a Schedule", "summary": "A developer outlined a pattern for building cron-driven agents that wake on a schedule rather than waiting for a prompt, arguing the architecture is simple but the hard parts are idempotency, unattended failure handling and cost control. The writeup recommends keying each scheduled run to a unique slot ID to prevent double-posting, adding model fallback via an OpenAI-compatible endpoint so a 3am outage doesn't silently break the job for a week, and routing scheduled work to cheaper models to avoid bill shock from high-frequency runs.", "body_md": "*Originally published on the [SandBase Blog](https://blog.sandbase.ai/cron-driven-agents-autonomous-workflows-2026/).*\n\n**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.\n\nMost 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.\"\n\nConcrete examples I've built or seen work well:\n\nHermes 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.\n\nReactive and cron-driven agents differ on a few axes worth being clear about:\n\n|  | Reactive agent | Cron-driven agent | \n|---|---|---|\n| Trigger | User prompt | Schedule / timer | \n| Failure visibility | Immediate (you see it) | Silent (3am, nobody watching) | \n| Cost driver | Per user request | Per scheduled run | \n| Main risk | Bad answer | Double-run, silent failure, runaway cost | \n\nAt its simplest, a cron-driven agent is a scheduler plus an agent run:\n\n``` php\nScheduler (cron) --> trigger --> Agent run --> action (Slack post, email, etc.)\n     |                              |\n     |                              +--> persist results to memory\n     +--> next scheduled time\n```\n\nThe 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.\n\n```\n# A cron-driven agent definition\njobs:\n  - name: morning-triage\n    schedule: \"0 7 * * *\"   # 7am daily\n    task: |\n      Read GitHub issues opened since 6pm yesterday.\n      Triage by severity. Post a summary to #eng-standup.\n    tools: [github, slack]\n    model: anthropic/claude-sonnet-4\n```\n\nThat's the happy path. Now the parts that actually matter.\n\nSchedulers 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.\n\nDesign every cron agent assuming it might run more than once for a single scheduled slot:\n\n`morning-triage-2026-06-04`). Before acting, check whether that key already completed.\nThis is the single most common way cron agents go wrong in production. The agent logic is fine; it just ran twice and double-posted.\n\nA 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.\n\nBuild for unattended failure:\n\n```\n# Cron agent pointed at an OpenAI-compatible endpoint (one key, many providers' models)\nOPENAI_API_BASE=https://api.sandbase.ai/v1\nOPENAI_API_KEY=your-sandbase-api-key\nMODEL=anthropic/claude-sonnet-4\n```\n\nBecause 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.\"\n\nHere'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.\n\nHow to keep cron agents cheap:\n\nRouting 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.\n\nThe 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.\n\nThis keeps cost proportional to actual events rather than to schedule frequency, which is the whole game for always-on automation.\n\n**Q: What's the difference between a cron agent and a regular scheduled script?**\n\nA 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.\n\n**Q: How do I stop a cron agent from doing something twice?**\n\nIdempotency 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.\n\n**Q: What happens if my LLM provider is down when the job fires?**\n\nWith 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.\n\n**Q: How do I keep scheduled agents from getting expensive?**\n\nRight-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.\n\n**Q: Can existing frameworks do this, or do I build it?**\n\nHermes 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.", "url": "https://wpnews.pro/news/cron-driven-agents-autonomous-workflows-on-a-schedule", "canonical_source": "https://dev.to/sandbaseai/cron-driven-agents-autonomous-workflows-on-a-schedule-50g6", "published_at": "2026-11-24 16:07:36+00:00", "updated_at": "2026-11-24 16:18:16.880419+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["SandBase", "Hermes Agent", "GitHub", "Slack", "Anthropic", "Claude Sonnet 4", "OpenAI"], "also_reported_by": [], "takeaway": "Give every scheduled agent run a unique slot key (e.g. morning-triage-2026-06-04) and check it before acting, so scheduler retries can't double-post or double-deploy.", "recommendation": {"advice": "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.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/cron-driven-agents-autonomous-workflows-on-a-schedule", "markdown": "https://wpnews.pro/news/cron-driven-agents-autonomous-workflows-on-a-schedule.md", "text": "https://wpnews.pro/news/cron-driven-agents-autonomous-workflows-on-a-schedule.txt", "jsonld": "https://wpnews.pro/news/cron-driven-agents-autonomous-workflows-on-a-schedule.jsonld"}}