Skip to main content

Module scheduler

Module scheduler 

Source
Expand description

Session-scoped prompt scheduler — backs /loop, /cron-list, /cron-cancel.

Users schedule recurring prompts with /loop 5m check the deployment. The scheduler fires them via a tokio channel; AgentSession drains the channel after each send() and runs the fired prompts.

§Design

  • CronScheduler holds a std::sync::Mutex<CronSchedulerInner> so it can be accessed from synchronous slash command handlers.
  • A background tokio task holds a Weak<CronScheduler> and ticks every second. It exits automatically when the session is dropped.
  • Fired prompts are delivered via tokio::sync::mpsc::UnboundedSender.
  • Deterministic jitter (0–10% of period, capped at 15 min) is derived from the task ID so the same task always fires with the same offset.

Structs§

CronScheduler
Session-scoped prompt scheduler.
ScheduledFire
A task fire event delivered to AgentSession.
ScheduledTask
A pending scheduled task.
ScheduledTaskInfo
Snapshot of a task used for display (avoids exposing Instant in public API).

Functions§

format_duration
Format a duration in seconds to a human-readable string ("5m", "2h 30m", etc.).
parse_interval
Parse a duration string like "5m", "30s", "2h", "1d".
parse_loop_args
Parse the argument string from /loop <args>.