building awe.

Closed laptops miss reminders. Catching up on wake doesn't fix it.

A reminder that fires late when the laptop opens has still been missed. Handing the next 48 hours to an always-on relay works if exactly one side owns each send.

Chad Priest / / 9 min read

Anything local-first has the same scheduler bug. Your agent runs on the user’s machine, which is where the privacy story and the memory live. Then the user says “text me at 3 to call the pharmacy” and closes the lid at 2:40. At 3:00 no process is running, so nothing fires and nobody notices.

The usual fix is to catch up on wake. The process starts, finds jobs that came due while it was down, and runs them. That’s a good fix for a nightly backup. For a reminder it’s the wrong fix, because “call the pharmacy” at 6:15 PM, when the laptop opens again, is just a missed reminder that arrives late.

awe is local-first, and a reminder on a Mac lived only on that Mac. The phone relay already answered and held texts while a Mac slept, so reminders were the last gap. This post covers how I closed it, the ownership rule that stops it from sending things twice, and a five-minute check you can run on your own scheduler.

The Mac hands the relay its next 48 hours of reminders every 5 minutes

The idea is small. Every 5 minutes (the first push comes 60 seconds after start), the engine builds a list of every text reminder due from 5 minutes ago to 48 hours ahead. It sends that list through the local gateway and a signed tunnel to the relay, an always-on server that already carries the user’s texts. If the Mac is offline when a reminder comes due, the relay sends it instead.

id, due_at, textonly if Mac offline at due + 2 minnormal path, carries the same idEngine on the Macexpands next 48 h, every5 minLocal gateway/chat/reminders-ahead,max 50 itemsSigned tunnelonly when the listchanged, or hourlyRelay (always on)User's phoneOnly the time and the line leave the Mac. Nothing else from memory goes with them.
Who sends a reminder

Each item has three fields: an id, a due time and the text. The text is trimmed to 500 characters. The gateway route is public code in MCP-servers/awe-console/src/index.ts. It accepts at most 50 items and throws out any item whose id doesn’t match ^\d{1,12}:\d{1,12}$. The tunnel side, in MCP-servers/awe-console/src/tunnel/client.ts, posts only when the list has changed since the last post, or once an hour, so a quiet Mac isn’t re-signing the same payload every 5 minutes.

Recurring reminders get expanded into individual occurrences, with a cap of 12 per task and 50 in total. The daily check-in is excluded, and so is anything that needs the Mac to actually do work.

Two senders for one reminder means the reminder can arrive twice

Making a backup copy of the reminders was the easy part. The hard part was the case where both copies fire. The relay holds a list and the Mac holds the real schedule, so either one can send any given reminder. Three failures follow directly from that:

  1. The Mac wakes at 3:01 and runs its catch-up. The relay already sent the reminder at 3:02. The user gets it twice.
  2. The user deletes a reminder at 2:55. The relay’s copy of the list is from 2:50. The relay texts a reminder that no longer exists.
  3. The relay expands a recurring reminder differently from the Mac. Across a DST change the two sides disagree by an hour, and both of them send.

I didn’t throw away much code on this feature. The cost was the time it took to see that none of these is a sync problem. They’re all ownership problems, and the fix is one rule about who owns each send at each moment.

While the Mac is connected, it owns every reminder and the relay never sends. This handles case 2. A reminder deleted a minute ago can’t be texted from a stale list, because the relay is not allowed to use that list while the Mac is reachable.

The relay sends only at due + 2 minutes, only if the Mac is not connected, and it records the id when it does. If the Mac wakes later and its scheduler runs the overdue job, the send includes the same id. The relay drops it as a duplicate, but still writes it into the conversation thread so the history is complete. That handles case 1.

Both sides compute the id the same way, from the stored schedule slot. The id is <task id>:<due unix minute>. I almost got this wrong. The obvious way to build an id at send time is “task id plus now, rounded to the minute”. A catch-up run at 6:15 would then get a different id from the 3:00 occurrence the relay already sent, so the dedupe would never match. The engine therefore reads the stored slot before the run starts and builds the id from that, which is the same value the 48-hour list used. One of the four tests on that module checks exactly this, in both of the timestamp formats the scheduler has stored over time.

Recurring reminders are expanded by the scheduler’s own next-run function. I didn’t write a second expander for the safety list, so time zones and DST resolve exactly the way the scheduler resolves them. That handles case 3. Any reimplementation of recurrence, however careful, eventually disagrees with the original on a boundary.

2:50Mac posts list;reminder id41:<3:00 minute>included2:55lid closed, tunneldrops3:02due + 2 min, Macnot connected:relay sends, marksid6:15Mac wakes,scheduler runsoverdue job withsame id6:15relay sees idalready sent: dropsthe text, keeps thethread entry

Some smaller decisions came out of the same thinking. The window starts 5 minutes in the past, so a reminder that is due right now while the push is in flight still gets handed over. The feature never runs on a cloud-hosted awe, because that instance is woken for its own schedules and doesn’t need a backup. It turns off whenever the scheduler is off. Errors are logged once per change, not on every 5-minute tick, so a relay that is down doesn’t fill the log. The relay side shipped behind a flag. With the flag off, the relay answers stored: 0 and nothing changes, so the Mac release could go out before the relay was switched on.

Occurrence ids come from the stored schedule slot, never the clock

Here is the failure class written as a property you can check, not as advice:

Every scheduled side effect that more than one process can perform carries an occurrence id derived from the stored schedule slot, never from the clock at execution time. At any instant exactly one process owns execution, and that is decided by a liveness signal the other process can observe.

A codebase either meets this or doesn’t. If your ids come from now(), catch-up runs and failovers can’t be deduplicated. If ownership comes from “whoever gets there first”, you will send things twice. If the backup expands recurrence with its own code, the two sides will disagree at DST.

Run this against your own scheduler in five minutes

You need two things: a table of occurrences that were due, and a table of what was actually sent. Most job systems have both under some name. This is the SQLite form. The Postgres version is the same join.

-- Every occurrence due in the last 7 days, and how late its send was.
SELECT o.job_id,
       o.due_at,
       s.sent_at,
       ROUND((julianday(s.sent_at) - julianday(o.due_at)) * 1440, 1) AS late_min,
       COUNT(s.id) OVER (PARTITION BY o.job_id, o.due_at)            AS sends
FROM   job_occurrences o
LEFT JOIN sends s
       ON s.job_id = o.job_id AND s.slot = o.due_at
WHERE  o.due_at BETWEEN datetime('now','-7 days') AND datetime('now','-10 minutes')
ORDER  BY late_min IS NOT NULL, late_min DESC;

Passing output: every row has a sent_at, late_min stays below a couple of minutes, and sends is 1.

Failing output, the version this post is about: rows with late_min in the hundreds, grouped on evenings and weekends. Those are catch-up sends after a lid was opened. Line them up with the machine’s sleep log (on macOS, pmset -g log | grep -E "Sleep |Wake ") and they will match.

Failing output, the other version: sends = 2. That means two writers, no shared occurrence id.

If the join won’t work because your sends have no slot column, you’ve found the problem already. Check where the id comes from:

# Find where the send path builds its idempotency key / occurrence id.
grep -rnE "idempot|occurrence|dedupe|reminder_id" src/ | grep -iE "now\(|Date\.now|time\.time|datetime\.now"

Any hit here means the id comes from the clock and not from the stored schedule slot, so a run made late can’t match the occurrence it is running for.

Catching up on wake answers a different question

Most writing on this treats “the machine was off” as a recovery problem. Rookery’s scheduling docs take the careful version of that position. On start-up it runs everything that came due while the machine was off, folds missed runs into one, and labels a reminder more than two hours late as delayed instead of pretending it’s on time. That is honest, and it’s correct for agents. For a reminder, the late label is the failure.

Aven keeps a background agent running after you quit the app. That solves a closed app. It does nothing for a closed lid. The bridge designs, RemindersBridge and the pattern Notis describes, keep the Mac as the only place reminders exist and make the cloud piece a stateless relay. I agree with that privacy stance. It does mean that a sleeping Mac has no reminders at all.

General agent guidance, such as the Software Engineering Guide on agentic systems and this agentic-loop reference, insists that every action be traceable and that every tool call get exactly one result. None of it discusses what exactly-once means when the executor is a laptop that disappears halfway through. The occurrence id is what makes it traceable across two machines.

What I took from all of this: decide how much state a stateless relay is allowed to hold, and limit it to exactly what has to survive the lid closing. For awe that is a time and a line of text, 48 hours ahead, and nothing else from memory.

What a closed laptop still misses

Only text reminders get handed over. A reminder that needs the Mac to do something, like run an errand or build a brief from memory, still waits for the Mac. The relay doesn’t yet tell the user “I couldn’t run that, your Mac was off.” That message is planned and not built.

The window is 48 hours from the last push. A laptop closed Friday evening and opened Monday morning will have its Saturday reminders delivered and its Sunday-night ones missed.

There is also a gap I have reasoned about but not tested. If a reminder is deleted and the lid closes before the next 5-minute push, the relay still holds the old list, and nothing stops it from sending the deleted reminder. Shorter push intervals make the gap smaller but don’t close it. Closing it means pushing on every schedule change, which is what I’ll add next.