Add scheduled tasks (one-off and cron) run by the agent #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "scheduled-tasks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The agent can now act without a user message. A schedule is either a
one-off (run_at) or recurring (a 5-field cron expression evaluated in
the server's TZ), and runs in a chosen conversation or in a new
conversation per run. They're stored in a new schedules table; deleting
a schedule's conversation sends later runs to new conversations.
The scheduler (server/scheduler.ts) ticks every 15s and fires due
schedules by adding the prompt as a user message with meta.scheduled.
startAgent moved into agent/loop.ts and can emit that message as a run
event, so open tabs see the turn appear. toChatMessages() prefixes it
with a <scheduled_task> note so the model knows nobody typed it just
now. A run missed while the server was down fires once, late; one-offs
are deleted after firing; a schedule whose conversation is busy stays
due until the run there ends. Recurring schedules may not fire more
often than every 5 minutes.
server/cron.ts is a small parser with no new dependency: lists,
ranges, steps, names, @daily-style aliases, and Vixie's either-day
rule. When clocks go back, fixed-time jobs run once in the repeated
hour and hourly jobs run in both passes.
The agent gets schedule_create/_list/_update/_delete tools, and the
system prompt states the time zone. Settings → Schedules lists, creates,
edits, pauses, deletes and runs schedules now. A finished scheduled run
sends a new
schedulednotification kind, with its own toggle soreminders arrive even when finished-run notifications are off.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com