# Routines and schedules

> Run agent work on a timetable with routines, and set a one-off follow-up on a ticket that wakes its agent, reminds you or moves the card.

This page shows you the two ways to have By Dawn act later without you. A **routine** is work an agent does again and
again on a timetable, such as a nightly dependency sweep. A **follow-up** is a single moment on one ticket, such as
"check tomorrow at 9 that the email went out". By the end you'll be able to set up either and keep an eye on what
they did.

## Routines

A routine is a playbook for an agent plus a timetable. Each time it comes round, By Dawn creates a ticket from the
playbook and an agent works it, so every run leaves a ticket you can open, like any other work. One run is called
a **tick**.

Open **Routines** at the foot of the sidebar. Routines aren't tied to the project you're in: the page lists every
routine in your organization. It has two tabs, **Fleet Wall** and **Ledger**.

### Create a routine

Choose **New routine** on the Fleet Wall. If you're inside a project, the routine belongs to it. To start from a
ticket you keep doing by hand, open the ticket and choose **Actions › Make this recurring**: By Dawn fills in the
routine from the ticket's plan or description, its project and its repos.

**New routine** asks for:

- **Name**: what you'll see on the card, such as "Nightly dependency sweep".
- **Cadence**: how often it runs (**Runs**) and in which **Timezone**. **Runs** can be **Every few minutes** (15 or
  30), **Hourly / every few hours**, **Daily**, **On specific days of the week**, **Monthly** (on a day from 1 to 28,
  so every month has it) or **Custom (cron)**. By Dawn reads the timetable back to you in plain words, so you can check
  it before you save.
- **Target repos**: the project's repos the agent may work in. A routine created outside a project works in none.
- **Playbook**: what one tick does, written for the agent in Markdown. Say what it should look at, what it should
  produce and when it should stop.
- **Autonomy**: how far the agent may go.
  - **Observe — reports & files tickets, never edits code**
  - **Propose — may open draft PRs, never merges**
- **Caps**, optional: **Max PRs opened** and **Max tickets created** in one tick. A tick that reaches one stops
  there.
- **If a tick was missed**: run one catch-up tick and carry on, or skip it and wait for the next one. By Dawn never runs
  more than one catch-up, so a routine that was down over a weekend doesn't open a pile of pull requests on Monday.
- **If the last tick is still running**: skip the new tick, or queue it until the running one ends.

Choose **Create routine**. A new routine starts **Paused**, so nothing runs until you're ready.

### Run, pause and edit

Each routine is a card on the **Fleet Wall**, with its state (**Active** or **Paused**), its autonomy, when it runs
next, and a strip of its last ticks coloured by how they went. Above the cards are counts of active and paused
routines and of runs this week.

Open a card's menu for:

- **Resume**, to start a paused routine, or **Pause** to stop an active one.
- **Run now**, to run a tick straight away, whatever the timetable says.
- **Edit**, to change anything you set when you created it.

A routine whose ticks fail three times in a row pauses itself, so it doesn't open the same broken pull request every
night. The card says why it paused. Fix the playbook, then **Resume** it.

### The Ledger

The **Ledger** lists every tick, newest first, for **All routines** or the one you pick. Each row says how the tick
went:

| Result | Means |
|---|---|
| **Queued** | Waiting to start. |
| **Running** | In progress. |
| **Clean** | Finished, with nothing to do. |
| **Warned** | Finished, with warnings. |
| **Capped** | Stopped at one of its caps. |
| **Failed** | Didn't finish. |
| **Skipped** | Didn't run, for example because the last tick was still running. The row says why. |

Open a row for the details: any error, the model and machine it ran on, and **View ticket** to open the ticket it
worked. By Dawn writes a row even for a tick it skipped, so a routine that has stopped producing work never looks the
same as one that had nothing to do.

## Follow-ups on a ticket

A follow-up is one thing By Dawn does to a ticket at a time you choose. Open the ticket and choose **Actions › Schedule
follow-up…** (on a phone, it's in the ticket's **…** menu). In **Schedule a follow-up**:

1. **When**: choose **In 1 hour**, **Tomorrow 9:00**, **In 2 days** or **In 1 week**, or pick a date and time. The
   time is in your own timezone, shown beside it. It can be up to 180 days away.
2. **What should happen**:
   - **Wake the worker**: the ticket's agent gets your message and carries on with it. If no agent is running, one
     starts.
   - **Just remind me**: By Dawn only notifies you, with your message.
   - **Move the card**: By Dawn moves the card to the column you pick, just as if you'd dragged it there. Moving it into
     a column that starts work starts the agent.
3. **Message**: what the agent should do, or what you want to be reminded of.

Choose **Schedule for …**. The follow-up survives restarts and updates, and you're notified when it fires, whatever
it was set to do.

The ticket lists its pending follow-ups under **Upcoming**, just below the plan, with what each will do, when, and
who scheduled it. **Cancel** removes one. The next one also shows as a countdown in the ticket's header and on its
card.

An agent can schedule a follow-up for itself too, for example to come back in two days and check that a fix held.
Those say **Scheduled by the worker**, and when one fires By Dawn tells the ticket's assignee, or else whoever last
started it.

If a move can't be made when the time comes, for example because the column was deleted or the ticket is blocked,
the follow-up fails and you're told why. A ticket can hold up to 25 pending follow-ups.

## FAQ

**Should I use a routine or a follow-up?**

Use a routine for work that repeats on a timetable. Use a follow-up for one moment in the life of one ticket, such
as checking on a fix after a release.

**Can a routine merge its own pull requests?**

No. The most a routine can do is open draft pull requests (**Propose**), and a person reviews them as usual.

**My routine is Paused but I never paused it. Why?**

New routines start paused, and a routine also pauses itself after three failed ticks in a row. The card says which.
Choose **Resume** from its menu when it's ready.

**What time zone does a follow-up use?**

You pick the time in your own timezone, and By Dawn fires it at that moment wherever the agent runs.

## Where to go next

- [Start a ticket](https://docs.bydawn.com/start-a-ticket/): what happens when a worker starts on a ticket.
- [Terminals](https://docs.bydawn.com/terminals/): step into an agent's session while it works.

Source: https://docs.bydawn.com/routines-and-schedules/
