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 theJournalStore for persistence and the Gateway for run dispatching.
Code Entity Mapping
| System Concept | Code Entity | File Path |
|---|---|---|
| Scheduler Loop | spawn_scheduler_loop | crates/palyra-daemon/src/cron.rs#252-252 |
| Routine Registry | RoutineMetadataRecord | crates/palyra-daemon/src/routines.rs#188-188 |
| Cron Matcher | CronMatcher | crates/palyra-daemon/src/cron.rs#129-129 |
| Misfire Policy | CronMisfirePolicy | crates/palyra-daemon/src/journal.rs#35-35 |
| API Surface | console_routines_list_handler | crates/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-520Cron & 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 inParsedSchedule:
- Cron: Standard cron expressions with configurable timezone modes (
UtcorLocal) crates/palyra-daemon/src/cron.rs#123-123. - Every: Interval-based execution (e.g., every 10 minutes) crates/palyra-daemon/src/cron.rs#124-124.
- 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), theCronMisfirePolicy determines behavior:
- FireOnceNow: Executes one run immediately to catch up crates/palyra-daemon/src/journal.rs#35-35.
- Ignore: Skips the missed occurrences and waits for the next scheduled time.
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
ARoutineMetadataRecord includes:
- TriggerKind: Can be
Schedule,Webhook,SystemEvent, orManualcrates/palyra-daemon/src/routines.rs#35-41. - DeliveryConfig: Specifies where the output should be sent (
SameChannel,SpecificChannel,LocalOnly, orLogsOnly) crates/palyra-daemon/src/routines.rs#69-74. - Quiet Hours: Optional time ranges where the routine is suppressed crates/palyra-daemon/src/routines.rs#167-172.
- Approval Policy: Controls whether runs require human-in-the-loop intervention before execution crates/palyra-daemon/src/routines.rs#176-178.
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-203Management Surfaces
HTTP API (Console V1)
The daemon provides a comprehensive set of endpoints for managing routines via theAxum web server:
GET /console/v1/routines: Lists routines with filters fortrigger_kind,enabled, andtemplate_idcrates/palyra-daemon/src/transport/http/handlers/console/routines.rs#154-182.POST /console/v1/routines: Upserts a routine definition usingConsoleRoutineUpsertRequestcrates/palyra-daemon/src/transport/http/handlers/console/routines.rs#53-107.POST /console/v1/routines/:id/run-now: Manually dispatches a routine run crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#125-134.POST /console/v1/routines/schedule-preview: Validates natural language schedule phrases crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#138-142.
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:- Memory Maintenance: Runs every 5 minutes (
MEMORY_MAINTENANCE_INTERVAL) to handle retention and cleanup crates/palyra-daemon/src/cron.rs#56-56. - Embeddings Backfill: Runs every 10 minutes (
MEMORY_EMBEDDINGS_BACKFILL_INTERVAL) to generate vector embeddings for new journal items crates/palyra-daemon/src/cron.rs#57-57. - Skill Re-audit: Periodically re-verifies the security and signatures of installed skills crates/palyra-daemon/src/cron.rs#54-54.
crates/palyra-daemon/src/cron.rscrates/palyra-daemon/src/routines.rscrates/palyra-daemon/src/journal.rscrates/palyra-daemon/src/transport/http/handlers/console/routines.rsapps/web/src/console/sections/CronSection.tsx