An Agent That Works While You Sleep: Crons and Hooks
The problem
A personal agent is most useful when you are not talking to it. Check the parcel every morning. Tell me if the price drops. Nudge me about the dentist on Friday. Each of those starts on a clock or an event, not on a message.
Background work brings three questions:
- What starts the work: a time, or an event?
- Who does the work, and with what context?
- When is the result worth interrupting the user for, and where does it go?
Terms are in the glossary.
How this Muse instance handles it
Crons are time-based. A job has a schedule, a title the user sees in a task list, and saved instructions. It recurs until paused or removed. Timing is loose: a job fires around its time, give or take a few minutes. There is no "fire only when" condition and no quiet-hours mode unless the job's own instructions say so.
Hooks are event-based. A hook is a small script that watches for something, such as new data arriving from a connected source, and fires when it sees it. Under the hood it is still polling, so the honest promise is "I will check every so often", never "the moment it happens".
A run is a fresh background worker. It does the job on its own, then decides whether the result needs the user. If yes, the main agent gets the report as a handoff and decides what the user sees. A run that succeeded only means the work finished, not that anything reached the user.
Delivery goes to the user only. A result arrives as a chat message and a push notification. A watch cannot text a friend. If the job's work is itself to send an email, that send still stops for approval unless the user already allowed it for that job.
The run history is the truth. "Did my 7 AM check run?" is answered from the run log, not from the schedule. A job that ends blocked on something durable, such as a connector that needs reconnecting, pauses itself and tries again later.
Goals own their check-ins. A cron that serves one of the user's goals belongs to that goal and lives in the goal's folder, so the goal's history stays in one place.
Scope matches approval. A yes to "do this once" authorizes one run. Making it recur needs its own yes, with the schedule named. Every limit the user sets goes into the job's instructions, because the worker that runs it later will not see the chat.

flowchart LR C["Cron: 0 9 * * *"] --> R["Fresh agent run, own transcript"] H["Hook: new data arrived"] --> R R --> D{"Worth telling the user?"} D -- no --> Q["Log the run, stay quiet"] D -- yes --> M["Handoff to main agent"] M --> P["Chat message + push"] R --> X{"Blocked on something durable?"} X -- yes --> Z["Pause, retry at a later run"]
Step 1: store jobs as plain JSON
python# tinymuse/scheduler.py def add_job(app, cron, task, deliver_to): if not croniter.is_valid(cron): raise ValueError(f"bad cron: {cron}") jobs = load(app) job = {"id": app.new_id(), "cron": cron, "task": task, "deliver_to": deliver_to, "next": croniter(cron, datetime.now()).get_next(datetime).isoformat(timespec="minutes")} jobs.append(job) save(app, jobs) return job
The model writes a five-field cron expression. Validation happens in code, not in the prompt, so "every morning" is rejected instead of silently never firing.
Step 2: a ticker that fires due jobs
pythondef fire(app, job): run = app.chat(f"job-{job['id']}", f"Job {job['id']}") app.run_turn(run, f"[Scheduled job {job['id']} firing]\n{job['task']}", allowed_tools={"memory_search", "browse", "skill_search"}) answer = run.messages[-1]["content"] target = app.chat(job["deliver_to"]) target.add({"role": "assistant", "content": answer}) target.emit("job_message", job=job["id"], text=answer) def tick(app): now = datetime.now() jobs = load(app) for job in jobs: if datetime.fromisoformat(job["next"]) <= now: job["next"] = croniter(job["cron"], now).get_next(datetime).isoformat(timespec="minutes") save(app, jobs) # move next first so a crash never double-fires threading.Thread(target=fire, args=(app, job), daemon=True).start() def start(app, every=20): def loop(): while True: tick(app) time.sleep(every) threading.Thread(target=loop, daemon=True).start()
Three details matter:
- Each run gets its own chat (
job-<id>). The main chat's history does not ride along, which keeps runs cheap and stops one run's page dumps from leaking into the next. - Read-only tools. A run can search memory, browse and read skills. It cannot send email. Sending from a job should go through an approval, like any send.
nextmoves before the run starts. If the process dies mid-run, the job is not fired twice on restart. The cost is that a crashed run is skipped, which is the safer failure for anything that sends or buys.
python demos.py scheduler adds a job, tries a bad cron, forces the job due, and ticks once:
textadded: {"id": "fb3561af", "cron": "0 9 * * *", "task": "Check my order at http://127.0.0.1:9/none", "deliver_to": "main", "next": "2026-11-29T09:00"} rejected: bad cron: every morning next after firing: 2026-11-29T09:00 delivered to main: ['job_message']
This one ran on the fake model, pointed at a closed port, so the run's answer is an error message. It still shows the plumbing: the job fired, next moved to tomorrow, and a message was delivered to the main chat.
Run it with a real model
In the real model run, the user typed "Every day at 9 AM, check my Riverstone order status and tell me." Llama 3.3 called schedule_job with 0 9 * * *:

To get the next screenshot without waiting until 9 AM, the job's next run time was set to the past by hand, so the ticker fired it on its next pass. The run opened the order page by itself and delivered this to the main chat:

sequenceDiagram participant T as Ticker (every 20 s) participant J as jobs.json participant R as Job run (own chat) participant B as browse participant M as Main chat participant U as You T->>J: any job with next <= now? J-->>T: job 1e2a4ebd T->>J: move next to tomorrow 09:00 T->>R: fire(task) R->>B: open order page B-->>R: "Out for delivery, 4 PM to 7 PM" R-->>M: job_message M-->>U: card in chat (+ push in a real app)
What a run costs
Job run vs main chat, real model runData from the sources listed below.
The job run's prompt was 880 tokens, against 2,359 for the main chat at the time, because it starts with no history. It took 30.8 s end to end, the slowest turn of the session, since it started a browser.
What tinymuse leaves out
- Hooks. The shape is the same as
tick: a loop that checks a source and callsfirewhen something new shows up. Keep a "last seen" marker on disk so a restart does not replay old events. - The "is it worth telling?" step. tinymuse delivers every answer. A real agent should let the run decide, and stay silent when nothing changed.
- A run log. Append one line per run with its start, end, status and whether anything was delivered. That log is what answers "did it run?".
- Timezones. croniter here uses the server clock. Store the user's timezone with each job and compute
nextin it.
What to take from this
- Validate schedules in code.
- Give each run its own transcript and fewer powers.
- Decide on purpose what reaches the user, and keep a run log so "did it run?" has an answer.
Next, Part 8: the guards that stop all this autonomy from doing damage.
Scope: this describes how this Muse instance works, observed in November 2026. Meta's actual implementation may differ and change. The code is our own open reference build, tinymuse, not Meta's code.
