Guide · November 2026

Codex automations stalling at Mac sleep or DarkWake

If a scheduled Codex automation or heartbeat didn't run overnight, or started and then stalled, your Mac's sleep and DarkWake (the few-second wakes it does while asleep) may be involved. Reports from public issues, what you can do for free and where it stops, and how to check yourself.

Lidnight keeps your Mac awake only while Claude Code or Codex is working, even with the lid closed, and lets it sleep when they finish.

Download freePro trial included · no card · Apple Silicon, macOS 13+

What has been reported

These are observations the authors posted in public openai/codex issues. Whether the cause is inside Codex or macOS isn't settled, and most are single occurrences, so it won't always happen (all still open when checked on 2026-11-14).

Due while the lid was closed and the Mac slept: the heartbeat came due while the Mac slept; during a 2-second DarkWake Codex recorded the run and advanced the schedule, but the request to resume the thread timed out and no turn was created. The author says it wasn't retried after a full wake either (#35602, 2026-07-27).

Started in a DarkWake, then stalled: with ‘Prevent sleep while running’ on, an automation started during a DarkWake while the laptop slept on battery with the lid closed; it went back to sleep seconds later, stayed unfinished for about ten hours, and finished after a full wake (#58706, 2026-11-01). The same author filed separately that the displayed working time included the sleep, so the run looked ten-plus hours long while the token counter hadn't moved (#58707).

Even on power, lid closed, auto-sleep off: after an update a heartbeat started about 82 minutes late, roughly 44 seconds after a full wake. The power log showed one continuous DarkWake over the due time and the app process was still logging activity (#53686, 2026-10-13; the author says it isn't established as reproducible or as a regression).

In the CLI, between automatic turns: with the experimental prevent-sleep on and the Mac on power, a goal's turn ended, Codex released its sleep assertion, the Mac entered ‘Idle Sleep’ a few seconds later, the VPN dropped and the goal ended up blocked (#52399, 2026-10-09). Another report: close the lid and the CLI hangs on ‘reasoning’ (#34358, 2026-07-20).

In short, a task you handed over before the Mac slept that stops midway is different from a schedule that comes due while the Mac is asleep. Blocking sleep can reduce the first; for the second, Codex can't work while the Mac sleeps, so blocking sleep alone doesn't cover it.

What you can do for free

1. Codex's own settings: the docs say that on macOS and Linux, turning on Prevent sleep while running (Settings › General) lets local chats continue while you step away. They don't say what happens with the lid closed or on battery (#58706 was filed with it on). The automations docs say to keep the computer on and the app running when a scheduled task needs local files. In the CLI it's codex features enable prevent_idle_sleep (experimental, off by default; codex features list on this Mac also shows experimental and false). More in the Codex CLI guide and Codex app ‘Keep this Mac awake’.

2. Bridging the gaps between turns: caffeinate -i -w <PID> prevents idle sleep until that process exits (man caffeinate: -i idle sleep, -w releases when the PID exits). Give it the PID of the Codex process (from ps or Activity Monitor) and one assertion stays held even if Codex releases its own between turns. -s does the same only on AC power. The man page says nothing about the lid, a comment on #34358 says caffeinate can't stop lid-close sleep, and it can't wake a Mac that is already asleep at the scheduled time.

3. To get through a scheduled time lid-closed, the Mac has to be awake then: connect an external display, or use sudo pmset -a disablesleep 1 (not in man pmset; check it with pmset -g | grep SleepDisabled) and set it back to 0 afterwards (it survives a restart, and a closed laptop in a bag gets hot). That still doesn't fix problems in how Codex handles the schedule, like #35602.

Checking on your Mac

What happened while it slept: in pmset -g log | grep -E "Sleep|DarkWake", look at the DarkWake lines around the scheduled time (how many seconds) and why it went back to Sleep. #35602 posted a log of a 2-second DarkWake followed by ‘Sleep Service Back to Sleep’. Compare with the Codex app log and the thread to see whether a run was recorded then.

What is holding sleep off now: run pmset -g assertions during work. The #52399 author saw in the log that Codex held PreventUserIdleSystemSleep (“Codex is running an active turn”) during a turn and released it at the end. If the list goes empty between turns on your Mac, step 2 is relevant.

Checked 2026-11-14 against the issue text and comments above, OpenAI's docs (automations, app settings), man caffeinate and codex features list. Issue status and docs can change.

Past those limits: Lidnight

Lidnight keeps the Mac awake (lid closed, on battery too) while Codex is working, using the Codex app's work process and Codex hooks, and lets it sleep only after everything has been quiet for 10 minutes. So it targets the Mac dozing off in the short gaps between automatic turns. If a schedule comes due while the Mac is already asleep, Codex isn't working so Lidnight can't wake it, and it can't change how Codex handles schedules. Lid-closed is a Pro feature, included in the free trial. Setting it up with Codex CLI

Try Lidnight free

Apple Silicon Macs · macOS 13 or later. Every download includes a free trial of everything in Pro (5 lid-closed runs or 14 days), no payment details needed. Pro is a one-time payment (1 Mac $9.99 · 3 Macs $14.99, 50% off through Dec 1) with a 14-day refund.

Download freeBuy Pro ›More about Lidnight ›

Homebrew: brew install whereisdw/tap/lidnight