Skip to main content
Routines are named, persistent, user-owned tasks that fire automatically based on triggers (cron schedules, event patterns, or webhooks). Each routine runs independently with only its specific prompt and context sent to the LLM.

Architecture

Routine Types

Lightweight

Single LLM call, no tools. Fast and cheap for checks and notifications.

Full Job

Multi-turn execution with tool access. For complex automation tasks.

Trigger Types

Cron Schedule

Fire on a recurring schedule:
Supported formats:
  • Standard cron: 0 9 * * MON-FRI (9am weekdays)
  • Human-readable: every 2h, every monday at 9am
  • Shortcuts: @hourly, @daily, @weekly
Use crontab.guru to validate cron expressions.

Event Pattern

Fire when a channel message matches a regex:
The pattern is compiled as a Rust regex. Common patterns:
  • (?i)keyword - Case-insensitive match
  • \b(word1|word2)\b - Word boundary match
  • ^deploy.*prod - Starts with “deploy”, contains “prod”

Webhook

Fire on incoming HTTP POST:
Webhook URL: http://your-host/hooks/routine/{id} or http://your-host/hooks/routine/{path}

Manual

Fire only via tool call or CLI:

Execution Modes

Lightweight

Single LLM call with context injection, no tool access:
Best for:
  • Periodic health checks
  • Notification summarization
  • Simple decision logic
  • Read-only operations

Full Job

Multi-turn agent loop with full tool access:
Best for:
  • Complex automation
  • Multi-step workflows
  • Tool-heavy operations
  • File manipulation

Guardrails

Routines enforce safety constraints:

Cooldown

Minimum time between fires:
Prevents rapid-fire execution from event triggers.

Max Concurrent

Limit simultaneous runs of the same routine:
Prevents resource exhaustion.

Dedup Window

For event triggers, ignore duplicate content:
Uses content hash to detect duplicates.

Notification Config

Control when and how users are notified:

Quiet Hours

Suppress notifications during sleep hours:

Creating Routines

Via CLI

Via Tool

Example Routine Definitions

Engine Implementation

The routine engine runs two independent loops:

Cron Ticker

Event Matcher

Event triggers are cached in memory with compiled regexes.

Execution Flow

  1. Trigger fires (cron, event, webhook, manual)
  2. Guardrail checks (cooldown, max_concurrent, dedup)
  3. Global capacity check (max_concurrent_routines)
  4. Spawn execution
    • Lightweight: Single LLM call
    • Full Job: Delegate to scheduler
  5. Record result (success/failure, message, iterations)
  6. Notify user (if configured)
  7. Update next_fire_at (for cron triggers)

Database Schema

Configuration

Monitoring

Next Steps

Sandbox

Learn about Docker-based job execution

API Reference

API documentation for routines