High-Level Automation Architecture
The automation layer is built on three pillars: the Cron Scheduler, Routines, and Objectives. These components interact to ensure that agents can fire based on time, events, or persistent goals while adhering to safety and approval constraints.Natural Language to Code Entity Space: Automation Dispatch
This diagram illustrates how a user’s intent or a scheduled trigger flows from high-level concepts into the internal daemon machinery. Sources: crates/palyra-daemon/src/cron.rs#3-13, crates/palyra-daemon/src/routines.rs#94-103, crates/palyra-daemon/src/objectives.rs#3-7Routines and Cron Scheduler
Thespawn_scheduler_loop is the heart of Palyra’s proactive execution. It handles time-based triggers defined via cron expressions or natural language phrases.
- Deterministic Scheduling: The scheduler uses stable hashes for jitter to prevent “thundering herd” issues across multiple instances crates/palyra-daemon/src/cron.rs#10-13.
- Misfire & Concurrency: Supports policies like
Skip,CatchUp, andQueueOneto handle daemon downtime or overlapping runs crates/palyra-daemon/src/cron.rs#58-66. - Routine Integration: Routines wrap cron jobs with additional metadata, including delivery targets (e.g., Slack/Discord) and quiet hour constraints crates/palyra-daemon/src/routines.rs#45-50.
- Tool Interface: The
palyra.routines.controlandpalyra.routines.querytools allow agents to self-manage their own automations crates/palyra-daemon/src/application/tool_runtime/routines.rs#3-10.
Objectives, Webhooks, and Event Triggers
Objectives represent long-lived goals that may span multiple sessions and weeks. They provide a structured way to track progress and manage budgets for autonomous agents.- Goal Tracking: The
ObjectiveRecordtracks theObjectiveState(Active, Paused, etc.) and maintains a history of attempts and approaches crates/palyra-daemon/src/objectives.rs#3-7. - Budgets & Guardrails: Objectives can enforce
max_runsormax_tokensto prevent runaway costs during autonomous operation crates/palyra-daemon/src/objectives.rs#142-152. - Webhook Ingestion: The
WebhookRegistryallows external systems to trigger Palyra routines via HMAC-SHA256 signed payloads crates/palyra-daemon/src/webhooks.rs#3-9. - Workspace Projection: Objectives can project their status directly into workspace documents using “managed blocks” crates/palyra-daemon/src/transport/http/handlers/console/objectives.rs#2-11.
Code Entity Mapping: Objective Lifecycle
The relationship between objective goals and their underlying automation components.| Code Entity | Purpose | File Reference |
|---|---|---|
ObjectiveRecord | The primary document for goal state and history. | crates/palyra-daemon/src/objectives.rs#3-7 |
ObjectiveBudget | Enforces token and run limits on autonomous agents. | crates/palyra-daemon/src/objectives.rs#145-152 |
ObjectiveJudgeInput | Data structure used by LLM judges to evaluate goal completion. | crates/palyra-daemon/src/transport/http/handlers/console/objectives.rs#31 |
WebhookRegistry | Manages external triggers and signature verification. | crates/palyra-daemon/src/webhooks.rs#194-196 |
Summary of Key Automation Components
| Component | Responsibility | Primary Logic |
|---|---|---|
| Cron Loop | Minute-by-minute tick evaluation and misfire recovery. | spawn_scheduler_loop src/cron.rs |
| Routine Registry | Mapping triggers to specific agent prompts and delivery channels. | RoutineRegistry src/routines.rs |
| Objective Store | Long-term goal persistence and budget enforcement. | ObjectiveRecord src/objectives.rs |
| Webhook Handler | Secure ingestion of external events via palyra-safety. | WebhookRegistry src/webhooks.rs |
| Coalescer | Debouncing rapid-fire events into single agent turns. | InboundCoalescer src/application/inbound_coalescer/mod.rs |