The task scheduler enables automated execution of agent prompts on a schedule. In v2, tasks are stored asDocumentation Index
Fetch the complete documentation index at: https://docs.nanoclaw.dev/llms.txt
Use this file to discover all available pages before exploring further.
messages_in rows with kind='task' — there is no separate task table. Task operations flow through the MCP tool / delivery action pipeline.
Task model
Tasks in v2 aremessages_in rows in inbound.db with:
kind='task'process_after— ISO timestamp for when the task should runrecurrence— optional cron expression for recurring tasksseries_id— links all occurrences of a recurring task
MCP tools (container-side)
Tasks are managed via MCP tools inside the container. Each tool writes akind='system' outbound message that the host’s delivery pipeline routes to the appropriate handler.
schedule_task
Creates a new task:kind='task' row in inbound.db with the specified process_after and recurrence. A series_id is set to the task’s own ID.
cancel_task
Marks all live rows in the task’s series ascompleted and nulls the recurrence:
pause_task
Toggles a pending task topaused status:
resume_task
Toggles a paused task back topending status:
update_task
Merges content updates in-place. Matches by ID orseries_id:
update_task returns 0 when no live row matches, triggering a system notification back to the agent (“no live task matched”).Host-side processing
Host sweep
The host sweep (60s interval) handles task lifecycle:- Due-message wake — finds tasks where
process_after <= nowand wakes containers - Processing_ack sync — reads acknowledgments from
outbound.dbto mark tasks completed - Recurrence advancement —
getCompletedRecurring()finds completed rows with non-null recurrence;insertRecurrence()creates the next-run row
Sequence numbers
All host-written messages (including tasks) use even-parity sequence numbers vianextEvenSeq(). Container-written messages use odd parity. This prevents sequence number collisions.
Recurring task series
Each recurring task occurrence gets a newmessages_in row:
- All rows in a series share the same
series_id - When a recurring task completes, the host creates a new pending row with the next
process_after cancel_taskmarks all live rows in the series as completed and nulls recurrenceupdate_taskmatches byseries_idto hit the live next-occurrence row
Schedule types
Cron (via recurrence)
cron-parser with the configured TIMEZONE environment variable.
One-time (no recurrence)
process_after is reached. After completion, no new row is created.
Task scripts
When a task has ascript field, the agent-runner executes it before invoking the agent:
- Script runs with a 30-second timeout
- Script outputs JSON:
{ "wakeAgent": true/false, "data": {...} } - If
wakeAgentisfalse, the task completes silently - If
wakeAgentistrue, the agent is invoked with script data
Script contract
Example
Scripts have a 30-second timeout and 1 MB output limit. For tasks running more than roughly twice a day, always include a script to minimize agent wake-ups.
Configuration
process.env.TZ, then .env file, then system default, with IANA validation.