Does Codex Goal mode keep running with the lid closed?

By Matyas Rathonyi. Updated October 17, 2026. Guides

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.

Goal modeHours or days, on your Mac
Prevent sleepWhile a task runs, lid open
Lid closedThe Mac sleeps, the goal stops
$9.99 onceAfter a 7-day free trial

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 trial

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99

A Codex goal keeps adding turns and its progress bar keeps filling while the MacBook lid closes. /goal
A goal is many turns on your Mac.Goal mode keeps starting new turns toward the outcome you set. Each one runs locally, so the Mac has to stay awake after the lid goes down.

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

SurfaceRuns onNeedsLid closed, no display
Goal in the ChatGPT desktop appYour MacMac awake and online, app runningStops until wake
Goal in the Codex CLI or IDE extensionYour MacMac awake and online, the session or workspace openStops until wake
Scheduled task in a local projectYour Mac"Keep the machine powered on and the ChatGPT desktop app running", project on diskDoes not run while asleep
Scheduled task inside a chatYour Mac, for a local chatSame as above; it returns to the chat on a scheduleDoes not run while asleep
Codex Cloud, ChatGPT web scheduled tasksOpenAI's serversNothing from your Mac, but no direct access to its foldersKeeps 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."

Prevent sleep while running blocks the idle timer, so the Mac stays awake. Closing the lid is forced sleep, which the setting does not stop. Idle timer runs out prevent sleep awake Lid closes prevent sleep z asleep
Two kinds of sleep. The setting holds off the idle timer while a task runs. Closing the lid is forced sleep, so the same setting no longer helps and the goal pauses.

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.

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 free

sudo 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

  1. Plug in and put the Mac on a hard, ventilated surface. Disconnect external displays, since Clamshell pauses instead of arming while one is connected.
  2. Leave Prevent sleep while running on in Settings, General. It still covers the time the lid is open.
  3. Start the goal with /goal and a clear outcome, constraints and a check that proves it is done.
  4. 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.
  5. 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.
  6. 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 trial

Frequently 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

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.