For Codex

How do I keep my Mac awake while Codex works?

Short answer

Codex can hold off sleep, but not by default in the CLI, and not with the lid closed. The CLI's prevent_idle_sleep is experimental and off until you turn it on. The app has "Prevent sleep while running". Open bug reports show the Mac sleeping between automatic turns and on power. Night Crew adds a hook, lid mode and battery guards.

By Atique Firoz · Updated

What Codex already does about sleep

Codex has three settings that touch sleep. They live in different places and do different jobs.

Setting Where What it does
prevent_idle_sleep Codex CLI, ~/.codex/config.toml Holds off sleep while a turn runs. Experimental, off
Prevent sleep while running Codex app, General settings Stops the Mac sleeping while Codex works
Keep this Mac awake Codex app, Control this Mac Keeps the Mac reachable for remote use from your phone

The CLI setting. OpenAI’s config reference describes features.prevent_idle_sleep as: “Prevent the machine from sleeping while a turn is actively running (experimental; off by default).” You can turn it on with /experimental inside Codex, or in your config file:

[features]
prevent_idle_sleep = true

The app settings. OpenAI Academy’s guide to Codex settings lists Prevent sleep while running for long jobs. The Keep this Mac awake switch sits with the app’s remote control settings (#23294).

Where that falls short

  • Off by default in the CLI. Unless you turn it on, nothing in the Codex CLI holds the Mac awake.
  • Between turns. In a goal with automatic turns, one report says “macOS entered idle sleep after an intermediate turn released its sleep-prevention assertion” (#52399, CLI 0.161.0, open).
  • On power, with remote control. “Keep this Mac awake” didn’t stop a MacBook on the charger from sleeping. It “went to sleep, dropped off the network, and became unavailable” (#23294, open, 10 thumbs-up).
  • The lid. Closing the lid is forced sleep, which apps can’t prevent (QA1340). One report: after closing the lid, the CLI stays stuck “reasoning” (#34358, codex-cli 0.144.6).
  • After a sleep. Requests can fail with error sending request for url once the Mac wakes (#3355, 34 thumbs-up). Later comments report it in the IDE extension and the app too.
  • Battery. The setting’s description says nothing about battery level.

What Night Crew adds

  • A hook, not a guess. Night Crew adds a small hook to Codex, so it knows when a turn starts, when a tool runs, when Codex waits for your approval and when it stops.
  • It holds across turns. After a turn ends, Night Crew waits 60 seconds before it lets the Mac sleep, so a next turn that starts within that time keeps the same lock. You can stretch the wait to as much as 10 minutes.
  • Lid mode. Close the lid and Codex keeps working. It’s on the charger only by default, and sleep comes back as soon as Codex is done.
  • Guards. A battery floor at 15% (30% in lid mode on battery), a heat guard that’s always on in lid mode, and a 24-hour cap.

Night Crew’s Codex hook is for the Codex CLI. We haven’t confirmed whether the Codex app or IDE extension run the same hooks yet.

How to set it up

  1. Download Night Crew and open it.
  2. Open Settings › Agents and click set up next to Codex. Night Crew backs up ~/.codex/hooks.json first, adds its entries next to any hooks you have, and keeps the three newest backups.
  3. In Codex, click Review hooks next to the message box, or type /hooks, and allow Night Crew’s hooks. Codex asks once.

To remove it, use the same row in Settings › Agents: one click and a confirm. For the lid question in more depth, see Can I close my laptop while an agent runs?. To compare Night Crew with caffeinate and other apps, see /compare.

Questions

Does Codex work when my laptop lid is closed?

Not on its own. Closing the lid forces the Mac to sleep, and Codex's settings only stop idle sleep. One open report says the Codex CLI stays stuck "reasoning" until the lid opens again. Night Crew's lid mode keeps a closed Mac running while Codex works, on the charger by default.

Why does Codex ask me to approve Night Crew's hook?

Codex runs a hook only after you trust it, which is a good rule. After you set up the hook in Night Crew, click Review hooks next to the Codex message box, or type /hooks, and allow Night Crew's entries. You do this once.

Should I turn on prevent_idle_sleep as well?

You can, and it does no harm. Codex's own setting holds the Mac awake during a turn, and Night Crew's lock sits alongside it. Night Crew adds what the setting doesn't cover: the gap between turns, the closed lid, and a battery floor at 15%.

Sources

  1. Codex config reference: features.prevent_idle_sleep
  2. OpenAI Academy: Codex settings ("Prevent sleep while running")
  3. codex #52399: sleep between automatic turns of a goal
  4. codex #23294: "Keep this Mac awake" fails on power
  5. codex #34358: Codex CLI hangs if the lid is closed
  6. codex #3355: request errors after the MacBook sleeps
  7. Apple QA1340: idle sleep vs forced sleep

Checked 5 November 2026.

Put your Mac on the night shift.

macOS 14+ · Apple silicon · signed and notarized by Apple

Buy the licence · $9