Files
agent-zero/plugins/_scheduler/AGENTS.md
Alessandro 9048880222 Catch up recurring scheduler tasks after downtime
Persist the schedule anchor and run overdue idle tasks once on the next tick, coalescing missed occurrences instead of relying on a one-minute lookback. Preserve pending work across ordinary edits, reset timing when schedules or states change, and carry the anchor through JSON, YAML and public serializers.

Recheck eligibility when claiming a run and keep one worker per task to prevent stale selections and repeated ticks from launching duplicates. Calculate cron delays in the task timezone across daylight-saving changes. Document disabled, failed and interrupted-task behavior in the scheduler and its skill.

Validate with 195 focused regression tests. In the live Docker stop/start test, the enabled marker-only task ran exactly once 93 seconds after its missed slot; the disabled task remained untouched, two extra ticks caused no replay, and existing tasks were unchanged.
2026-11-13 12:07:03 +01:00

4.4 KiB
Raw Permalink Blame History

Scheduler Plugin DOX

Purpose

  • Own the scheduler agent tool and the Scheduled Tasks UI for managing saved tasks and schedules.

Ownership

  • tools/scheduler.py owns action dispatch, timezone normalization, cron/plan validation, and agent-facing task CRUD.
  • The tool logs its message as type scheduler with an icon://calendar_month Schedule: <action> headline; extensions/webui/get_message_handler/ owns the SCH badge presentation and extensions/webui/get_process_step_types/ registers the type.
  • prompts/ owns the tool prompt and the framework repair messages.
  • api/ owns the scheduler CRUD HTTP endpoints (scheduler_task_create, scheduler_task_delete, scheduler_task_run, scheduler_task_update, scheduler_tasks_list); core api/scheduler_tick.py stays with the scheduling engine.
  • webui/scheduler/ owns the Scheduled Tasks modal (store, modal, detail, editor, list) and webui/css/ owns the scheduler styles loaded through the plugin page-head extension.
  • webui/sidebar/ owns the sidebar tasks list and its store, injected through the sidebar-extensions extension point.
  • extensions/webui/sidebar-extensions/ owns the plugin contribution to that extension point.
  • extensions/webui/sidebar-quick-actions-dropdown-start/ owns the Scheduled Tasks dropdown button, moved after the Files item via x-move-after.
  • extensions/webui/welcome-actions-start/ owns the Scheduled Tasks card on the welcome screen, contributed through the welcome-actions-start point and using the shared Quick Actions tile layout.
  • extensions/webui/page-head/ owns the scheduler and datepicker asset loading; core webui/index.html owns the shared flatpickr preload.
  • plugin.yaml and README.md own metadata and docs.
  • webui/thumbnail.jpg owns the 256×256 plugin catalog artwork, kept below 20 KB.

Local Contracts

  • The tool and API endpoints delegate to the shared helpers.task_scheduler engine, which stays in core and is also used by api/scheduler_tick.py, helpers/job_loop.py, chat lifecycle endpoints, and _chat_naming.
  • Recurring tasks catch up once after missed schedules on the next engine tick. Changes to cron/timezone or re-enabling a disabled task start a new schedule from that moment; ordinary edits preserve an overdue run. Keep timing in the engine and preserve its serialized schedule_anchor during full-task round trips.
  • The plugin declares always_enabled: true: the core scheduling engine keeps running tasks it created even when plugin code is absent, so the plugin must not be disableable into a state where tasks run without any way to manage them.
  • Plugin API routes resolve as /api/plugins/_scheduler/<handler> via the standard plugin API resolution in helpers/api.py.
  • Core snapshot and chat-selection consumers import the always-enabled plugin's tasks store directly, ensuring it exists before the first snapshot even when the sidebar has not mounted.
  • Timezone aliases (local/user/default/current/current_timezone) resolve via helpers.localization; cron validation rejects malformed expressions before task creation.
  • wait_for_task polls task state until completion, failure, or idempotent runs.
  • Plugin-owned tasks carry plugin_name and run through the engine's deterministic hook. Their schedule, name and state remain editable; the editor hides model prompts/attachments and detail shows the operation. The engine rejects changing those inapplicable inputs and creates no chat for these tasks.
  • Close task detail by its modal path and await closure before opening its editor, so asynchronous close hooks cannot remove the new modal from the stack.

Work Guidance

  • Keep tool output concise, model-readable, and safe for history persistence.
  • Coordinate argument or behavior changes with the tool prompt and the shared task scheduler engine.
  • Respect intervention flow for long waits and user-visible task operations.

Verification

  • Import the tool and API endpoints in the framework runtime and run the scheduler tool, timezone, tool contract, and webui extension surface tests after changes.
  • For scheduler editing, run pytest tests/test_scheduler_editor.py and check prompt expansion, draft retention, and save/reopen on desktop and mobile.

Child DOX Index

Direct child DOX files:

Child Scope
extensions/webui/sidebar-extensions/AGENTS.md Sidebar tasks section extension contribution.