If you run AI agents, long-running AI sessions that each have one job, they need a computer that stays awake. This article shows how our agents stopped for eleven hours, why our first explanation was wrong, and how to check your own setup.

Also on this topic: why your AI should not grade its own work, what an AI agent is and what MCP Analytics is.

Our position: list what your agents depend on, test the part you think is safe, watch from the outside, and check the real cause before you change anything.

The answer first: a real night, and what it showed

AI agents need a computer that stays awake to keep working. Ours stopped for eleven hours because a laptop slept with its lid closed, on battery, while a stay-awake program ran whose strongest setting only counts on the charger. Our first story about why was wrong.

What happened to us (one case)

We run a team of AI agents. Each is a long AI session with one job. Some run on a small desktop that is always on the wall plug. The rest ran on a laptop. One evening the laptop’s lid was closed. The next morning, our incident record showed the laptop’s agents had done nothing for eleven hours. The desktop’s had kept working.

Two bars for one night. The agents on the laptop worked, then were silent for eleven hours. The agents on the desktop kept working.
One night, two machines. Source: our own incident record. The bar lengths are a sketch.

Our first story was that the stay-awake program had failed. Before we changed anything, we looked at the laptop’s sleep log. The line from that night read: “Entering Sleep state due to Clamshell Sleep ... Using Batt”. The lid was closed, and the laptop was on battery. Apple’s manual for the stay-awake tool says its strongest setting “is valid only when system is running on AC power.” The charger was not plugged in. So it took three things at once: the lid closed, the charger out, and a setting that needs the charger.

Three boxes joined by plus signs: lid closed, charger out and on battery, strongest stay-awake setting needs the charger. Together they put the laptop to sleep.
The three things that lined up. Source: our own sleep log and Apple’s caffeinate manual.

What this means for you

  • Safe-looking parts fail too. A stay-awake program was running. It still was not enough.
  • One cause is rarely the whole story. Several small things lined up.
  • A machine cannot tell you it is asleep. You need something outside it to notice.
  • Write your first explanation down, then try to prove it wrong.

Why the first story misleads

Safety experts have a name for this pattern. Richard Cook wrote that big failures often come when “small, apparently innocuous failures join to create opportunity for a systemic accident” (How Complex Systems Fail, 1998). He describes complex systems; our three things are our own evidence, from our own log.

Doctors know the trap of the first answer. In one study of 100 diagnostic errors in internal medicine, “premature closure”, stopping at the first explanation, was the single most common cause (Graber, Franklin and Gordon, 2005). Fixing a computer is not medicine. We use it as a comparison only.

What a dependency is, and why a list of them matters

A dependency is something your agents cannot work without. An agent needs a computer and power to keep working, for example. If any one important part stops, the agents can stop. Google’s reliability engineers put it this way: “A service cannot be more available than the intersection of all its critical dependencies” (Treynor, Dahlin, Rau and Beyer, 2017). The same paper names the fixes: remove the dependency, or add a backup for it.

Here is a short example from our own setup. It shows the shape of the list, not every line of ours.

DependencyOn a single machine?What we did
The laptop’s powerYesIt stays on the charger, and a check flags battery
The laptop’s lidYesA check flags a closed lid
Where deadline work runsYes, if on the laptopIt runs on the desktop
Knowing an agent went quietNo, a second computer watchesIt warns us when it cannot reach the laptop

A dependency list versus a stay-awake program

  • A stay-awake program. It handles one thing, whether the computer sleeps, and only within the limits its manual states. Ours did not count on battery.
  • A dependency list. It names every part your agents need, so you can see which sit on a single machine and decide what to remove or back up.

How to run the check on your own setup: eight steps

  1. List every dependency, one line each: which computer, is it plugged in, is the lid open, the internet, your AI account and its limits, any password that can expire. Circle anything that lives on a single machine. For each circled line, remove it or add a backup.
  2. On a Mac, check your power. This shows whether the Mac is on the charger or on battery. If it says battery, the strongest stay-awake setting does not count.

    Type this on a Mac (Mac only):

    pmset -g batt
  3. See which stay-awake promises are on. Type the command below. You get a list, one setting per line: a name, then a 0 or a 1. Find the line that starts with PreventSystemSleep. A 1 means a program is asking the Mac to stay fully awake right now. A 0 means nothing is. If you see a 0 on a night your agents must run, find out what is supposed to keep the Mac awake and fix that first. Treat it as a clue, not a guarantee: one good reading does not promise a good night.

    Type this on a Mac (Mac only):

    pmset -g assertions

    What our laptop showed that night, on battery:

    PreventUserIdleSystemSleep    1
    PreventSystemSleep            0
  4. After a bad night, look at the full sleep log. The log records when the computer slept and why. Keep the whole output.

    Type this on a Mac (Mac only):

    pmset -g log
  5. Test the safe-looking part on purpose. The idea is to carefully test what happens when you unplug the charger. Engineers call this chaos engineering: experimenting on a system “to build confidence in the system’s capability to withstand turbulent conditions” (Principles of Chaos Engineering). Pick a quiet afternoon. Run no deadline work and save your work. Unplug the charger, close the lid, wait, and try to reach your agents from another device. Know how you will wake it if it does not answer.
  6. Check from another computer. A sleeping computer cannot tell you it is asleep, so have a second computer, or an online checking service, ask “are you there?” every few minutes. Engineers call this black-box monitoring: “testing externally visible behavior as a user would see it.” (Google’s SRE book). Make the knock mean something: check that the agent made something new, not only that the machine answers. A missed knock can be the internet. So wait for two in a row. We alert after two misses in twenty minutes. That is our choice, not a rule. Keep alerts quiet unless you need to act. Do not open your computer to the whole internet to do this.
  7. Put deadline work where power is not the weak link: a desktop on the wall plug, a computer you rent in the cloud, or a laptop on the charger that you have tested. Each costs something: money, setup or care.
  8. When something breaks, write your first story down in one sentence, then ask what would prove it wrong, and get that evidence before you change anything.
Four boxes in a row: two answered knocks, then two missed knocks, then an alert.
Watching from the outside. The two-misses-in-twenty-minutes rule is our own choice. Source: our practice; black-box monitoring from the Google SRE book.

What you need and what you get back

What you need: a list of what your agents depend on, a quiet afternoon for one test, and a second machine or hosted check to knock from outside.

What you get back: a list of parts with no backup that could stop everything, the real cause of any bad night written down with its evidence, and an alert that fires when an agent goes quiet.

What we changed

The laptop stays on the charger. A check flags it when the laptop is on battery or its lid is closed. A second computer warns us when it cannot reach the laptop. Work with a deadline runs on the desktop.

Limits

This was one night on one laptop. It shows the mechanism, not how often it happens. The commands are for a Mac. Windows and Linux handle sleep differently, and settings differ between Macs. Apple’s pages do not say whether the charger alone keeps a closed laptop awake with no external display. Test your own setup. The research on failures comes from big internet services and hospitals, not small businesses.

Questions business owners ask

Why did our AI agents stop overnight?

In our case, the laptop they ran on went to sleep: the lid was closed, it was on battery, and the stay-awake tool's strongest setting only counts on the charger. This is one case. It shows the mechanism, not how often it happens.

Is a stay-awake program enough?

Not by itself. Apple's manual says the strongest setting of its stay-awake tool is valid only when the Mac is on AC power. Check your own setup, because settings differ between Macs.

What is a dependency?

Something your agents cannot work without: a computer, its power, the internet, your AI account and its limits, or a password that can expire.

Why watch from the outside?

A sleeping computer cannot tell you it is asleep. A second machine or a hosted check that asks "are you there?" every few minutes will notice.

Do these commands work on Windows or Linux?

No. The commands are for a Mac. Windows and Linux handle sleep differently.

Does the person still decide?

Yes. The checks show what is wrong. A person decides where the deadline work runs and what is worth the cost.

Sources