Docs / How it works

The daily follow-up sweep

Decision 0050, track P142. Clients get our message and may take a long time to answer; the owner asked for the agent to check once a day who is silent, decide when to nudge and when not, and note what it did on the client's profile. This page is the whole mechanism. The rules the agent follows are the skill skills/follow-up-sweep/SKILL.md; nothing below judges a message.

What runs, and when

Who is listed: the silent clients (mechanical)

The server's selector (packages/db/src/repos/follow-up-due.ts, pure over fact rows) lists a Hub client of the project (decision 0009: never the Notion pages) when all hold:

A chat in reply mode off is left out; on_request is listed and the agent hands it over. Unlinked chats are never listed (decision 0049 point 8): the list counts them in one line. A chat marked done (P143) is judged by its own facts: Done removes attention, not follow-up. Order: the oldest next date first, then the longest silence.

One turn per client

The sweep runs one headless claude -p turn per listed client through P139's runner (claudeBrain, the follow_up kind): the same spawn rules as autopilot, its system prompt the skill's text, HUB_PROJECT plus HUB_FOLLOWUP_CLIENT (the clients row id) binding its hub mcp. The server prefetches the client's last 30 messages (Mail through the conversation reader, chats through the cache), the plan and its last lines, our last message's Mail ids and whether a chat is on autopilot, and puts them into the prompt as data, so the turn needs no Mail reader.

The turn has exactly nine hub tools, each bound to that client (refusal followup_other_client): client_show, client_map, message_show, knowledge_search, knowledge_get, draft_write, messenger_draft_write, follow_up_plan, bug_report (P145: a silent client's last message may be a bug report; section "Bug reports" below). No built-in tool, no mail-mcp, no Notion server, no send tool. --max-turns 12 and a 120 s wall clock. packages/agent/test/deny-modes.test.ts pins the list.

The decision and the plan

Each turn ends in one of four decisions, written with follow_up_plan: nudge (a follow-up draft was written in the same turn), wait (until next_check), stop (no_answer, not_interested, lost, done, do_not_contact) or hand over (the owner decides: we owe the next step, money or terms). The tool refuses only a malformed shape (a nudge or a wait without a date) or another client; a nudge without a draft is answered with a hint. A rerun the same day replaces that day's decision.

The plan (follow_ups, one row per client per project) is the agent's notes: state (waiting, stopped, handed_over, answered), next_at, waiting_on, nudges_sent, last_nudge_at, channel, reason, stop_reason, tz, the newest line, decided_by and decided_at. "Nudge ready" (an open nudge draft) and "due" (waiting, its date passed) are derived, never stored. No tool, door or draft check refuses because of a plan (decision 0050 point 4); the removed per-chat rule (may_nudge, nudge_after_days) is not back under any name.

Bookkeeping, never judgement (packages/db/src/repos/follow-up-hooks.ts):

What a nudge may do

Budgets and failure

At most 30 client turns per sweep (the rest roll to tomorrow, oldest date first), at most 60 sweep turns a day on the Mac (separate from autopilot's 100), and one of the pool's two slots, a waiting autopilot turn always first. A failed turn (timeout, mcp_not_ready, sign-in) keeps the client's date for the next run; three failures in a row stop the sweep with an Overview item "Follow-ups stopped: ".

Where the owner sees it

Routes

Route What
GET /api/projects/:slug/follow-ups the plans with their derived state and the sweep line (last, next, running, today's counts)
POST /api/projects/:slug/follow-ups/sweep Run follow-ups now (joins a running sweep; at most 3 a day)
PUT /api/projects/:slug/follow-ups/:clientId the owner's Change date, Stop or Resume; the exact admin Origin and Sec-Fetch-Site: same-origin, no ticket (they only delay or stop)

Live topic follow-ups (the follow_ups and follow_up_sweeps rows); P47's enrolments are the topic sequences. Ops source follow-ups: one line per sweep and per turn, each in its action id (28-ops-log.md).

Bug reports (P145, decision 0054)

A client's bug report is filed in the project's Bug reports database (hub install --only notion.bug-reports creates it; pack page notion-crm/11-bug-reports.md) by the hub tool bug_report, in every turn kind: a dock session, triage, the messenger and autopilot turns and this sweep's turn. It searches the open reports (New, Triaged, In progress) of the same Area and project, appends the client, their words and evidence to the one it finds, creates one with Status New when there is none, and with several creates nothing and lists them. One entry per message; never Severity, Notes, Fix link or a cause. The reply says it is recorded and will be looked at and promises no date and no cause; in autopilot the turn files it and hands back.

Closing the loop (B4, migration 0050 bug_fixed_notes): before its silent clients, and in the same turn budget, the sweep reads the project's Bug reports with Status Fixed, an empty Client told and Kind Product (or none) (fixedReports, packages/notion/src/bug-reports.ts). For each linked client the Hub knows and may contact, with no note yet, it claims one bug_fixed_notes row (unique per report and client) and runs one turn bound to it (HUB_FOLLOWUP_BUG_NOTE; the skill's section 2b): a short "fixed, please check" in the client's language, in the report's channel when the client has it there, else their last channel, quoting the symptom in their words. A mail note joins the day's lead batch, so it is one more row of Send all ready (row kind fixed); a messenger note waits in its chat. A turn that wrote no draft gives the claim back and the next sweep tries again; a client noted today is not also nudged today. The send stamps told_at; once every claimed client of a report was told, the sweep writes Client told with the last send's time. A Notion failure never fails the sweep or a send. Won't fix, Duplicate and Do not contact get no note (apps/server/src/follow-ups/bug-notes.ts).

Code

packages/config/src/follow-ups.ts (vocabularies, limits, the brain's port), packages/db/src/repos/follow-up*.ts (the plan, the selector, the hooks), migration 0046, packages/agent/src/mcp/tools/follow-ups.ts (follow_ups_due, follow_up_plan), apps/server/src/follow-ups/ (schedule, sweep, prefetch, nudges, routes), packages/notion/src/follow-ups.ts, the installer step notion.follow-ups, the skill skills/follow-up-sweep, the e2e apps/admin/e2e/z-follow-ups.spec.ts (HUB_FOLLOWUP_BRAIN=fake, refused without a throwaway HUB_DB).

P47 sequences coexist (23-sequences.md): a client with an open enrolment belongs to the sequence and is not swept. Whether to retire enrolments into the plans is a question for P47's W4 report.

Update this page when the architecture changes.

Source: @docs/core/30-follow-ups.md