A scheduled agent wakes up on its own, checks conditions, executes tools, writes state, and goes back to sleep. The difference between a chat agent and a scheduled agent is a timer, a state checkpoint, and idempotency logic. Cron is the simplest way to get there: a line such as 0 6 * * 1 runs the agent at 06:00 every Monday.
Before you start
A server or machine where cron can run, the agent script, and a place to store state between runs.
Write the job as a script
Write the agent job as a script that does one thing: gather yesterday’s numbers, write the summary, and send it. Give the job a goal in plain language, a model, tools, and a stop condition, because a loop that never stops costs money.
Make the job idempotent: if it runs twice, it must not send the summary twice. Record what was sent, with the date, and check the record before sending.
Add the cron line
Add a cron line for the schedule you want, such as 0 7 * * * for 07:00 every day. Keep the schedule in the job record with the goal and the next run time, so the job can be listed and changed.
Cap what the agent can schedule for itself: an agent that schedules itself can create runaway job trees if you do not cap depth or validate intervals.
Check the first run and the state
Watch the first run end to end: did it wake on time, gather the right numbers, send one summary, and write its state? Check the run log for the status, the error if any, and the conversation log.
Check the second run too: it should skip what the first run already did, because the state persisted.
Practice check: fictional Maple Corner daily summary, 07:00, 5 days
The table below is fictional practice material, worked out by hand from the stated schedule. It is the expected result for the practice job, not a run of any agent.
| Day | Woke on time | Summary sent | Duplicates | Verdict |
|---|---|---|---|---|
| Monday | Yes | 1 | 0 | Pass |
| Tuesday | Yes | 1 | 0 | Pass |
| Wednesday | Yes | 1 | 0 | Pass |
| Thursday | Yes, retried once | 1 | 0 | Pass – idempotent |
| Friday | Yes | 1 | 0 | Pass |
All five days send exactly one summary on time. Thursday’s run retried once after a tool timeout but still sent only one summary, because the job checks its sent record first.
Expected result. UNTESTED: the days in the practice table are worked out by hand, not measured by running a cron job. Write your own daily summary job with a sent record, add the cron line, and check the first two runs for duplicates.
Limits
- A scheduled agent with no state will repeat its work: persist what was sent and check it before sending.
- Cap self-scheduling: an agent that creates its own jobs can create runaway job trees.
