Scheduled Tasks
Let a bot do work on a schedule: a daily morning report, a service check every 30 minutes, cleaning up a branch once a PR merges. When a task is due, the bot hands your prompt to its AI CLI and posts the result back to Feishu/Lark.
Quick start
The fastest way is to send this in a group or topic:
(每日17:50 means "every day at 17:50"; the rest is the prompt.) The bot replies with the task ID, next run time and execution position. Use /schedule list to view tasks and /schedule remove <id> to delete one.
You can also just tell the agent "add a scheduled task to check deployment every day at 18:00". It uses the built-in botmux-schedule skill to create it.
Four ways to create a task
When you run botmux schedule add inside a bot session, the chat is inferred. Outside a session, add --chat-id <chat ID>.
Writing the schedule
The /schedule slash command only understands Chinese phrases (schedule first, then the prompt):
The CLI and Dashboard accept more formats:
Time zone
Cron and phrases like "every day at 9" fire, "tomorrow 9:00" is parsed, and times on cards and in the Dashboard are shown, all in one time zone. By default it follows the host.
If the server and you are in different time zones (say the host is overseas and you're in Beijing), pick Asia/Shanghai under Dashboard "General → Scheduled tasks → Timezone" (stored as scheduleTimeZone in config.json), or set the environment variable BOTMUX_SCHEDULE_TIMEZONE. The environment variable wins. See Global Settings: Scheduled task timezone.
The exception is an explicit date-time: 2026-12-01T10:00 without an offset is read in the host time zone, not this setting. To pin a zone, include the offset, e.g. 2026-12-01T10:00+08:00.
Where results go: execution position
By default a task runs at the chat's top level, even if you created it inside a topic. It does not automatically return to that topic. To change that, pick one of these:
The Dashboard Execution position dropdown changes it directly. An admin can also send /dashboard schedules to get a DM card; the task detail view there can pause, resume or switch the execution position.
New topic each run
The first message of the new topic is the "task started" notice by default. Set your own title with --topic-title (up to 200 characters). Non-silent tasks can use placeholders:
Silent tasks only support fixed titles; templates are rejected on save.
Dedicated task topic
- Every run of the same task lands in the same topic, so context carries over.
- Different tasks in the same chat each get their own topic, so a health check and a daily report never share a session.
- The topic is created on the first run: a non-silent task posts a "task started" message to start the topic; a silent task waits until the bot first speaks with
botmux send. - Only single-chat tasks are supported.
Keywords such as 静默 (silent) and 独立话题 can be combined in any order.
Follow the active topic
A fixed-topic task has a weakness: when the topic closes and people move elsewhere, reminders land where nobody looks. With --follow-active, the task picks a target again on every run:
Each run checks, in order:
- The last topic is still open and a human has spoken in it → post there again.
- Otherwise → post to the topic in this chat where a human spoke most recently, and remember it (bot replies don't count). The task then runs in that existing session, so its own
--workdirdoesn't apply. - No open topic with human messages, but the last topic is still open → stay put.
- Nothing is open → open a new top-level topic and remember it.
If session records can't be read (for example the database is temporarily unavailable), the target doesn't move. --follow-active can't be combined with --top-level / --new-topic. In schedule list these tasks are marked ↷跟随活跃话题.
Silent mode
For checks that should stay quiet unless something is wrong:
On the CLI use --silent. A silent task posts no "task started" notice; the model decides whether to send anything with botmux send. With a new topic, the topic is only created when there's something to say.
Managing tasks
In a chat:
CLI:
In a chat, /schedule list shows each task's run-as identity (runAs). A task with no usable identity is flagged, because tools that need a user identity will fail closed. See Run-as identity.
Edit the frequency, prompt or calendar in place
No need to delete and recreate — use update:
--schedule accepts everything schedule add does (每日17:50, every 2h, 5-field cron, …); an expression it can't read is rejected with examples and the task is left alone. After a frequency change the next run is recomputed from now under the new rule — nothing is re-run or fired immediately — and the command prints the new rule and the next run time. A paused task stays paused. The frequency can't be changed while a run is in progress (you'll be asked to wait for it to finish), and a one-shot time can't be in the past.
The task ID, silent setting, execution position, Bash precondition, work calendar, creator identity, enabled state and run history are kept. A run already in progress keeps the old configuration; the next run uses the new one. Permissions match the Dashboard edit: whoever can change the prompt can change the frequency, and delegated tasks still need a new authorization. See botmux schedule update --help for every field.
Run logs and multiple groups (Dashboard)
Like the Bash precondition, these two are only available on the Dashboard's Scheduled Tasks page.
Run logs: every row in the task list has a Run logs button. It shows recent runs: whether each one was submitted to the model, skipped because the precondition failed, or failed to schedule, plus the trigger (scheduler / Dashboard run now), start and end times and the precondition result. The log only covers the precondition check and the submission to the model; it does not include model output, terminal output or message delivery. Only runs recorded after the upgrade are shown, and viewing the log never triggers or changes the task.
One task, several groups: when creating or editing a task, Bound groups accepts several groups, up to 5.
- Each group calls the model independently, and a failure in one group doesn't stop the others; model usage grows with the number of groups.
- The Bash precondition runs once per schedule, and its result applies to every group.
- With the execution position set to Dedicated topic for this task or to a specific existing topic, only one group can be bound.
Per-task model
A high-frequency sentinel is fine on a cheap model; a daily deep review deserves the strongest one. --model / --reasoning-effort apply to this task only and leave the bot config alone:
The Dashboard form has Model and Reasoning effort fields too; leave them empty to follow the bot config.
Note: only the run that starts a new session can switch models. The model is a launch argument of the CLI process and can't change once it's running:
Reasoning effort can be low / medium / high / xhigh / max / ultra; which levels work depends on the model. Per-task models are supported on Codex, Codex App, Claude Code, Grok, TRAE (TraeX), Kimi, ZCode and Remote Runner. If at run time the bot has switched to a CLI without support, or the model no longer supports the level, that setting is dropped with a warning and the task runs anyway; it is never skipped for this reason.
Until done: stateful follow-up tasks
For jobs like "switch back to main once the PR merges" or "delete the backup after Oct 30", use --until-done. The task keeps running on schedule until the session running it confirms the work is done and marks it complete.
--deadline accepts a date, 7d, 明天18:00 (tomorrow 18:00) and similar.
Each run gets a footer appended to the prompt with the run number, deadline and how to mark completion, so your prompt only needs to say what to wait for and what to do. Completed or expired tasks can't be resumed; create a new one. Tasks created through cross-bot delegation don't support --until-done yet.
Run ledger: every task records runs, skips, failures and misses. botmux schedule list shows two extra lines per task:
(Status: until-done · in progress · ran 3 times · deadline …; Ledger: ran 3 · skipped 0 · failed 1 · missed 1.)
Failure notifications:
--notify failing,expired: @mentions the creator in the topic where the task was created (or the target chat if there is none).failingfires after 3 failures in a row (once per streak);expiredfires when the task closes at its deadline. Off by default.- Admin fallback: whether or not
--notifyis set, any task that fails 3 times in a row DMs one admin once; it resets after a successful run.
Bash precondition
To check something first and call the model only when a condition holds (saving cost and noise), turn on Enable Bash precondition when creating or editing a task in the Dashboard.
There is one rule: the script must exit with 0 and its stdout, trimmed, must be exactly 1 for the model to be called. Output 0, anything else, empty output or an error skips this run.
To give this model call extra context, write to file descriptor 3 (FD 3); it is appended to the prompt:
FD 3 content is sent to the model and may end up in the session log. Never print secrets or tokens.
Two ways to configure it:
- Enter Bash directly: the script is stored with the task.
- Bash file path: the file must live in the trusted directory the Dashboard shows,
<dataDir>/schedule-preconditions/trusted-files/on the daemon host. Enter the full absolute path. Relative paths,~, the directory itself, files outside it and paths containing symlinks are rejected. The file is re-read on every test and run, so editing it doesn't require re-saving the task.
Then click Test precondition. It really runs the current (unsaved) form content on the daemon host and shows passed, not passed, or an error code. Testing doesn't save, doesn't call the model and doesn't count as a run, but the script's own side effects (writing files, network calls) do happen.
Turning the switch off only pauses the precondition; the task still runs and the script is kept. Clear the script or path and save to remove it.
File paths saved outside the trusted directory before an upgrade are kept, but while enabled both testing and scheduled runs refuse them (no model call). Move the file into the trusted directory yourself, update the full path, test, then save.
Work calendars
"Workdays at 9" means Monday to Friday, which breaks around public holidays and make-up workdays. Bind a work calendar and the scheduler filters runs by it:
To run on Chinese statutory workdays, use a daily cron plus the calendar (e.g.
0 9 * * *).0 9 * * 1-5never fires on weekends, so a calendar can't create the weekend make-up workday for it.
Built-in China statutory calendar
ID cn, shown as "China Statutory Work Calendar", time zone Asia/Shanghai, including holidays and weekend make-up workdays. Currently verified for 2026-01-01 to 2026-12-31, based on the State Council General Office notice on 2026 holidays (Guobanfa Mingdian [2025] No. 7). schedule calendars prints the source details.
It represents the nationwide holiday arrangement, not every organization's actual shifts; local holidays, company rosters, Hong Kong/Macao/Taiwan and other countries are out of scope. Dates outside coverage (such as the not-yet-verified 2027) are never guessed: the task stops running automatically and records calendar_out_of_coverage. Upgrade to a release with next year's data before the year ends.
Custom calendars
For company rosters and the like, add your own calendar to the bot. The default path is ~/.botmux/bots/<appId>/work-calendars.json (next to that bot's schedules.json); each bot's calendars are separate. Changes are picked up on the next check without a restart.
The following is made-up demo data:
Everything except displayNames is required. Duplicate dates, a day listed as both rest and work, an invalid time zone or a reversed range invalidate that definition. The file is limited to 1 MiB. One bad definition doesn't affect the others, but a malformed file stops every task bound to it from running automatically. cn is reserved and can't be overridden locally.
Bind, change and unbind
In the Dashboard form, pick a calendar under Custom Work Calendar, choose Workdays only or Rest days only under Run on, or choose No calendar filter to unbind. Task rows show the Next calendar-eligible trigger and the reason.
How calendars affect runs
- The calendar check happens before the precondition, the model call and topic creation. A skip is recorded as a skip, not a failure, and doesn't use up repeat counts.
- If the calendar is missing, broken or out of coverage, the task doesn't run and the reason is recorded, but the task isn't disabled; once the data is fixed, later runs proceed. A calendar read failure counts as one failure, and 3 in a row trigger failure notifications.
- A paused task can't
schedule run; resume it first. Pausing cancels pending manual run requests.
Common reason codes: work_date / work_week allow the run, rest_date / rest_week skip it; calendar_missing (no such calendar), calendar_invalid (bad format), calendar_out_of_coverage (outside the covered dates).
If your own job script also hard-codes "Monday to Friday only", remove that, or it will still skip weekend make-up workdays the calendar allows.
Run-as identity and permissions
When a task runs, whose identity is used for per-user tools like lark-cli --as user and bytedcli? The rule:
- Someone claimed it → the claimant;
- Otherwise → the creator (recorded automatically when a human creates the task in Feishu/Lark).
Every run re-checks that this person can still operate the bot.
--run-as only works from the host terminal; tasks created inside a session always run as the current requester.
Claim card
If the bot has user identity auth on (triggerUserAuth in bots.json) and a task has no usable identity (no recorded creator, or the creator/claimant lost access), the bot posts a claim card in the task's chat (or topic) when it fires, instead of letting the task fail silently:
- Click Claim — run it as me: every later run uses your identity. The identity comes from the clicker Feishu reports, so it can't be forged.
- After a claim you can use Claim it for me instead or Run again.
- Only members who can operate the bot can click. Each task has one card, refreshed in place on later runs.
(The screenshot shows the Chinese UI.)
Who can manage tasks
- Creating, running, pausing, resuming, deleting and updating tasks are all judged by whether the human sender of the current turn is an operator of this bot. Bot messages, old messages and automatic continuations can't stand in for a human.
- A task's own run can stop itself with
botmux schedule pause self/remove self(re-checking each time that the creator is still an admin and still in the chat; host-terminal tasks with no creator can do this too). It can only manage this one task: no prompt changes, no resume, no forced runs. - To "send the final result, then delete myself", use one command instead of two steps:
BotMux first confirms the result was delivered, then deletes the current task. If scheduleSelfCleanup.removed in the result is false, retry the same command; the message won't be sent twice.
The authoritative task records live in a host-side SQLite database; schedules.json is only a rebuildable copy, and hand-adding records there won't make a task run. So every write goes to the owning bot's daemon. If the daemon is unavailable the command fails loudly, instead of editing only the JSON and leaving a task that never runs.
Advanced: one-shot child tasks from scheduled runs
Some two-stage workflows need a later same-day check, such as collecting data overnight and reviewing unfinished items at 18:00. An administrator can enable Scheduled one-shot child tasks under Global Settings → Experimental, or configure:
An authenticated scheduled turn may then use the ordinary botmux schedule add <future-time> <prompt> --topic command. Authority is limited to the same bot, chat, current topic and exact working directory. Only once schedules are accepted; the defaults are within 24 hours and one child per turn. childOneShotMaxDelayMinutes is capped at 7 days and childOneShotMaxTasksPerTurn at 16.
The parent must be a human-created direct task (or its migrated equivalent), and its controller must still be a bot administrator and chat member. The child exposes that verified controller only as the exact turn's lark-cli / bytedcli tool actor and for botmux actor current; its persisted task remains ownerless, so workflow and schedule mutations stay unauthorized. It cannot self-manage or create descendants, and the caller cannot nominate another owner. Ordinary cross-bot delegated tasks remain anonymous. The target bot must enable triggerUserAuth isolation for both lark-cli and bytedcli, preventing a reused topic session from inheriting stale credentials. Retrying the same request returns the original task without consuming another slot; deleting a task does not return the turn quota.
Advanced: cross-bot delegated creation
When a human explicitly asks Bot A, in the current turn, to have Bot B create a scheduled task, A must request the capability on the managed dispatch:
The host must also turn it on in ~/.botmux/config.json (off by default):
The switches are also editable in the Dashboard under Global Settings → Experimental; advanced numeric limits are configured in config.json.
With runScopes, both the source and target bots must enable triggerUserAuth, and the target bot must route both lark-cli and bytedcli through identity isolation:
Limits: delegation is single-hop and bound to the target bot's current dispatch turn; it expires when the turn ends. Tasks can only land at the top level of the original dispatch chat or in the current topic; --new-topic, --follow-active, multiple chats and re-delegation aren't supported. Retrying the same request returns the original task instead of creating a duplicate.
