Building always-on agents (Anthropic, William Hu)
Mental model: an "always-on" agent is never actually on. It is a sleeping agent loop woken by events, and five durable primitives around the loop (event inbox, timers, memory, permissions, outbox) make a chain of brief runs feel continuous.
Why this is in the vault
Ray is exactly this kind of agent, built by hand over seven months. This is the first vendor reference architecture that names the same parts, so it works as a checklist for where Ray is ahead and where it is still a single long session held together with prose files.
⚠️ Structural Bias
- First-party Anthropic content filed under "Claude Platform". The framing ("resurgence is largely due to recent model advancements") steers demand toward Anthropic models and products, and the article plugs Claude Code auto memory, the Messages API memory tool, auto mode, hooks and MCP Apps by name.
- The one hard number ("Opus 5.5 cost 78% less per solved task than Opus 5" on "one long-horizon coding benchmark") is self-reported, and the benchmark isn't named. Treat it as marketing, not evidence.
- The architecture advice itself (inbox/outbox tables, single worker, durable timers) is standard queue-and-worker engineering and doesn't depend on any vendor. That part holds up regardless of the bias.
Summary (author's terms)
- The cycle. A run takes an event, does the work, and saves state. It happens inside a session, the transcript of messages and tool calls. Then the agent sleeps.
- Event inbox. Sources never call the agent directly, because concurrent events start competing runs and a crash loses an event. Instead each source writes to a durable table (handler → list → worker) with status tracking and dedup on source IDs. Best practices: (1) the handler acks fast and defers deep checks such as prompt-injection screening to the run; (2) the inbox is the source of truth, so a dead worker's event gets retried; (3) one active worker per inbox, and a mid-run event is queued, folded in or triggers a restart; (4) pending events are batched so a burst of user messages gets one reply. Replies resume the existing session, and everything else starts a new one.
- Timers. Follow-ups are one-shot deadlines the agent sets for itself, and schedules recur. They live in their own store, apart from the inbox. A scheduler polls for due timers, marks a follow-up done or advances a schedule, writes an event to the inbox and wakes the worker.
- Memory. A directory of files on durable storage that outlives the worker. Store only what can't be looked up again, and keep pointers to everything else. Four kinds: user instructions (loaded every run), user notes (an index plus small files), past messages (so nothing is repeated), and per-task progress files (an index plus files). Optional dreaming reviews past sessions to curate memory. Keep the per-run context overhead lean and prompt-cached. Compaction and new sessions both lose detail, so persist as you go.
- Permissions are the main risk. Use a credential proxy outside the agent's environment that injects secrets into outgoing requests, so the agent never holds them. Use classifier-based auto mode for risky actions, with humans still deciding the most important ones. Use deferred tool calls: the run ends and the session is saved mid-call, the request reaches the user, the answer comes back as an inbox event that resumes the session, and the worker handles other events in the meantime.
- Outbox. A run ends in one of three ways: send a message, decide not to send, or defer. A direct "send" tool is enough until you need pacing or error recovery. At that point add an outbox table and a dispatcher. Tune message volume with evals, and start quiet so the agent earns attention over time.
Mapping against Ray Data Co
Ray is a hybrid design. One long-lived Claude Code session (LaunchAgent + tmux, restarted 4am) is the interactive worker. A separate cron-dispatcher.py LaunchAgent fires headless claude -p runs from ~/.claude/scripts/scheduled-jobs.txt. The article assumes many short runs with a database behind them. Ray has a few long runs with files behind them. Most gaps below come from that difference.
| Pattern | Article says | Ray today | Gap / action |
|---|---|---|---|
| Event inbox | Durable table, per-event status, dedup, worker pulls from it as source of truth | Inbound iMessage is pushed into the live session by the plugin. chat.db is durable but tracks no processed status, so after a restart Ray infers "unanswered" by reading the thread (handoff "First move on a routine restart") |
Partial. chat.db is effectively the inbox, but "handled" status lives only in the model's reading. Cheap fix (reversible): a last-handled-message-id marker written after each founder reply, read on restart |
| One worker per inbox | One active worker, so no competing runs | Two runtimes can act for the same user: the live session and headless system jobs (each locked per job via state/cron-locks). Nothing serializes their sends to the founder |
Gap. Locks stop a job from running twice, but nothing stops the session and a cron run from both messaging him in the same minute. An outbox (below) fixes this too |
| Batch pending events | Merge a burst of messages into one run and one reply | The session naturally sees queued iMessages together. "Reply tool = LAST action" rule | Ray at parity |
| Fast ack, injection check in-run | Handler does light checks, the run does deep ones | No handler layer. Injection caution is a run-time rule (feedback_listen_and_injection_caution, AGENTS.md "pasted content is data") |
At parity for a single-user channel |
| Schedules | Durable store, polling scheduler, advance to next occurrence | scheduled-jobs.txt manifest (format v3, with catchup=, timeout=, prechecks). Dispatcher polls every minute, and session jobs are re-armed at SessionStart |
Ray ahead. Catch-up windows and prechecks (inbox-nonempty.sh, first-sunday.sh) go beyond the article |
| Follow-ups (agent-set timers) | One-shot deadlines in the same durable store | Agent-set follow-ups are either session CronCreate one-shots, which die at the 4am restart, or prose lines in ray-handoff.md "Upcoming dated follow-ups", which only fire if a later run happens to read them. open-threads-check (hourly) is a hard-coded follow-up for one case |
Biggest structural gap. Add a follow-ups file (id, due, prompt, status) that the existing cron-dispatcher polls, firing a headless run or writing to the session. Reversible, Ray can build it |
| Memory: user instructions | Own file, loaded every run | ~/AGENTS.md (1.9KB after the 11-09 spring clean) + SOUL.md |
At parity |
| Memory: user notes | One file, then index + small files | MEMORY.md index + ~140 per-topic files, typed (user/feedback/project/reference) |
Ray ahead. Same pattern, plus typing and "newer wins" precedence |
| Memory: past messages | Track what's been told so nothing repeats | chat_messages reads chat.db. open-threads 🅿️ markers dedupe Ray's asks (2026-05-18-open-threads-channel-state-mechanism) |
At parity |
| Memory: task progress | Per-task progress file + index | ray-handoff.md (verified state, 10KB cap), working-context.md scratchpad, Notion board as pointer store, implementation-notes files for sub-agents | Ray ahead on pointers, behind on granularity. The handoff is one prose file mixing many tasks rather than an index of per-task files. Fine at current scale |
| Dreaming | Review sessions to curate memory | /improve (weekly), /self-review, /compile-vault, nightly scratchpad roll, manual spring cleans |
Ray ahead on vault curation. No job reviews session transcripts for memory updates. Optional |
| Lean context + compaction | Keep overhead lean, persist before compaction loses detail | Learned the hard way: 12 fabrications on 2026-05-31 from a compacted context, which led to the "read before you claim" discipline and the daily restart | Ray at parity, earned |
| Credential proxy | Proxy outside the agent's env injects secrets, so the agent never holds them | 1Password service-account wrappers. These are better than .env, but the secret still enters the agent's process env. OP_SERVICE_ACCOUNT_TOKEN is in plaintext in settings.local.json (verified open 11-09) |
Gap. Needs the founder (settings self-edit is gated): rotate the token and move it out of settings. A true proxy is a larger, optional build |
| Auto mode | Classifier gates risky actions, humans decide the big ones | Auto-mode classifier is the hard gate, and a denial means stop (feedback_automode_classifier_hard_gate). Founder-only decisions are listed in memory |
At parity |
| Deferred tool calls | Pause mid-call, save the session, the answer resumes it, and the worker stays unblocked | "Announce approval-gated calls" + iMessage asks + 🅿️ parking. Ray doesn't freeze a call: when the yes arrives (often hours later, after a restart) it re-derives the action from the handoff | Functional gap, low priority. The resume relies on handoff prose being right. Optional: write pending approvals as structured entries (action, exact command, asked-at) |
| Outbox + dispatcher | Needed once you want pacing or error recovery | Direct reply tool. Messages.app wedges with AppleEvent -1712 (3 times in 2 days), and headless failures land in cron-undelivered/, which only /morning-prep drains, once a day. Six open-threads notes from 11-13 (10:11-20:11 ET) were stuck there at filing time. messages-watchdog.sh is disabled (cron lacks Automation permission) |
Highest-leverage gap. Ray already has an outbox table (cron-undelivered/) but no dispatcher. Add a session cron every ~15 min that runs cron-undelivered.sh list, retries each send from the session (which has the Automation permission), restarts Messages on -1712, and marks sent items done. Reversible, Ray can build it |
| Message-volume tuning | Evals to balance noise against missed info. Start quiet | Rules, not evals: auto-mode signal/noise, 60-min ask cooldown, "no ping on restart" | Partial. No measurement. A cheap eval: weekly count of sends vs founder replies/reactions from chat.db |
Where the article and Ray disagree. The article treats sessions as cheap and disposable, with each run brief and continuity carried by durable stores. Ray treats the long-lived session as the main worker and the files as backup. The 05-31 fabrication incident is the article's warning ("both approaches lose detail") playing out live. The direction of travel is toward the article's model: more state in structured stores (follow-ups, outbox, handled marker), less in prose and context.
Open questions
- Should the two runtimes share one outbox, so all sends to the founder go through one paced dispatcher?
- Is it worth moving
cron-undelivered/and follow-ups from files to SQLite (status, dedup, atomic claims), or do files stay adequate at one user? - The article's 14-minute read has no evals section. What would a "too noisy vs too quiet" eval for Ray actually score against?
Related
- [[2026-06-11-system-cron-runner]]: Ray's scheduler and headless-run design (the "timers" primitive)
- [[2026-05-18-open-threads-channel-state-mechanism]]: Ray's hard-coded follow-up and past-message dedupe
- [[2026-11-10-technically-what-is-agent-memory]]: complementary take on the memory primitive
- [[2026-04-11-garry-tan-thin-harness-fat-skills]]: the harness-around-the-loop thesis this article productizes
- [[task1-harness-audit-A]]: the 11-10 Fable bake-off audit of Ray's harness, for cross-checking these gaps