Skip to main content
The Palyra scheduler is a central background subsystem within palyrad responsible for the automated execution of agent tasks. It manages traditional cron-based scheduling, interval-based triggers, and unified “Routines”—automation units that combine prompts, triggers, and delivery policies into a single manageable entity.

System Architecture

The scheduling system operates as a background loop within the daemon, interacting with the JournalStore for persistence and the Gateway for run dispatching.

Code Entity Mapping

System ConceptCode EntityFile Path
Scheduler Loopspawn_scheduler_loopcrates/palyra-daemon/src/cron.rs#252-252
Routine RegistryRoutineMetadataRecordcrates/palyra-daemon/src/routines.rs#188-188
Cron MatcherCronMatchercrates/palyra-daemon/src/cron.rs#129-129
Misfire PolicyCronMisfirePolicycrates/palyra-daemon/src/journal.rs#35-35
API Surfaceconsole_routines_list_handlercrates/palyra-daemon/src/transport/http/handlers/console/routines.rs#154-154

Data Flow Diagram: Task Scheduling & Dispatch

Sources: crates/palyra-daemon/src/cron.rs#42-43, crates/palyra-daemon/src/cron.rs#252-270, crates/palyra-daemon/src/cron.rs#500-520

Cron & Scheduling Logic

Palyra implements a custom cron parser and matcher that supports standard 5-field expressions (minute, hour, day, month, weekday) crates/palyra-daemon/src/cron.rs#140-156.

Schedule Types

The system supports three primary schedule types defined in ParsedSchedule:
  1. Cron: Standard cron expressions with configurable timezone modes (Utc or Local) crates/palyra-daemon/src/cron.rs#123-123.
  2. Every: Interval-based execution (e.g., every 10 minutes) crates/palyra-daemon/src/cron.rs#124-124.
  3. At: One-time execution at a specific RFC3339 timestamp crates/palyra-daemon/src/cron.rs#125-125.

Misfire & Concurrency Policies

When a task is missed (e.g., daemon was offline), the CronMisfirePolicy determines behavior: Concurrency is managed via CronConcurrencyPolicy, allowing Forbid (skip if previous run still active) or Allow (parallel execution) crates/palyra-daemon/src/journal.rs#34-35.

Routines: Unified Automation Units

Routines represent a higher-level abstraction than raw cron jobs. They encapsulate the “What” (Prompt), “When” (Trigger), and “How” (Delivery) of an automation.

Routine Components

A RoutineMetadataRecord includes:

Code Association: Routine Management

Sources: crates/palyra-daemon/src/routines.rs#35-41, crates/palyra-daemon/src/routines.rs#69-74, crates/palyra-daemon/src/routines.rs#188-203

Management Surfaces

HTTP API (Console V1)

The daemon provides a comprehensive set of endpoints for managing routines via the Axum web server:

Web Console Integration

The Web Console (apps/web) provides a “Cron” section for visual management. It uses the CronSection component to display a table of routines, their next scheduled run times, and their last execution outcomes apps/web/src/console/sections/CronSection.tsx#153-181.

Internal Maintenance Tasks

The scheduler also handles internal daemon maintenance that does not use the standard Routine infrastructure: Sources:
  • crates/palyra-daemon/src/cron.rs
  • crates/palyra-daemon/src/routines.rs
  • crates/palyra-daemon/src/journal.rs
  • crates/palyra-daemon/src/transport/http/handlers/console/routines.rs
  • apps/web/src/console/sections/CronSection.tsx