Skip to content

Routines

How to create a routine, how the scheduler runs it, where its result goes and what happens when a run fails.

A routine is a recurring unattended turn: a cron expression, a timezone, an agent and one prompt. The scheduler fires it, the agent runs with no human present, and the tail of its final message is saved. An agent in GitHub App mode gets only its baseline repository grants.

A routine runs as the person who last changed its message, agent or target. Such an edit moves the routine to that person and erases its saved output and pending delivery. Pausing, resuming and deleting move nothing.

A routine may name a destination: a channel, a thread or the owner's Discord DM. With one, Daimon posts the agent's full final reply and its generated files there, unless the agent posted there itself. Without one, the result is only recorded, and files stay in the workspace.

For a one-off "remind me in two hours", use a timer (create_timer, mcp-tools.md). It fires once, in the conversation it was set in, and needs no cleanup.

Create a routine

Five MCP tools manage routines: create_routine, list_routines, get_routine, update_routine and delete_routine (mcp-tools.md). There is no pause tool: pause with update_routine(enabled=False). The last run is in the last_* fields that get_routine returns.

Ask the agent in chat ("every weekday at 9am, post the sales numbers"), or use a panel:

  • Slack /routines and Teams routines (in a 1:1 chat): workspace admins create and delete. The form's schedule field takes cron, such as 0 9 * * 1-5, and the panel shows schedules in words.
  • Discord /routines lists your routines, or all for an admin. Admins create; the creator or an admin can pause, resume or delete.
  • Web app Routines page: members manage their own, admins all. Changing one needs a linked chat account. Run now makes an active routine due at once.

The CLI creates routines for an owner (daimon routines create), sets sandbox tools, checks owners' roles and moves routines in from another system.

--destination dm|channel|thread (with --destination-id) runs the checks below; --dry-run saves nothing. The operator may name any agent, counted as the owner's own.

create_routine refuses a caller with no platform identity (a CLI-only token), an unknown IANA timezone, an unparseable cron expression and an agent_name outside the caller's tenant.

Set a destination

Set destination_kind and destination_id together on create_routine or update_routine. Remove them with update_routine(clear_destination=true). Changing it drops a result still pending for the old one. Before saving, the tool checks that:

  • the id has the platform's shape: a Slack thread is <channel>:<ts> and a Teams thread is <channel>;messageid=<root>;
  • the channel exists in the caller's own server or workspace and Daimon can post there;
  • the caller may post there themselves, by the same rules as send_message;
  • the tenant's access policy does not protect it (permissions.md).

For the owner's DM, set destination_kind="dm" and leave out the id. Daimon uses the caller's own Discord id, so nobody can send another person's routine to their DM. Slack and Teams refuse it. A DM routine runs as a live DM turn, with the owner's personal memory, and needs the server's DMs on and the agent's DM grant for the owner.

To make a destination mandatory, set DAIMON_MCP__REQUIRE_ROUTINE_DESTINATION=true (configuration.md). A create_routine call without one then creates nothing and returns a warning.

Choose a catch-up policy

Set catch_up_policy on create_routine or update_routine:

  • skip (default): a slot fires only if it is claimed within the freshness window. Older slots roll forward without firing.
  • run-once: after downtime, an overdue slot fires once whatever its age. Missed slots coalesce into that one run and are never replayed one by one.

Slots that pass while the same routine is still running are skipped under both policies. get_routine and list_routines show the latest skipped range and reason (stale or in_flight), not a history.

On OpenAI or Gemini a routine runs as an unattended reply, a DM routine as the owner's private turn. On OpenAI it stops with backend_unsupported unless sandbox tools are on. A routine into a thread runs on the provider that thread kept. Self-hosted stops with last_error=selfhosted_routines_unsupported. A thread destination with an unknown parent channel stops with routine_destination_parent_unknown. Set the destination again to record the parent.

How the scheduler runs it

The scheduler is a separate process, daimon-scheduler. At boot it takes a PostgreSQL advisory lock, and a second scheduler with the same key exits non-zero. Only the lock holder answers its liveness port, so a standby never looks healthy.

Each tick, 30 seconds apart by default, the scheduler:

  1. Rolls forward stale slots and slots that came due while the routine ran.
  2. Claims at most 20 due routines, stamping the run and computing the next slot in the same transaction.
  3. Checks the spend allowance, then starts each run as an independent task.
  4. Runs housekeeping, such as promo credit settlement, then sleeps.

The scheduler also runs long jobs and cleans up compute sessions, each on its own loop.

The tick does not wait for the runs. A dispatcher bounds concurrency, so a slow routine cannot hold up later ticks or overlap itself. A crash after a claim can lose that run.

The usage sweep runs on its own loop (billing.md). On shutdown the scheduler cancels its runs, records scheduler_shutdown and then releases the lock. --once drains its one batch before exiting. A schedule change made during a run survives the run's completion.

What a run does

A run resolves the creator's account, checks the invoker allowlist and the balance, and resolves the agent. It then runs a session with chat's turn driver. It is not a chat turn: there is no thread binding, continuity, handoff or dead-session recovery.

Nobody can click a confirmation, so tool calls follow the unattended rules. Built-in sandbox tools stay off unless an operator opts in.

A routine with a destination gets a short controls block before its prompt: its id, schedule and destination, a line saying nobody is watching, and that Daimon posts the final reply unless the agent does. If the destination is writers: none, the block tells the agent not to post there. Routine turns also get unattended-run framing, which an agent can override with context_fragments.routine.

Routine sessions mount the agent's shared memory read-only. A routine with no destination or channel also mounts its owner's personal memory read-only. An owner-DM routine is skipped as owner_busy if the owner already has a DM turn running. A routine in a channel shared with another organisation runs held to that channel, with only that channel's memory and no DM fallback.

Repository memory gives a routine the shared entries for its working repository, and its tools refuse routine calls. See repository memory.

Each routine session is stamped like a turn in the channel it fires into, and as private to its owner. A routine of a channel with limited readers is read only from inside it, and no server admin reads a routine's transcript from the hub.

On success the run saves the last 1,000 characters of the result as last_result_tail. The full reply goes to the delivery outbox.

Delivery

For a routine with a destination, a successful run queues its full result. If the agent already called send_message to that exact destination, the result is skipped as agent_posted. Otherwise the chat adapter for the tenant's platform posts it, in chunks that keep code fences intact. The post reads Result from <agent>'s daily routine at 09:00 UTC: followed by the result. The Routine result header feature turns that line off for a workspace, agent, channel or one routine.

Delivery is at most once and checks first:

  • Newest only. A new run replaces a queued result, so no backlog posts.
  • Creator first. If the access policy cannot be read, or the creator may not invoke the agent (admins pass unless the admin bypass is off), nothing is sent anywhere.
  • Policy at post time. A writers: none channel, a thread under one or a Discord channel in such a category is refused as protected_channel.
  • Only where the creator could post. A creator who lost view or send access, or is not in a private channel, gets the result by direct message instead.
  • Live workspace only. A channel in another server, or one that does not exist or is archived, is destination_unavailable.
  • Never silently nowhere. When nobody may write in the destination, the result goes to the creator by DM, under the tenant's DM policy (configuration.md). If that is not allowed or fails, the result is dropped with the reason.
  • No broadcasts. Mentions are disabled on Discord, and <!channel> stays literal on Slack. On Teams, a post also sends the creator one activity feed notice.
  • Never tag me. Someone who opted out shows as a plain name and gets no Teams notice.

An expired claim or a raising poster is not retried, as it may have posted. A run with no final text, or a NO_POST: line, posts no text. With agent identity on, Slack and Discord post as the agent. On Discord a reply to any delivered message starts a turn.

Generated files

After a successful run, Daimon collects the session's output files and delivers up to ten with the reply. Discord and Slack attach them, and a Teams post says files are not supported there. A file over 200 MB or the destination's limit (10 MB in a Discord DM) is named in text and stays in the workspace. On OpenAI and Gemini the limit is 24 MB.

Files share the result's at-most-once claim, and each send rechecks the destination and the owner's access. Changing the destination cancels pending files. Failure notices never carry files.

Timeouts

Bound Default
Per-turn ceiling 45 minutes, or the unattended_time_limit feature (15 to 45 minutes)
DAIMON_SCHEDULER__DISPATCH_TIMEOUT_S longest ceiling plus 300 s
DAIMON_SCHEDULER__TICK_INTERVAL_S 30 s
DAIMON_SCHEDULER__MAX_AGE_S 900 s
DAIMON_SCHEDULER__MAX_CONCURRENT_FIRES 10
Read timeout per call 120 s; for Gemini, 15 minutes, with a status check every minute

The ceiling covers session assembly and the run. The dispatch timeout cannot be set below it. Settings are in configuration.md.

Who may do what

Action MCP Discord Slack and Teams
create a caller with a platform user identity, for the agent they are talking to or the one the destination answers with; any agent for an admin by asking the agent; admins also in the panel workspace admin only
list and read last output admin or the creator admin or the creator admin or the creator
pause and resume admin or the creator admin or the creator admin or the creator
delete admin or the creator admin or the creator, after a confirmation admin or the creator
run now admin or the creator not offered not offered

Run now is offered on the web app's Routines page.

Ownerless routines are admin-only, and a refusal reads as "not found". Non-admins see only their own routines. A routine runs with its agent's repo, keys and connectors, so a member may schedule only the agent they are talking to. Admins too need a role-gated agent's roles.

In a readers: own channel, a routine of that channel's own agent is visible and editable only from inside it. Each run re-checks the agent's rule at the destination and skips a run that would cross the line (own_agents_only).

When a run fails

A failing routine is not retried; it tries again at its next slot. It pauses when its owner lost a role its agent needs (owner_lacks_agent_role). A failed run writes last_error and clears last_result_tail; a success does the reverse. The panels show a failure whenever last_error is set.

A channel or thread routine announces the first failure after a success, or a first run that fails, through the same checks as a result, with the DM fallback. On Discord, Slack and Teams the owner also gets a DM written by the routine's own agent, or a plain notice when it cannot run; a routine that posts to the owner's DM gets only that DM. Notices say what failed in plain words, never the raw error. A routine that keeps failing posts once until a run succeeds.

A run that could not do its task calls report_routine_problem; admins see it on Issues.

The last_error values are a closed set: invoker_not_allowed (the creator was removed from the allowlist), access_policy_unreadable, balance_depleted, cap_exceeded, channel_budget_exceeded, owner_lacks_agent_role, scheduler_shutdown, timeout: exceeded <n>s, and otherwise <ExceptionType>: <message> cut to 500 characters. A ceiling breach reads TurnError: ceiling: ....

Turn routines on

There is no feature flag. Routines run only while the scheduler process runs; without the scheduler service they never fire. The process will not boot without DAIMON_MCP__JWT_SECRET and DAIMON_MCP__PUBLIC_URL (JWT secret, public URL).

Four gates apply to every run: the invoker allowlist against the creator, the credit balance, the owner's spend allowance and a channel routine's channel budget, checked last (billing.md). A refused run records the reason and fires at its next slot. On Discord each fire, and each delivery, checks the creator's live membership, roles and admin permissions. Elsewhere only the creator's stored admin role exempts them from the allowlist.