Skip to main content
This page documents the configuration system of the Palyra daemon (palyrad), the abstraction layer for LLM and embedding providers, and the background scheduling infrastructure.

Configuration System

Palyra uses a TOML-based configuration system centered around the RootFileConfig schema. The configuration is loaded at startup, supporting versioned migrations and sensitive value redaction.

RootFileConfig Schema

The RootFileConfig struct defines the top-level sections of the palyra.toml file.
SectionDescription
deploymentDefines environment mode (local_desktop vs remote_vps) crates/palyra-daemon/src/config/schema.rs#114-117.
daemonNetwork binding for the HTTP/Admin/Console server crates/palyra-common/src/daemon_config_schema.rs#92-95.
gatewaygRPC and QUIC interface settings for agent communication crates/palyra-common/src/daemon_config_schema.rs#99-112.
model_providerLLM settings, including API keys and model selection crates/palyra-common/src/daemon_config_schema.rs#195-212.
cronGlobal scheduler settings (e.g., timezone) crates/palyra-common/src/daemon_config_schema.rs#133-135.
storageDatabase paths and persistence settings crates/palyra-daemon/src/config/schema.rs#253-257.

Secret Redaction

To prevent accidental exposure of credentials in logs or diagnostic exports, the system implements a redaction mechanism.

Configuration Loading Flow

The load_config() function in crates/palyra-daemon/src/config/load.rs orchestrates the discovery and parsing of the configuration file. Config Loading Sequence Sources: crates/palyra-daemon/src/config/load.rs#29-48, crates/palyra-daemon/src/config/load.rs#51-56.

Model and Embeddings Providers

Palyra abstracts LLM interactions through the ModelProvider and EmbeddingsProvider traits, primarily supporting OpenAI-compatible APIs with built-in resilience.

Provider Abstractions

The system distinguishes between two primary provider kinds:
  1. Deterministic: Used for testing or fixed-response scenarios crates/palyra-daemon/src/model_provider.rs#33.
  2. OpenAiCompatible: The standard provider for GPT-style models crates/palyra-daemon/src/model_provider.rs#34.

OpenAI-Compatible Implementation

The OpenAiCompatible provider implements chat/completions and embeddings endpoints. It includes a sophisticated request pipeline:

Credential Sources

API keys can be sourced from multiple locations, prioritized by the ModelProviderCredentialSource enum:
  • InlineConfig: Directly from palyra.toml.
  • VaultRef: Referenced by a key in the encrypted palyra-vault.
  • AuthProfile: Associated with a specific user or principal identity.
Sources: crates/palyra-daemon/src/model_provider.rs#103-108, crates/palyra-daemon/src/model_provider.rs#123-140.

Background Scheduler (Cron and Routines)

The cron module handles periodic tasks, while routines provide a higher-level abstraction for agentic workflows triggered by schedules or events.

The Cron Scheduler

The scheduler runs a background loop that evaluates job readiness every 15 seconds (SCHEDULER_IDLE_SLEEP) crates/palyra-daemon/src/cron.rs#42. Cron Matcher Logic The CronMatcher parses standard 5-field cron expressions (minute, hour, day, month, weekday) crates/palyra-daemon/src/cron.rs#140-156. It supports both Utc and Local timezone modes crates/palyra-daemon/src/cron.rs#60-65.

Routine Execution

Routines extend the scheduler by adding metadata, delivery policies, and approval gates.
ComponentRole
RoutineTriggerKindDefines what starts the routine (Schedule, Webhook, Manual, etc.) crates/palyra-daemon/src/routines.rs#35-41.
RoutineDeliveryModeControls where the agent’s output is sent (SameChannel, SpecificChannel, LogsOnly) crates/palyra-daemon/src/routines.rs#69-74.
RoutineApprovalModeDefines human-in-the-loop requirements (BeforeEnable, BeforeFirstRun) crates/palyra-daemon/src/routines.rs#125-129.

System Maintenance Routines

The daemon schedules internal maintenance tasks via the same infrastructure: Routine Dispatch and Persistence Flow Sources: crates/palyra-daemon/src/cron.rs#140-156, crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#154-162.

Data Flow: Config to Runtime

This diagram illustrates how configuration values are propagated from the physical TOML file into the active model provider instances. Config to ModelProvider Initialization Sources: crates/palyra-daemon/src/config/load.rs#29-43, crates/palyra-daemon/src/model_provider.rs#123-140, crates/palyra-daemon/src/gateway.rs#31.