An overnight agent run: why the Mac sleeps and what helps
The run was meant to go through overnight. In the morning it sits at step four of thirty, and the log breaks off mid-sentence.
Long runs have become the normal case
An agent that restructures a project, gets a test suite green or drives a migration needs hours, not minutes. Whether that is Claude Code in a terminal, Codex, an agent inside Cursor, Copilot, Gemini CLI or another tool of the kind — and whatever model is doing the thinking behind it: the run only survives if the machine survives.
The machine is not the problem here. The problem is the rule by which it sleeps — time without a keystroke, not load. An agent does not type.
What actually goes wrong at night
The dark display is harmless. The machine carries on, and for a run with no audience a dark screen is the thriftier choice anyway. Only system sleep brings everything to a halt.
Second point: the charger. An overnight run on battery ends when the battery ends — and not cleanly, but mid tool call. If you run at night, you plug in.
Lid closed, machine running
Many people want to close the lid and go to bed. That is the case a keep-awake session alone does not cover: a closed lid is its own rule in the system, and for that you need lid mode and its helper.
Heat is part of the decision. A closed machine sheds it through the enclosure — on a desk that works, inside a closed bag it does not. For an overnight run you leave it out in the open.
The routine you learn once
Before starting, pick a span that reaches past the expected duration: twelve hours for a night, twenty-four for a weekend. The icon fills, time remaining and end time sit in the panel.
After that there is nothing left to do. If the agent finishes early, the machine sleeps by itself once the span is over; if it is slower, the span was generous enough. Either beats a permanent switch nobody thinks about in the morning.
The night checklist
- Plug in the charger.
- Set a twelve- or twenty-four-hour span before the run starts.
- Turn on lid mode if the lid is going down — and leave the machine out in the open.
- Check the icon: filled means the session is running. Outlined means it is not.
Common questions
Why not just use caffeinate?
For a run that hangs off a terminal, caffeinate is the cleaner choice — it ends with the command. But it does not survive closing the window, shows no time remaining, and does not help with a closed lid.
Is keeping the display on enough?
The other way round: the display may go dark. What has to be prevented is system sleep, because that is what stops the run.
A run that is finished in the morning instead of sitting at step four is the whole difference. The home page says what Toxin does for free and what Pro adds.