Can I run agents with the monitors off?

Yes. Turning your screens off doesn't stop anything that's running. But it's worth knowing why the question feels risky — on a Mac, the display going dark is the moment system sleep becomes possible. Those are two different sleeps, and only one of them freezes your agent.

Short version: display sleep turns the panels off and leaves every process running. System sleep suspends the whole machine and freezes your agent mid-turn. You want the first without the second, and the command for that is caffeinate -i — not caffeinate -d, which keeps your screens lit, which is the thing you were trying to avoid. Closing the lid is a third, separate path that ignores both.

The direct answer

Three different sleeps, often confused for one

macOS has separate timers for the display and for the system, and a third path for the lid. You can see the first two on your own Mac right now:

  • pmset -g custom prints your current settings, and displaysleep and sleep are two independent lines — separate timers, separate values, one block for Battery Power and one for AC Power. Both are in minutes; 0 means never.

Display sleep turns the panels off. Nothing else changes: your agent keeps running, downloads keep going, the shell command it launched keeps writing output. Nothing about a dark screen stops work.

System (idle) sleep is the one that hurts. macOS suspends the machine, and every process is frozen where it stood — not killed. That's why it looks so confusing afterwards: the process is still there, the terminal still has your prompt, and the last thing the agent printed is from twenty minutes ago. macOS decides this from your idle time — how long since real keyboard or mouse input — and from the sleep assertions running processes hold. CPU load is not part of it: a Mac at 100% CPU still idle-sleeps on schedule, which is why an agent burning a core all night doesn't save itself.

Closing the lid is not a timer. macOS doesn't consult the idle settings there; it just sleeps. This catches people who set every timer to never and still lose runs. The supported way to keep a MacBook running with the lid shut is clamshell mode — on power, with an external display and an external keyboard or mouse connected. Assume otherwise that the lid is a hard stop.

One footnote that explains why some overnight runs survive without anyone arranging it: ttyskeepawake is on by default, and man pmset describes it as preventing idle system sleep while any tty — a terminal or remote login session — is active, where a tty counts as inactive only once its idle time passes the sleep timer. So a CLI agent printing output into Terminal can hold the machine up on its own. It's a nice accident, not something to depend on: a quiet or detached session doesn't count, and it isn't attributed in either command below.

The part nobody mentions

Display-off is what allows system sleep

This is the reason the question is a good instinct rather than a silly one. While your display is on, macOS itself holds a system-sleep assertion. Run this and look for it:

  • pmset -g assertions

Near the bottom you get a list of every process currently holding sleep off, by name. On a Mac with the screen on you'll find a line owned by powerd, currently worded PreventUserIdleSystemSleep named: "Powerd - Prevent sleep while display is on". That's the OS saying: the screen is lit, so I won't idle-sleep yet.

So the sequence that eats overnight runs is: display timer fires → screens go dark → that assertion goes away → the system idle timer is now free to fire → the Mac suspends and your agent stops. The monitors going off didn't stop the work. It removed the accident that was protecting it.

Which also explains a mistake worth avoiding. caffeinate -d holds the display awake, and because a lit display blocks idle sleep, it looks like it fixed the problem. It did — by leaving your panels on all night. If your reason for asking was an external monitor you'd rather not leave burning for eight hours, -d is the wrong flag.

That same list is how you audit any keep-awake tool, including ours: anything holding a power assertion — caffeinate, Amphetamine, KeepingYouAwake, AgentBarista — shows up there by name. One exception worth knowing: pmset -a disablesleep 1 keeps a Mac awake without creating any assertion, so a tool relying on that alone appears nowhere in that list. You catch it with plain pmset -g, which reports it as SleepDisabled 1. AgentBarista runs that command too, in its opt-in lid-closed mode — but on top of a caffeinate assertion, not instead of one, so we're in the assertions list either way. Between the two commands you can see anything holding a power assertion or a disabled sleep timer.

The free option

Screens off, agent running — for free, in one command

Everything here ships with macOS:

  • Hold system sleep only. caffeinate -i your-agent-command blocks idle system sleep for as long as that command runs, and leaves the display timer alone — so your screens still go dark on their own schedule. That is exactly the combination you asked for. It releases itself when the command exits.
  • Already running? caffeinate -i -w <pid> attaches to a process that's already going and lets go when it ends. Find the pid with pgrep -l claude, pgrep -l codex, or whatever your agent's binary is called. If several come back, pgrep -x claude matches the process name exactly and skips helper processes — don't reach for -f, which prints full command lines and buries the one you want under pages of flags.
  • Turn the screens off now, deliberately. pmset displaysleepnow puts the displays to sleep immediately without touching the system. The keyboard shortcut is Control-Shift-Power (Control-Shift-Eject on older keyboards). Don't confuse it with pmset sleepnow, which is full system sleep and will freeze your agent.
  • The permanent setting, if the Mac lives on a desk. System Settings → Displays has a "prevent automatic sleeping when the display is off" option on Macs that qualify — note it applies on the power adapter, not on battery. The exact wording and placement move between macOS versions and models, so confirm the result rather than the label: pmset -g custom will show you the sleep value it actually set, under AC Power.
  • Afterwards, settle the argument. pmset -g log | grep -i "Entering Sleep" gives you timestamped sleep events — but read the reason in quotes before you blame it. 'Maintenance Sleep', 'Sleep Service Back to Sleep' and 'Notification Wake Back to Sleep' are short dark wakes that fire many times a night on a healthy Mac — on the Mac this page was written on they were 486 of 624 entries — and they are not your culprit. 'Clamshell Sleep' means the lid closed. 'Software Sleep pid=…' means a program, or you via the Apple menu, asked for it. Any other reason in the window where your agent went quiet is your real sleep event. No entry in that window? Look at a crash, a rate limit, or the agent finishing and waiting on input.

For occasional runs this is genuinely all you need, and there are free menu-bar apps if you'd rather click than type. Amphetamine gets closer than a bare command — its app and CPU triggers do release on their own — but it triggers on a process existing or a CPU threshold, not on an agent's turn ending, so an agent waiting on a model at near-zero CPU can read as finished. With bare caffeinate you hold and release by hand, and forgetting on battery is how people come back to a flat Mac.

Where we stand — honestly

What AgentBarista does, and one thing it doesn't

AgentBarista watches for real agent activity — process command lines and CPU, session-file timestamps, and optionally on-screen text — and holds sleep off only while there's work, then lets your Mac sleep normally once the run is done. Free tools do the holding, and the free ones with hooks (Keepresso, adrafinil) do the letting go too — for a solo dev Keepresso is genuinely excellent and it costs nothing. Where we earn the price: it shows you what it actually kept awake, and it's first to support brand-new agents as they ship. A battery cutoff keeps an unattended run from flattening the machine — table stakes in 2026, not a reason to pay.

The thing this page is about, we don't do yet. Under the hood AgentBarista starts caffeinate -dimsu. That d — plus u, which can even switch a dark display back on — means it holds your display awake too. So today, if your specific goal is "screens off, agent running", the free caffeinate -i above does that better than our app does. You can verify both the same way, with pmset -g assertions. A display-sleep-allowed mode is a small change and it's now on our list — we'd rather write that here than let you find it at 2am.

It lets go by itself

Detects when the work is actually done and releases sleep prevention, instead of holding it until you remember. That's the difference from a manual command.

It won't flatten your battery

A battery cutoff for unattended overnight runs, plus a one-click restore for the rare case a crash leaves sleep disabled.

It tells you what it kept awake

Local, content-free stats on how much agent time it held the Mac awake for — counted separately for lid-open and lid-closed runs and never added together, so the number means something.

It runs on your Mac.

AgentBarista never opens your files. To tell a working agent from a finished one it looks at process command lines and CPU, at the names and modification times of your agents' session files, and — only if you grant macOS Accessibility permission — at the on-screen text of the agent apps you enable and of the terminals we support. Two of those can contain your own words: a command line includes any prompt you pass on it, and on-screen text includes whatever is visible in that window, your code included. Both are matched against status phrases on your Mac and discarded on the spot: never stored, never sent. Nothing about your work leaves your Mac — no file contents, no code, no prompts, no file names, no activity data. Your stats and settings stay on this Mac. The app contains no analytics or telemetry of any kind. Its one network call is license validation, sent to our payment provider, Lemon Squeezy: activating a license sends your license key and your Mac's name, and the routine check after that sends your license key and an anonymous instance id — nothing else.

Pricing

Try it free, then keep it. No subscription.

Pro, one-time
$19 once
  • 14-day free trial, no card needed
  • $15 founding price for the first 200 customers
  • Includes 1 year of updates
  • Lifetime option: $39 once, updates forever
Get notified at launch

Not live yet — leave your email and we'll ping you the moment it is.

Running agents across a team instead? See team pricing.

Per-agent guides

Which agent are you running?

Same Mac-goes-to-sleep problem, tool by tool — including the exact caffeinate wrap for each: