Home/Q&A/My agent stops when I close my laptop lid. What can I do?

My agent stops when I close my laptop lid. What can I do?

Updated · airankrush

Direct answer

A laptop goes to sleep when the lid closes, so a paused task is normal behavior. Either adjust the power settings and keep it plugged in with the lid open, or move the agent to an always-on machine that has no lid to close and does not sleep.

Basis

  • By default a laptop sleeps when the lid is closed. Processes are suspended and the network disconnects, so the agent stops. This is the system's power-saving design, not a fault in the agent.
  • A Mac laptop can run with the lid closed when it is on power with an external display and keyboard attached. The caffeinate command prevents idle sleep but cannot stop the sleep triggered by closing the lid.
  • Running under heavy load with the lid closed for long periods cools poorly, and the task is bound to be interrupted whenever you take the computer out with you, so this only counts as a temporary fix.
  • A desktop Mac mini has no lid and no battery, which suits being left on. A remote Mac mini in the United States keeps running after you disconnect.

Information as of .

Boundaries: when the answer is different

If the task only needs to run for a few hours, keeping the laptop plugged in with the lid open and automatic sleep turned off is enough, and there is no need to find another machine. Moving the task to a remote machine is not a permanent cure either: it stops just the same when that machine is restarted, when the task itself errors out, or when the account's usage allowance runs out, so you still need logs and notifications. We make no promise that a remote machine will run without interruption.

How to do it

  1. Short-term fix: in System Settings, turn off automatic sleep while on power, and keep the lid open.
  2. In the terminal, put caffeinate -i in front of your start command to prevent idle sleep.
  3. If it needs to run around the clock, move the agent's code and configuration to an always-on desktop or a remote Mac mini.
  4. On that machine, start it with tmux or launchd and write the output to a log.
  5. After that, close the laptop and connect back from your phone or another computer to check progress.

Use case

This question belongs to the use case: Mac mini for 24/7 AI agents? Only worth it when the agent needs a desktop or macOS apps

Other questions in the same use case:

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All Q&A