Skip to content

Scheduled work & tasks

Sometimes you don’t want the agent to act now. You want it to act later, or every morning, or once an hour. Atomic Agent lets you schedule work: a message the agent will run on its own at a time you choose.

A scheduled job is just a normal turn with a clock attached. You give it a prompt (“summarize my git log and email me”), pick when it should fire (--at, --cron, or --every), and Atomic Agent persists it to disk. A single background timer wakes up, finds what’s due, and runs it, retrying automatically if something fails.

The task queue is a SQLite file in your state directory, and one scheduler timer polls it. Scheduled tasks fire only while an Atomic Agent process is running (the desktop app, the TUI or atomic-agent serve); there is no separate background daemon, and runs missed while nothing was running fire once on the next start. A scheduled turn uses whichever model provider is active, like any other turn.

The desktop app and the TUI share ~/.atomic-agent, so when both are open only one of them runs due tasks. If Telegram is set up, the process that holds the Telegram connection runs them, so reports can go out. Otherwise the one that started first runs them. When it quits, the other takes over on its next tick.

Three ways to schedule

A task carries an optional schedule. Leave it off and the task runs as soon as it’s drained. Add one of three schedule kinds ("at", "interval" from --every, or "cron" in the stored JSON) and it fires on a clock. Note the one-shot kind is the literal string "at"; there is no "one-shot" value, though that’s the word this page uses for the behavior.

One-shot (--at)

Run once at a specific time (Unix milliseconds or a strict ISO-8601 time), then stop.

Interval (--every)

Run every N seconds until you stop it. Re-armed after each successful run.

Cron (--cron)

Run on a 5- or 6-field cron expression (e.g. 0 9 * * 1, 9am every Monday), with optional timezone.

Quick start

In the desktop app, open Cron jobs in the sidebar (Cmd/Ctrl+2) and press New task. Write one sentence in What should the agent do, and when? and press Ask the agent: the agent opens a new chat and sets up the schedule with its task tools. Set up manually opens a form with the schedule kind (cron, interval or at), the message and a preview of the next runs; press Create task to save it.

From the terminal, create a task with atomic-agent task create. The --message is the prompt the agent will run when the task fires. Pick at most one of --at, --every and --cron; --tz works only with --cron.

Terminal window
# Run once, about 1 hour from now (--at takes Unix milliseconds or ISO-8601)
atomic-agent task create \
--message "Check the build status and summarize failures" \
--at $(($(date +%s) * 1000 + 3600000))

--at also takes a strict ISO-8601 time, for example --at 2026-12-01T09:00. A date-time without Z or an offset is your machine’s local time; a date alone (YYYY-MM-DD) is midnight UTC. A time in the past runs on the next scheduler tick, and the CLI warns you about it.

Inspect and manage tasks:

Terminal window
atomic-agent task list # all tasks (default limit 100)
atomic-agent task list --status pending,failed --limit 20
atomic-agent task show <id> # one task as JSON
atomic-agent task cancel <id> # idempotent cancel
atomic-agent task pause <id> # the scheduler skips it until resumed
atomic-agent task resume <id> # a recurring task is armed for its next firing from now
atomic-agent task runs <id> # past runs, newest first, as JSON

pause works only on a waiting (pending) task, not on one that is running. Resuming a recurring task skips the firings it missed while paused. In the desktop app, the task page has the same controls: Pause/Resume, Run now, Open session and Cancel task.

Cost and time caps

A task can carry its own money cap and time limit:

Terminal window
atomic-agent task create --message "refresh the changelog" \
--max-cost-usd 2 --max-duration 1h30m

--max-duration takes 90s, 30m, 8h or 1h30m (a bare number is seconds). Local models without a price count as $0. Both default to the agent.task.* keys in Configuration. A run that reaches a cap stops with a closing summary; a task whose budget is already spent when it comes up again is blocked. See Overnight runs for one long unattended task.

Getting the result: --notify telegram

A scheduled task runs while you’re not watching, so by default its output just lands in the task’s own chat. Add --notify telegram and the runner reports the task’s final result to your paired Telegram chat when it finishes:

Terminal window
atomic-agent task create \
--message "Summarize my git activity from yesterday" \
--cron "0 9 * * 1-5" \
--tz "Europe/Berlin" \
--notify telegram

--notify accepts telegram or push; anything else is rejected at create time. telegram requires Telegram to be configured and paired (see the Telegram guide for setup). push sends a short phone notification through ntfy instead; turn it on first with atomic-agent push on and subscribe to the topic it prints in the ntfy app. The choice is stored on the task (notify in the task show JSON). The rest of this section describes the Telegram report.

Failures notify too. This is the whole point of turning it on for an unattended job: a report is sent for completed, failed, and blocked. If your 9am summary stops arriving, you find out because a ⛔ blocked message arrives instead, not by noticing weeks later that nothing has run.

Reports are sent for exactly three statuses, and never for anything else:

StatusReports?Why
completedyesThe happy path, with the reply text.
failedyesRetry budget exhausted.
blockedyesPermanent failure or missing session.
retry (running → pending)noA retry is not an outcome yet; you’d get a message per attempt.
cancellednoOperator-initiated or shutdown-driven; you already know.

What the message contains

Every report is a plain-text DM to the paired owner carrying:

  • A status line: ✅ Scheduled task completed, ❌ Scheduled task failed, or ⛔ Scheduled task blocked.
  • The task’s prompt, flattened to one line and cut to 120 characters, with the schedule kind (cron, interval or one-shot) and the task id.
  • A meta line: attempt count and duration (Attempt 2/3 · took 1m 12s), plus steps, why the run stopped, and spend when known.
  • In words: on completed, the agent’s final reply, up to 1,200 characters.
  • Done, Failed and Needs you sections: files changed, commands run, errors, approvals nobody gave, and questions the agent asked.
  • On failed or blocked, the error message, capped at 500 characters.

A whole report stays under Telegram’s message limit. Truncated excerpts always end in … [truncated], so a cut is never silent.

If Telegram is not paired, the report is skipped with a warning in the log. If Telegram is set up but offline, the report is queued and sent when the bot reconnects.

Quiet hours

By default a report goes out as soon as the task ends, even at 3 a.m. To hold reports at night, set a local-time window before you start the agent:

Terminal window
export ATOMIC_AGENT_TASKS_REPORT_QUIET_HOURS=23:00-08:00

Reports of tasks that finish inside the window are held and sent when it ends. Several held reports go out together as one morning report with counts of completed, failed and blocked tasks. Quiet hours are off unless you set this variable, and a malformed value turns them off with a warning.

How the scheduler works

The scheduler owns a single setInterval. Every tick (ATOMIC_AGENT_TASKS_SCHEDULER_TICK_MS, default 5000ms) it wakes, asks the task store for everything that’s due right now, and hands up to ATOMIC_AGENT_TASKS_SCHEDULER_BATCH tasks (default 10) to the runner.

flowchart TD
    Tick["setInterval<br/>every tickMs (5s)"] --> Guard{running?}
    Guard -->|yes| Skip["skip this tick<br/>(no pile-up)"]
    Guard -->|no| Due["TaskRunner.runDue(now, batch)"]
    Due --> Query["TaskStore.listDue(now)<br/>scheduled_for ≤ now"]
    Query --> Group["group by session<br/>(per-session FIFO)"]
    Group --> Run["run N tasks in parallel<br/>across sessions"]
    Run --> Turn["runtime.runTurn<br/>(through TurnController)"]
    Turn --> Outcome{outcome}
    Outcome -->|success + recurring| Requeue["requeue: reset attempts,<br/>compute next scheduled_for"]
    Outcome -->|success + one-shot| Done["terminal: completed"]
    Outcome -->|retryable failure| Backoff["backoff, mark pending,<br/>retry within budget"]
    Outcome -->|budget exhausted| Failed["terminal: failed"]
    Outcome -->|permanent failure<br/>or missing session| Blocked["terminal: blocked<br/>(no retry, no recovery)"]
    Requeue --> NextTick["picked up on a later tick"]
    Run -->|error| Log["log warning,<br/>record metric, never crash"]

A few properties that fall out of this design:

  • No pile-up. If a tick takes longer than tickMs, the next fire is skipped while the previous one is still draining. Ticks never stack.
  • Failures are contained. A bad task logs a warning and records an error metric, but never crashes the polling loop.
  • Cross-session parallelism, per-session FIFO. One tick can run tasks from many independent sessions at once, but tasks within a single session always run in order, serialized through the TurnController.
  • Single-use. Once the scheduler is stopped (at shutdown) it can’t be restarted in the same process.

Task lifecycle

Each task is a durable row in tasks.sqlite that moves through a small state machine.

  • A task is created pending (with a schedule, or null for immediate execution).
  • When drained, it’s claimed pending → running, the session is loaded (or created), and runtime.runTurn executes the message.
  • On success: one-shot tasks become terminal (completed); recurring tasks are requeued: attempts/errors/times reset and scheduled_for is rearmed to the next firing.
  • On a retryable failure: the task moves running → pending, a backoff delay is applied, and it retries until maxAttempts is exhausted, at which point it becomes failed.
  • On a permanent failure, when the session can’t be loaded, or when the task’s budget is already spent, the task skips retries entirely and becomes blocked.
  • A waiting task can be paused (pending → paused) and resumed (paused → pending). The scheduler never picks a paused task. Run now in the desktop app runs it once and leaves it paused.

failed vs blocked: two different endings

They are not two names for the same outcome. Only one of them is about the retry budget.

StatusWhy it happensWhat to do
failedThe retry budget ran out. Every attempt up to maxAttempts was tried and each one failed with a retryable (transport) error.Usually transient. Re-create the task once the underlying service is back.
blockedThe failure was classified permanent (grammar or tool), the task’s session could not be loaded or recreated (session_not_found: <id>), or its money budget was already spent. No retries are attempted at all.Fix the cause first (recreate the session, fix the prompt or tool, or raise the budget), then re-create the task.

Two consequences worth internalising:

  • blocked can happen on attempt 1. The failure classifier returns tool as its catch-all for any error it doesn’t recognise, so an unexpected exception is treated as permanent and blocks immediately, with maxAttempts untouched. A task showing blocked after one attempt is not a bug.
  • blocked is terminal with no way out. It is one of the terminal statuses, and no CLI command, HTTP route, or agent tool transitions a task out of it. task resume works only on paused tasks. The only path forward is to create the task again, after recreating its session if that was the cause.

Sessions: lazy vs persistent

  • One-shot tasks created without a sessionId get a lazily-allocated ephemeral session at first execution.
  • Recurring tasks get one persistent session at create time, reused across every firing, so there’s no row-per-firing duplication. If that session goes missing, recurring tasks auto-recreate it.

Stale recovery

If the process crashes mid-task, rows stuck in running would otherwise be orphaned. On bootstrap, the task store flips a running row back to pending when the process that claimed it is gone, so it gets picked up again. For an old row that records no owner, it falls back to age: older than ATOMIC_AGENT_TASKS_STALE_AFTER_MS.

Letting the agent schedule its own work

When task tools are enabled, the agent can schedule follow-ups for itself mid-conversation (“remind me in an hour”, “check this every morning”). These are the same durable tasks, created from inside a turn.

ToolWhat it does
tasks.scheduleSchedule a one-shot task: { userMessage, at?, inSeconds?, newSession?, notify? } (at in epoch ms, or inSeconds from now). Inherits the current session unless newSession is set.
tasks.cronCreate a recurring task from a 5- or 6-field cron expression: { userMessage, expression, tz?, notify? }. Each firing runs in its own persistent session, not the caller’s.
tasks.listQuery tasks, optionally filtered by session/status.
tasks.showFetch one task.
tasks.cancelCancel a task (idempotent).

notify takes "telegram" or "push", as on the CLI. These tools are gated by the ATOMIC_AGENT_TASKS_AGENT_TOOLS_ENABLED environment variable (default true). When it’s false, they don’t appear in the registry at all, so the agent can’t see or call them.

Running tasks without the scheduler

For cron jobs, CI, or manual ops, you can drain due tasks once without starting the long-lived scheduler:

Terminal window
atomic-agent task tick --limit 50 # one-shot drain of everything due now
atomic-agent task run <id> # run a specific task
atomic-agent task run --all-pending # drain all pending tasks

Over HTTP (when running atomic-agent serve):

Terminal window
# Create a task: userMessage plus sessionId (or workingDir) are required
curl -X POST http://127.0.0.1:8787/api/tasks \
-H "Authorization: Bearer $ATOMIC_AGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sessionId": "s-abc123", "userMessage": "Summarize today’s commits", "maxSteps": 15}'
# List (filters: ?session=, ?status=, ?limit=), inspect, cancel, run
curl -H "Authorization: Bearer $ATOMIC_AGENT_API_KEY" "http://127.0.0.1:8787/api/tasks?status=pending"
curl -H "Authorization: Bearer $ATOMIC_AGENT_API_KEY" http://127.0.0.1:8787/api/tasks/<id>
curl -X DELETE -H "Authorization: Bearer $ATOMIC_AGENT_API_KEY" http://127.0.0.1:8787/api/tasks/<id>
curl -X POST -H "Authorization: Bearer $ATOMIC_AGENT_API_KEY" http://127.0.0.1:8787/api/tasks/<id>/run # explicit drain

Webhooks: events as scheduled work

Incoming webhooks become tasks too. A POST /api/webhooks/{name} doesn’t call runTurn directly: it renders the payload against the webhook’s userMessageTemplate and materializes a task via the task runner. That keeps webhook-triggered work on the same per-session FIFO and retry path as everything else. A webhook binding in config.json can also carry a schedule, which makes the tasks it creates recurring.

Configuration

Scheduling is configured only with ATOMIC_AGENT_TASKS_* environment variables (in your shell or <stateDir>/.env). There is no tasks block in config.json; one written there is ignored.

VariableDefaultPurpose
ATOMIC_AGENT_TASKS_ENABLEDtrueMaster kill switch for the whole task subsystem.
ATOMIC_AGENT_TASKS_SCHEDULER_ENABLEDtrueWhether the background scheduler is constructed and started.
ATOMIC_AGENT_TASKS_SCHEDULER_TICK_MS5000Polling interval, in milliseconds.
ATOMIC_AGENT_TASKS_SCHEDULER_BATCH10Max tasks consumed per tick (more independent sessions can fire in parallel).
ATOMIC_AGENT_TASKS_MAX_ATTEMPTS3Retry budget per task before it’s terminal.
ATOMIC_AGENT_TASKS_BACKOFF_INITIAL_MS1000First inter-attempt backoff delay.
ATOMIC_AGENT_TASKS_BACKOFF_MAX_MS60000Backoff ceiling.
ATOMIC_AGENT_TASKS_RUN_ON_CREATEtrueDrain immediately when a task that is already due is created through the task runner (HTTP, webhooks, agent tools).
ATOMIC_AGENT_TASKS_STALE_AFTER_MS300000Age after which a running row is recovered to pending on bootstrap.
ATOMIC_AGENT_TASKS_AGENT_TOOLS_ENABLEDtrueWhether the agent’s tasks.* tools are registered.

| ATOMIC_AGENT_TASKS_REPORT_QUIET_HOURS | unset (off) | Hold task reports in this local-time window, e.g. 23:00-08:00, and send them after it. | | ATOMIC_AGENT_TASKS_KEEP_AWAKE | unset (off) | while-working keeps the computer awake while a task or turn runs. A closed MacBook lid still sleeps the Mac. |

ATOMIC_AGENT_TASKS_MIN_INTERVAL_MS (default 1000) is the floor the task runner applies to a new interval schedule; a shorter one is rejected. You can raise it, not lower it below 1 second.

Scheduling caveats

These are the behaviours people are most often surprised by. None of them are bugs: they follow from the scheduler being a simple due-poller over a durable queue, but they change how you write a schedule.

Missed runs are not caught up

A task that is overdue fires once, no matter how many slots went by while the process was down. Ten missed hourly firings do not become ten runs; they become one. The store simply asks for rows whose scheduled_for is at or before now, and running the task rearms it.

If your job must not skip work, make each run self-correcting (“summarise everything since the last summary”) rather than assuming it fires exactly once per slot.

Interval tasks drift forward

The next firing of a recurring task is computed from its completion time, not from the slot it was supposed to occupy. An interval schedule resolves to completedAt + everyMs, so every run pushes the next one further out by however long the run itself took.

A --every 3600 task whose turns take five minutes does not fire at :00 every hour. It fires roughly every 65 minutes, and the offset keeps growing. Over a day that is hours of drift.

Timezones apply to cron only

tz is passed to the cron parser and nowhere else. An at schedule is an absolute epoch timestamp and an interval is a fixed number of milliseconds. Neither has any notion of a calendar, so neither tracks DST. An interval job that lines up with 09:00 local time today will be an hour off after the clocks change; only cron with a tz holds the local hour.

Bounds enforced at create time

BoundValueApplies to
Minimum interval1,000 ms--every / interval
Maximum horizon10 years ahead--at
Cron expression length200 chars--cron
User message16,000 charsall tasks

All of these are rejected up front, before anything is written to disk. A bad shape surfaces as a CLI exit code 1 or an HTTP 400, never as a silent failure inside a tick.

Retry backoff is deterministic

The delay before retry N is min(initialMs * 2^(attempt-1), maxMs): 1,000 ms then 2,000, 4,000, 8,000, clipped at 60,000 ms by default. There is no jitter. If a shared dependency knocks out many tasks at once, they will all retry in lockstep rather than spreading out, so a flapping service can see synchronised bursts.

Backoff applies only to within-attempt retries. The gap between recurring firings comes from the schedule, not from backoff.

Stale recovery runs once, at startup

Rows stuck in running are reclaimed by a single pass on bootstrap: a row whose claiming process is gone (or, for a row with no recorded owner, whose started_at is older than ATOMIC_AGENT_TASKS_STALE_AFTER_MS, default 5 minutes) is flipped back to pending. There is no background sweeper.

The consequence: a task orphaned inside a still-running process is never reclaimed. If a turn hangs without throwing, its row sits in running for as long as the process lives. Recovery only helps after a crash and restart.

Other limits

  • No scheduling through POST /api/tasks: it takes no schedule field (webhooks can carry one).
  • The first interval run fires one interval after creation, not immediately.
  • Imported schedules: atomic-agent import can bring enabled cron jobs over from Hermes and OpenClaw as native tasks. See Import.
  • Heartbeat: atomic-agent task heartbeat create makes a recurring task that goes through a checklist file (every 30 minutes by default, at least 5) and writes to you only when there is news. See atomic-agent task heartbeat --help.

Tasks reference

Full task store lifecycle, status transitions, and HTTP/CLI surfaces.

Get updates by email

One email when a new version comes out.