๐ค For AI agents
Why AI agents need your Mac awake
Agents like Claude Code, Codex CLI and Gemini CLI are not chatbots. Hand them a long plan and they run for hours - and the moment macOS sleeps, the whole run freezes. Here is what actually happens, and how to stop it.
The loop that runs for hours
Give an agent a real task and it works in cycles: plan, read files, write code, run shell commands, analyse the output, then iterate. A single refactor on a medium repo can take hours. Add a multi-agent orchestrator like Claude Flow and you have pipelines that run all night.
What sleep actually does to it
When the Mac sleeps, the agent process is frozen. You do not lose the work already written to disk, but the task stops and does not resume on its own when the Mac wakes. Worse, anything that depends on timers or the network can break while it is out - expired sessions, revoked API tokens, half-written files, a repo left in an inconsistent state. The fix is not to disable sleep forever; it is to keep the Mac awake only while the agent is actually working, then let it sleep.
Frozen, not resumed
The process pauses on sleep and stays paused on wake - the run does not pick up where it left off.
Expired sessions and tokens
Auth that was valid when you stepped away can be revoked or timed out by the time the Mac wakes.
Inconsistent state
A command cut off mid-write can leave files, branches or migrations half-applied.
caffeinate, power profiles, clamshell - or AwakeMate
There are a few ways to hold off sleep. Each has a place; here is the honest trade-off.
caffeinate commandTargeted, lid-open sessions you start and stop by hand.Manual and all-or-nothing; holds the whole Mac awake; no per-tool sense; lid-open only.Lid-closed note: AwakeMate also offers an optional lid-closed mode that works on most Apple Silicon Macs, but Apple forces sleep on some - test by closing your lid. For guaranteed lid-closed, clamshell is the official route.
Why AwakeMate is the one built for agents
It knows your agents by name
Auto-detect watches for claude, codex and friends - and Deep CLI detection sees them even when an npm-installed agent shows up as node.
Awake while working, asleep after
Keep the Mac up for the whole agent run, or turn on idle-aware sleep for CPU-bound jobs so it sleeps the instant the work is done.
Never touches your energy settings
It holds the same gentle power assertion caffeinate uses - idle sleep only, no telemetry, nothing global to remember to undo.
Live status in the notch
See exactly what is keeping the Mac awake and for how long, with battery rules and a low-battery cutoff for overnight runs.
Free 14-day trial ยท one-time $39.99 ยท no telemetry ยท macOS 13+
Frequently asked
What happens to my AI agent when the Mac goes to sleep?
The agent process is frozen. You do not lose the work already written to disk, but the run stops and does not resume on its own when the Mac wakes. Anything in flight - a shell command, a model call, an open session - is interrupted, and tokens or sessions can expire while the Mac is asleep.
Does the caffeinate command keep an agent alive?
For a targeted, lid-open session, yes - `caffeinate` blocks idle sleep while it runs. But you have to wrap each run and remember to stop it, it holds the whole Mac awake (not just your agent), and it does nothing per-tool. AwakeMate automates the same gentle power assertion, scoped to the tools you choose.
Can I keep my Mac awake with the lid closed for an overnight agent run, even on battery?
Yes - turn on "Keep awake with the lid closed" in Settings - Options and approve the one-time helper. AwakeMate keeps the Mac awake with the lid shut while your agent runs and dims the built-in screen to save battery. It works on most Apple Silicon Macs (Apple forces sleep on some, so test by closing your lid), on battery or power - on power is best for long overnight runs. The only officially supported lid-closed route is clamshell mode (external display + power). See it in action.
Will it cut my agent off when it goes quiet between steps?
Not if you leave "Sleep when tools go idle" off, which is the right setting for agents. They spend long stretches waiting on the model and on your approval, so AwakeMate keeps the Mac awake the whole time the agent process is running, quiet pauses included.