Zum Inhalt springen
Plugins

input_source Plugin

Scheduled Tasks

Ships as the bundled `scheduled_tasks` plugin, enabled by default. Disabling it from Admin -> Plugins stops schedules firing and removes the Schedules pages, nav entries, repository tab, and chat tools; the schedules an operator already configured are kept, and come back when it is re-enabled. When the optional `calendar` plugin is enabled, Scheduled Tasks contributes operator-accessible repository tasks to Calendar. Calendar expands cron/RRULE and one-shot occurrences only for its requested window and the task's active lifetime, using each task's stored timezone, and correlates past slots with their Jobs and Workflows. Paused, auto-paused, fired, skipped, and failed executions remain visible there with links back to the owning task or Job; archiving stops the task's occurrence timeline at the archive time. Coworker-owned tasks are deliberately excluded because the Coworkers plugin owns their presentation. Disabling Calendar does not change scheduling or task firing.

scheduled_tasksQuellcode

Scheduled Tasks

Ships as the bundled scheduled_tasks plugin, enabled by default. Disabling it from Admin -> Plugins stops schedules firing and removes the Schedules pages, nav entries, repository tab, and chat tools; the schedules an operator already configured are kept, and come back when it is re-enabled.

When the optional calendar plugin is enabled, Scheduled Tasks contributes operator-accessible repository tasks to Calendar. Calendar expands cron/RRULE and one-shot occurrences only for its requested window and the task's active lifetime, using each task's stored timezone, and correlates past slots with their Jobs and Workflows. Paused, auto-paused, fired, skipped, and failed executions remain visible there with links back to the owning task or Job; archiving stops the task's occurrence timeline at the archive time. Coworker-owned tasks are deliberately excluded because the Coworkers plugin owns their presentation. Disabling Calendar does not change scheduling or task firing.

ScheduledTasks::Task lets operators attach recurring or one-shot agent prompts to a repository. The agent runs on schedule without requiring a GitHub issue.

A fired Job records where it came from through the generic jobs.origin / jobs.origin_id columns (origin: "scheduled_tasks") rather than a scheduled_task_id foreign key, so core can render and link the origin without knowing what a schedule is -- and degrades to plain text when the plugin is disabled.

Creating tasks

Tasks are usually created from a repository's Schedules tab (/repositories/:id/scheduled_tasks/new), which is already scoped to that repository. Creating or mutating a task requires write-tier repository access. Firing re-checks the task owner's write access, and auto-pauses the task instead of creating a Job if that access has been removed. The top-level /scheduled_tasks index also has a "New scheduled task" button; since that page isn't scoped to any repository, it presents a mandatory repository picker first (GET /api/v1/app/scheduled_tasks/new lists the operator's writable active repositories) and, once a repository is chosen, hands off to the same per-repository form and createScheduledTask(repositoryId, ...) submit path used by the repo-scoped flow. Repository recommendation CTAs also use the repository-scoped form and may include a preset query parameter so the form opens with the repository selected plus a suggested name, cadence, prompt, and pile-up policy even when the operator has not created the matching cron template.

Task kinds

cron

Fires on a recurring wall-clock schedule stored canonically as an RRULE-compatible expression plus a validated IANA time zone. New tasks and templates default to the configured server time zone; existing rows keep their stored zone, including legacy UTC schedules. Operators enter natural cadence text such as Every Monday at 9:00 AM; five-field cron input (minute hour day-of-month month day-of-week) is also accepted and preserved in legacy_cron_expression for audit/compatibility. Cron lists, ranges, and steps are supported, including day-of-week forms such as 1-5, */2, and 1-5/2; both 0 and 7 mean Sunday. When day-of-month and day-of-week are both restricted, a date matching either field fires, following cron OR semantics (the canonical expression carries an X-SYRUS-CRON-DAY-OR=TRUE marker because standard RRULE combines those fields with AND). Recurring tasks fire at most once per hour — expressions that would fire more frequently are rejected.

# Fire at 9:00 AM in the task's stored time zone every Monday
Every Monday at 9:00 AM

The minute is honored exactly. Calendar schedules retain their local wall time across offset changes. A nonexistent spring-forward time is skipped, and a duplicated fall-back time fires once. Hourly schedules remain fixed elapsed intervals. Occurrence instants and due windows are converted to UTC for storage, comparison, deduplication, and execution. Fire-time scheduling is deterministic and does not call an AI provider.

Tiered cadence parsing

Schedules::CadencePreview (used by both ScheduledTask/CronTemplate save and the preview_schedule API endpoints) resolves cadence text in three tiers:

  1. Strict cron detection — Schedules::RecurringSchedule.cron_shaped?

only routes input to the cron parser when every one of the five whitespace-separated fields independently looks like cron syntax (*, integers, ranges, steps, comma lists). Five *words* — e.g. Every day at 10 am — are never misrouted into the cron parser just because they happen to split into five tokens.

  1. Deterministic natural language — a small set of supported phrasings

(Every day at 10 am, Every Monday at 9:00 AM, daily at 14:30, and variants) parse without any AI call. Spaced/uppercase meridiem (10 am, 10 AM) and compact meridiem (10am) are equivalent.

  1. LLM fallback — only when steps 1–2 both fail, and only for input

that isn't cron-shaped-but-invalid. Schedules::CadenceLlmFallback sends the raw text to Gemini (via the operator's own User#gemini_api_key) and asks for structured intent only (frequency/day/month/hour/minute plus a confidence/ambiguous signal) — never an executable schedule. The fallback fails closed (no schedule is saved) when: the user has no Gemini key configured, the model reports low confidence or flags the request ambiguous, or the returned intent is incomplete. A usable result is then run back through the *same deterministic* Schedules::RecurringSchedule.preview(structured_intent:) path used by tier 2, so validation/canonicalization/explanation is identical either way and nothing executable ever comes directly from the model.

The scheduler itself (PollScheduledTasksJob, ScheduledTask#next_fire_at, #due?) only ever reads the already-canonicalized schedule_expression — no LLM call happens at fire time, regardless of which tier resolved the schedule at save time.

one_shot

Fires once at a future datetime (fire_at). After firing, the task moves to fired (terminal) state.

Task states

StateMeaning
scheduledActive, waiting to fire
pausedManually paused by the operator
auto_pausedPaused automatically after too many consecutive failures
firedOne-shot task has completed (terminal)

PR pileup policy

pr_pileup_policy controls what happens when the previous fire's PR is still open at the next tick:

PolicyBehavior
skip (default)Don't fire if an open PR already exists
pileFire regardless; multiple open PRs accumulate
replaceCancel the old Job and fire a new one

Fire handlers for plugin-owned task targets

Plugins can route selected task rows to another Job and workflow without changing ScheduledTasks::Fire. Register a handler as a reversible while_enabled effect:

scope.effect("scheduled task fire handler") do
  ScheduledTasks::FireHandlers.register(target: :example, handler: Example::FireHandler) do |task|
    task.respond_to?(:example_id) && task.example_id.present?
  end
end

Handlers inherit ScheduledTasks::FireHandlers::Base, implement fire!(now:), and return the created Job with its scheduled_task_id set to the firing task. Their applicable_behaviors declaration is empty by default; include PR_PILEUP_POLICY and PR_BASED_AUTO_APPROVAL only when those PR-oriented scheduled-task policies apply. The built-in default handler declares both and keeps the existing cron Job plus initial or skill workflow behavior.

The shared fire service still owns row locking, due-window deduplication, repository write authorization, fire timestamps, and one-shot state transitions for every handler. Returning the registration's teardown from scope.effect removes the handler when its plugin is disabled.

When a scheduled agent reaches an authorization boundary, equivalent later fires reuse the active request and associate their Jobs with it. Only the fire that creates the request opens an authorization checkpoint; later fires may still perform useful ungated work. A short denial cooldown and a per-agent, per-capability active-request cap prevent recurring schedules from repeatedly asking for the same authority.

Auto-pause

When consecutive_failure_count reaches AppSetting.max_job_failures (default: 3), the task transitions to auto_paused. The operator must unpause the task (via admin UI or Rails console: task.update!(state: 'scheduled', consecutive_failure_count: 0)) to re-enable it.

An auto-paused task stops firing silently -- nothing about it looks different from a task nobody has touched in a while, which is exactly what makes it easy to miss. While enabled, the plugin exports syrus_scheduled_tasks_autopaused_total (a gauge) to /metrics (see docs/engineering/operations/metrics.md): the count of tasks currently in the auto_paused state, so a silently-stopped cron task shows up on a dashboard the same way a stalled queue does. It uses the declarative sample-block form of the manifest metrics DSL (gauge :autopaused_total do ... end, see Syrus::PluginApi::Definition#metrics), so it is sampled once a minute on the shared control-plane tick (SampleGlobalMetricsJob, the same tick core samplers use) rather than on ScheduledTasks::Callbacks#on_tick's own poll cadence or on the /metrics scrape path. Like every plugin metric, disabling the plugin removes the series entirely rather than freezing it at its last value.

When the metrics_dashboard plugin is also enabled, Scheduled Tasks contributes its own "Scheduled Tasks" tab there (ScheduledTasks::MetricsDashboardTabs, registered under metrics_dashboard's hosted "metrics_dashboard:tab" point -- see plugins/metrics_dashboard/docs/syrus_docs/metrics_dashboard.md), charting autopaused. The tab is absent, not empty, whenever either plugin is disabled.

The "no changes" happy path

Cron tasks should be written so the agent can succeed even if there's nothing to do. The canonical pattern: the agent surveys the repo state, calls the available submit_summary MCP tool name with a one-line note like "No changes needed," and the Job closes with reason not_needed. This is counted as a success and does not increment consecutive_failure_count.

CronTemplate

CronTemplate is a per-user reusable schedule plus either a prompt or skill configuration that multiple ScheduledTask rows can reference. Applying a template copies its canonical schedule, task source, and pr_pileup_policy into the task at creation time. Later edits to the template do not retroactively update existing tasks.

Templates are managed from the user's settings page. Useful when the same survey or maintenance prompt runs across many repositories.

Seeded defaults

A brand-new Syrus installation seeds three starter templates (CronTemplate::DEFAULT_TEMPLATES) for the first user created — the installation's bootstrap admin — so /cron_templates isn't empty on day one:

TemplateCadencePurpose
Deduplicate codeWeekly, Monday 9:00 AM server timeFinds and consolidates duplicated logic
Keep documentation up to dateWeekly, Wednesday 9:00 AM server timeAudits docs against recent code changes
Increase test coverageWeekly, Friday 9:00 AM server timeAdds tests for under-covered, high-risk code

They're seeded once via User#seed_default_cron_templates (an after_create callback gated on being the very first User row) and are ordinary templates from then on — operators can edit, disable, or delete them like any other. CronTemplate.seed_defaults_for(user) is idempotent (find_or_create_by! on name), so re-running it is a no-op. Later signups don't get a copy.

Skill-based tasks

A task can fire a named skill (see skills.md) instead of a freeform prompt: set skill_name plus a skill_args hash instead of prompt. This is additive — existing freeform tasks are unaffected, and a task carries exactly one or the other (the prompt column is nullable and only required when skill_name is blank).

At save time, skill_name must resolve to a real skill (repo-local override or built-in) for the task's repository, and skill_args must satisfy that skill's declared parameter schema — the same validation SkillJobs::Creator runs for an immediate skill Job launch. On fire, ScheduledTaskFire creates a kind=cron Job carrying skill_name/skill_args and dispatches a Workflows::Skill (trigger_kind skill) instead of Workflows::Initial, deferring the actual instruction rendering to the run_skill step (Skills::Renderer/Prompts::Skill) — the same rendering path a direct skill Job launch uses, so a repo-local skill that changed (or was removed) since the task was last saved surfaces as a normal Run failure rather than wedging the poller.

pr_pileup_policy and auto-pause-on-failure behave identically for skill-based and freeform tasks — both are just Job outcomes tracked against the parent ScheduledTask. The New/Edit scheduled task form lets an operator toggle between "Freeform prompt" and "Skill", reusing the same skill picker + schema-driven parameter form used to launch a one-off skill Job from a repository.

Templates support the same exactly-one-of prompt-or-skill choice. While authoring a skill template, the operator chooses a repository so the existing skill picker and schema-driven argument controls can resolve its current definition. The repository is only validation context and is not stored on the reusable template. Applying the template validates the copied skill and arguments against the target repository, so a removed skill or changed schema produces an actionable form-save error. If the definition drifts only after the task has been saved, the existing run_skill resolution path reports a normal Run failure.

Variables in prompts

Cron task prompts support these interpolation variables, rendered at fire time:

VariableValue
{{repo_slug}}owner/repo of the target repository
{{last_fired_at}}ISO 8601 timestamp of the previous fire (empty on first fire)

How tasks fire

Scheduled tasks are repository automation, not chat reminders. The chat schedule_recurring tool first creates a pending action for operator confirmation. Confirming creates the task; every later fire creates a new background cron Job and Workflow. It does not wake or resume the chat that requested it. Use schedule_wakeup instead when the desired result is a future turn in the same chat, including “remind me here,” conditional follow-ups, and chained rechecks. Wakeups are one-shot, require no confirmation, and do not create repository Jobs.

PollScheduledTasksJob runs every minute. For each due task it:

  1. Creates a Job with kind=cron, linked via scheduled_task_id.
  2. Creates an initial Run whose prompt is pre-rendered at fire time.
  3. Enqueues RunJob — the standard workflow pipeline takes over from there.

The Job runs on the branch syrus/scheduled-<task_id>-<job_id>.

Admin API

Bearer-token admin clients can inspect and operate scheduled tasks instance-wide through /api/v1/admin/scheduled_tasks and /api/v1/admin/cron_templates — list/filter, view detail (cron expression, pr_pileup_policy, consecutive failure count, last/next fire time), and pause/unpause/fire a task without a browser session. Authoring stays UI-only. See website/src/content/docs/api.md (Scheduled Tasks section) for the full surface. With the plugin disabled, every endpoint answers plugin_disabled.

Per-user scheduling pause

Set User#scheduling_paused = true to pause all scheduled tasks for a user without touching individual tasks. PollScheduledTasksJob skips paused users entirely. Operators can toggle this via the admin UI; users can toggle it in /credentials/edit.

Chat tool permissions

The chat tools that manage scheduled tasks declare permission capabilities, so persistent automation goes through the same policy, audit, and attention routing as other consequential effects. Listing, reading, and pausing are automatic (pausing only removes autonomy). Creating and editing a task ask by default and can be covered for the current chat session. Resuming, firing now, and deleting ask for the exact invocation. Creation and immediate firing still return a pending confirmation, and write access to the repository is checked again when the approved action runs.