Cron scheduling
Why Cron is first-class
In the six-layer architecture, scheduled tasks sit beside event triggers as infrastructure that delivers work into Sessions:
Rendering diagram…
Cron enables periodic proactive work—dailies, patrol jobs, alarms, batch schedules.
Three schedule kinds
| Type | Meaning | Example schedule_value |
|---|---|---|
at | One-shot; auto-disables after run | 2026-04-25T09:00:00 (ISO, ≥1 minute ahead) |
cron | Standard 5-field crontab | 0 9 * * * daily 9:00 · 0 10 * * 1 Monday 10:00 |
every | Fixed interval | 30m, 2h, 1d (minimum 5 minutes) |
Two execution modes
| Mode | Meaning | When to use |
|---|---|---|
isolated ⭐ | Spin a temporary Session | Default; jobs don’t interfere |
main | Run inside the creating Session | Need inherited files / memory / context |
Delivery modes
After a job fires, output can go to:
| Mode | Behavior |
|---|---|
| SESSION | Post back to a Session (default) |
| CHANNEL | Push to Feishu / WeCom / email |
| WEBHOOK | HTTP callback |
| LOG | Log only |
If the job was created in a group chat, results auto-return to that group—no extra config.
Conflict policy
When a previous run is still executing and the next tick arrives:
| Policy | Behavior |
|---|---|
| SKIP | Skip this tick |
| QUEUE | Wait until prior run finishes |
| FALLBACK_ISOLATED | Run this tick in an isolated Session |
Retry policy
- Max attempts: default 3
- Backoff:
30s → 60s → 300s → 900s → 3600s - Retriable:
timeout/rate_limit/server_error/network_error - Non-retriable: business / permission
permanent_error
Agent-managed scheduling
Built-in tool manage_cron_job lets users create / list / delete jobs in chat—no admin UI required:
On trigger:
Rendering diagram…
Typical patterns
Cron vs EventTrigger
| Axis | Cron | EventTrigger |
|---|---|---|
| Source | Clock | External events |
| Examples | Reports, patrols, alarms | PR review, requirement change, chat |
| Creation | Agent or admin UI | Admin Webhook / routing |
| Concurrency | Usually single instance per job | Bursty under spikes |
Compose: cron can chain into EventTrigger; EventTrigger can spawn cron jobs.
Persistence & observability
- MySQL persistence — survives restarts
- Run history — status, duration, output, errors
- Audit — create / update / delete logged per tenant
- APM — each fire has a Trace ID; see Observability