No, not for local work. A /goal in the ChatGPT desktop app, the Codex CLI or the IDE extension, a scheduled task in a local project and a chat's scheduled check-in all run on your Mac, so closing the lid sleeps the Mac and they stop until it wakes. Codex's Prevent sleep while running setting keeps the Mac awake while a task runs with the lid open; it cannot stop lid-close sleep. OpenAI's answer for a closed lid is an external display. With nothing attached, arm Clamshell for Mac before you close it.
Clamshell for Mac keeps the Mac awake with the lid closed while armed, so a local Codex goal or scheduled task keeps running. Free for 7 days.
Download free trialApple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99
Goal mode lets Codex work toward one outcome on its own, turn after turn. OpenAI's changelog for May 21, 2026, when it left the experimental stage, says it can "drive toward a specific objective for hours or even days". That is exactly the kind of job you start before bed or before you leave, and the question is what it needs from the Mac in the meantime.
What each Codex surface needs from your Mac
| Surface | Runs on | Needs | Lid closed, no display |
|---|---|---|---|
| Goal in the ChatGPT desktop app | Your Mac | Mac awake and online, app running | Stops until wake |
| Goal in the Codex CLI or IDE extension | Your Mac | Mac awake and online, the session or workspace open | Stops until wake |
| Scheduled task in a local project | Your Mac | "Keep the machine powered on and the ChatGPT desktop app running", project on disk | Does not run while asleep |
| Scheduled task inside a chat | Your Mac, for a local chat | Same as above; it returns to the chat on a schedule | Does not run while asleep |
| Codex Cloud, ChatGPT web scheduled tasks | OpenAI's servers | Nothing from your Mac, but no direct access to its folders | Keeps going |
Sources: OpenAI's long-running work, scheduled tasks and Codex Cloud docs. Every local surface also needs the network, because the model runs at OpenAI; the long-running work docs say to pause the goal before you expect to lose connectivity. GitHub reports call a recurring task attached to a chat a heartbeat, the name the April 2026 changelog used when it added "heartbeat automation affordances in threads".
What Prevent sleep while running does, and does not
There are two keep-awake settings in the ChatGPT desktop app, and they do different jobs. The labels below are the ones in the current app (26.1002.52244) and in OpenAI's settings docs.
Prevent sleep while running
In Settings, General. The app describes it as "Keep your computer awake while" the app "is running a task", and the docs say to turn it on for local work "so your Mac stays awake". The CLI has an experimental equivalent, features.prevent_idle_sleep, which OpenAI's config reference describes as preventing sleep "while a turn is actively running" and lists as off by default.
Keep this Mac awake
In Settings, Connections, for using the Mac from your phone. The app describes it as "Prevent sleep when computer is plugged in and remote access is enabled". More in Codex Keep this Mac awake not working.
Neither setting stops the sleep a closing lid causes. Apple's developer note QA1340 classes closing the lid as forced sleep, which apps can delay but not prevent; an app's keep-awake only blocks idle sleep, the timer that fires when nobody touches the Mac. OpenAI's remote connections docs say the same thing in practice: a Mac laptop stays available "with the lid open and power connected. With the lid closed, connect an external display as well."
What users report
These are open GitHub reports, each from one reporter, and none is confirmed as a reproducible bug by OpenAI as of October 17, 2026. They show where the edges are.
- A gap between turns, lid open. In #52399 (CLI 0.161.0, on power, experimental prevent-sleep on), macOS logged Codex releasing its sleep assertion after an intermediate turn of an unfinished goal, and macOS entered idle sleep seconds later, just as the next automatic turn began. The VPN dropped and the goal ended blocked on connectivity. The reporter recorded it once and has not reproduced it reliably.
- A late check-in, lid closed. In #53686, with the lid closed on power and idle sleep disabled, a recurring heartbeat attached to a chat ran during a long DarkWake on one desktop build and, after an update, did not start until about 44 seconds after a full wake, roughly 82 minutes late. The reporter says it is not established as a regression.
- Locked use during an unattended goal. #49808 reports Computer Use failing to unlock the Mac after a display-dim lock late in a local goal; that is about locking, covered in Codex Locked use with the lid closed.
- Prevent sleep while running and a closed lid. #21703 reports the desktop app disconnecting during closed-lid use on a mobile hotspot despite the setting.
To see what happened on your own Mac, the pmset manual's pmset -g log shows the history of sleeps and wakes, and pmset -g assertions lists which apps hold the Mac awake right now.
Ways to keep a goal running
Lid open, on power, Prevent sleep while running on
Free and what OpenAI's docs describe. Fine on a desk at home. For a CLI goal, caffeinate -i -w "$(pgrep -nx codex)" in a second terminal holds off idle sleep until that Codex process exits, which also covers the gaps between turns.
External display (clamshell mode)
OpenAI's documented closed-lid setup: power and an external display, and Apple's clamshell mode also asks for an external keyboard and mouse (Apple). It ends when you unplug and leave.
Codex Cloud
For work that does not need your Mac. OpenAI says each cloud task "can keep working while your computer is asleep". Each task works in its own cloud workspace, not in the folders on your Mac.
Clamshell for Mac
Keeps an Apple Silicon MacBook on macOS 14 or later awake with the lid closed while armed, with no external display, sudo or admin rights. It also holds an idle-sleep assertion for the whole armed session, so the gaps between turns are covered too. Thermal safety is always on. $9.99 once after a 7-day free trial.
Try it freesudo pmset -a disablesleep 1 also stops lid sleep with nothing attached, but it is a global admin switch that stays on until you undo it. Read pmset disablesleep explained before you use it.
Set up a lid-closed goal
- Plug in and put the Mac on a hard, ventilated surface. Disconnect external displays, since Clamshell pauses instead of arming while one is connected.
- Leave Prevent sleep while running on in Settings, General. It still covers the time the lid is open.
- Start the goal with
/goaland a clear outcome, constraints and a check that proves it is done. - Arm Clamshell from the menu bar, a Shortcut, or a terminal with
open "clamshell://arm". The request is asynchronous, so check the menu bar state, then close the lid. - Check from your phone if you use Codex on mobile; keep Keep this Mac awake on for that. See Codex from your phone with the lid closed.
- Disarm when it is done. Clamshell does not detect Codex or a finished goal, so disarm from the menu bar, with
open "clamshell://disarm", or the Disarm Clamshell Shortcuts action. The hooks recipe has a Codex variant that disarms when the Codex session ends; its author notes the Codex part is written from OpenAI's docs and untested.
Clamshell keeps your Mac awake with the lid closed. Free for 7 days, then $9.99 once for one Mac. 14-day money-back guarantee.
Download free trialFrequently asked questions
Does Codex Goal mode keep running when I close my MacBook lid?
Not for local work. A goal in the ChatGPT desktop app, the Codex CLI or the IDE extension runs on your Mac, and closing the lid puts the Mac to sleep, so the goal stops making progress until it wakes. Codex Cloud tasks run on OpenAI's servers and keep going.
Does Prevent sleep while running keep Codex awake with the lid closed?
No. OpenAI describes it as keeping the computer awake while a task runs, which holds off idle sleep. Apple treats closing the lid as forced sleep, which apps can delay but not prevent, and OpenAI's own remote access docs say to connect an external display when the lid is closed.
What is the difference between Prevent sleep while running and Keep this Mac awake?
Prevent sleep while running is a General setting that keeps the computer awake while the app is running a task. Keep this Mac awake is a Connections setting that prevents sleep when the computer is plugged in and remote access is enabled, so your phone can reach it. Neither stops lid-close sleep.
Do Codex scheduled tasks run while my Mac is asleep?
Not tasks that work in a local project. OpenAI's docs say to keep the machine powered on and the ChatGPT desktop app running, with the project on disk. Scheduled tasks created on ChatGPT web run in the cloud but cannot work in a folder on your computer.
How do I keep a Codex goal running with the lid closed?
Use Apple's clamshell mode with power, an external display, keyboard and mouse, which is what OpenAI's docs suggest, or keep the Mac awake without a display. Clamshell for Mac does that while armed, with no sudo or admin rights. Arm it before you close the lid and leave Prevent sleep while running on.
Related guides
- Keep Codex running when you close your MacBook lid
- Codex Keep this Mac awake not working with the lid closed
- Use Codex from your phone with the lid closed
- Codex Locked use: a locked Mac, not a closed lid
- Run AI coding agents overnight on a MacBook
- Does Mac sleep burn your Claude Code usage limit?
Sources checked October 17, 2026: OpenAI's docs on long-running work, desktop app settings, the configuration reference, scheduled tasks, remote connections and Codex Cloud; the OpenAI changelog; the setting labels in the installed ChatGPT desktop app 26.1002.52244; GitHub issues #52399, #53686, #49808 and #21703 (user reports); Apple Technical Q&A QA1340 and Apple's external display guide; and the macOS caffeinate and pmset manual pages. Clamshell behavior is described from its published facts. Clamshell is an independent app, not affiliated with or endorsed by OpenAI or Apple. Codex and ChatGPT are trademarks of OpenAI.