Anthropic's 5 Core Rules for Always-On Agents: The Sleep-Wake Architecture Pattern
Key architectural patterns for building always-on AI agents based on Anthropic's engineering guide: event inboxes, separated timers, lean memory with dreaming,
The single biggest misconception when engineering autonomous AI agents is assuming that an 'always-on' system must continuously execute an active loop 24 hours a day. According to an engineering guide published by Anthropic, an effective always-on agent spends the vast majority of its day asleep. It wakes up only when an event arrives, executes a short and focused run, commits its state to storage, and immediately returns to sleep. Engineer Tekon Burns (@TekonBurns) distilled the guide into five fundamental architectural components.

Image source: TechCrunch 쨌 CC BY 2.0 쨌 https://creativecommons.org/licenses/by/2.0 쨌 https://commons.wikimedia.org/wiki/File:Dario_Amodei_at_TechCrunch_Disrupt_2023_01.jpg
From a user's perspective, an agent should feel persistently responsive and always available. However, keeping an inference loop spinning continuously on the infrastructure side is an expensive implementation mistake. Idle polling burns tokens and degrades context without delivering real value. The entire challenge centers on clean state handoffs between runs: letting the agent rest until needed, and ensuring it can pick up exactly where it left off without reprocessing unnecessary data.
1. Event Inbox: Decoupling Webhooks from Worker Execution
Connecting incoming webhooks directly to an active agent worker creates concurrency hazards, race conditions, and unhandled request timeouts.
- Database Buffering: Insert a robust database table between incoming webhooks and the agent runtime. The incoming webhook endpoint acknowledges the caller immediately with a fast 200 OK, while the payload is serialized and placed into the inbox queue.
- Single Worker per User: Ensure that only one agent worker runs actively for a given user at any single moment. This serialized lock prevents parallel runs from colliding and clobbering persistent state.
- Message Batching: If a user sends multiple messages in rapid succession, the inbox batches them into a single coherent prompt payload instead of spinning up multiple overlapping inference cycles.
This pattern isolates external delivery instability from execution logic, stabilizing the entire ingestion layer.
2. Timers: Isolating Scheduled Wakeups from Real-Time Inboxes
When an agent needs to check on an external job in two hours or schedule a recurring weekly brief, storing that schedule in memory or within an active thread creates severe vulnerability during restarts.
- Dedicated Schedule Table: Maintain timers in a table separate from the immediate event inbox. Split schedules clearly into one-off follow-up reminders and recurring interval schedules.
- Lightweight Background Poller: A small system daemon or cron service periodically polls the timer table for due entries. When a timer matures, the poller writes an event into the primary event inbox.
The agent never spends compute cycles watching the clock. It simply awakens when an event lands in its inbox, whether triggered by a human message or a scheduled timer dispatch.
3. Lean Memory and Dreaming: Minimizing Cold-Start Token Taxes
In a sleep-wake architecture, the primary recurring operational cost is reading cold-start context. Loading full chat transcripts and heavy documentation every time an agent awakens incurs a heavy token tax that quickly escalates.
- Retain Only Irreplaceable State: Never store data that can be re-fetched dynamically from upstream APIs. Store only core user instructions, manual user notes, distilled message history, and active task progress trackers.
- Wakeup with Lightweight Indexes: When waking up, the agent should only load a compact index rather than entire file hierarchies or full historical corpora. Detailed context should be retrieved selectively on-demand using targeted tool calls.
- Periodic Dreaming Passes: During idle background windows, run a dreaming pass. This maintenance process summarizes outdated dialogues, resolves conflicting facts, and prunes stale scratchpads, preserving a lean and accurate long-term memory footprint.
4. Unattended Permissions: Outside Proxies and Deferred Tool Calls
When an agent acts autonomously without a human actively supervising every prompt, permission boundaries must be tightly enforced outside the model's direct sandbox.
- No Raw Credentials in Sandboxes: Never inject raw API keys or database connection strings directly into the agent's runtime environment. Route all external actions through an external proxy layer that validates scope, checks rate limits, and injects authorization tokens downstream.
- Deferred Tool Calls for Sensitive Operations: High-risk actions—such as processing a payment, altering permissions, or modifying production records—should trigger a deferred tool call. Instead of blocking the worker process, the agent saves its execution state, queues a human approval request, and goes back to sleep. Once approved, the agent wakes up and resumes cleanly.
5. Outbox: Delivery Cadence and Idempotency Guarantees
An agent's output layer requires the same defensive buffering as its input layer.
- Pacing and Quiet Hours: Just because an agent finishes a background research task at 3:00 AM does not mean it should notify the user immediately. An outbox queue buffers outgoing messages, enforcing reasonable pacing and respecting designated notification windows.
- Idempotency Keys: Network retries and worker restarts can lead to duplicate dispatches. Attaching a unique idempotency key to every outgoing message ensures that retried delivery jobs never result in duplicate emails or repeated chat alerts.
Building a dependable always-on agent is less about model cleverness and far more about state discipline across sleep-wake cycles.
Original source
- Tekon Burns (@TekonBurns) on X: https://x.com/TekonBurns/status/2121328737174388847