Add nightly briefing program — and a file on the machine the next morning:
What the agent builds
A loop that wakes often and asks a question about the calendar. The question is the whole design:state["last"] is the last date it actually ran, written to a file on the
machine. So the loop is not counting hours since it started — it is asking
whether today’s has been done. Three consequences, and they are the difference
between a job that runs once a day and a job that runs whenever the process
happened to be restarted:
- A machine that was off at 07:00 runs the briefing the moment it comes back.
- A machine restarted three times before noon runs it once.
- The loop’s own sleep interval does not have to be exact. The one above sleeps five minutes at a time.
programs/nightly/main.py, as the agent wrote it
programs/nightly/main.py, as the agent wrote it
What to say
The time, and which clock. The machine’s clock is UTC —date and date -u
give the same answer on it — so “every morning at 7” becomes 07:00 UTC unless you
say otherwise. If you are in Berlin and mean 7 your time, say so; the agent can
do the arithmetic, but only if it knows there is arithmetic to do.
Where the result should go. This is the part people leave out. “Write it to a
file”, “mail it to me at …”, “put it in the notes” are all different programs.
The example above writes a file, which is the cheapest option and the one you
have to go and look at. Ask for mail if you want to be told.
What it should read. A schedule is only as good as its input. “Read
/home/daytona/expenses.csv” is a job; “summarise what happened” is not, unless
the agent already knows where “what happened” lives.
That it should survive a restart. Say “make restarting it harmless” and you
get the state file above. Without it, a restarted loop can run the job twice in
one day.
What “started” means, and how it ends
The agent starts the program the ordinary way, in its sandbox:On a paid plan the machine has no idle timeout — it runs until somebody stops
it — so in practice this comes up after a deliberate stop or a restart rather
than on its own. Plans has the per-plan detail.
Checking it
The state file says when it last ran. On the machine:Changing it and stopping it
A change to the program’s code needs the loop restarted to take effect — it is a
running Python process, not a file the platform re-reads. The agent knows that;
if you change something and nothing happens the next morning, “did you restart
it?” is the question.
Have it reach you
The same shape, triggered by a message arriving instead of by the clock.
A nightly job, end to end
The whole conversation, from the ask to the first morning it fired.

