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
caffeinatecommand 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.
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
- Short-term fix: in System Settings, turn off automatic sleep while on power, and keep the lid open.
- In the terminal, put
caffeinate -iin front of your start command to prevent idle sleep. - 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.
- On that machine, start it with tmux or launchd and write the output to a log.
- After that, close the laptop and connect back from your phone or another computer to check progress.
Related questions
- Mac mini for 24/7 AI agents? Only worth it when the agent needs a desktop or macOS apps
- How to keep long tasks running on a remote Mac mini after you disconnect
- Should I buy or rent a Mac mini to run an AI agent 24/7?
- Does a long Claude Code task stop when my remote connection drops?
- Can I connect to a remote Mac mini from my phone to check on my agent?
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:
- Can an AI agent control the screen and browser on a rented Mac?
- Can I shut down a rented Mac mini or put it to sleep?
- How do I know my unattended agent is still running properly?
- Can I automate iMessage and AppleScript on a rented Mac mini?
Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support