# Running an agent overnight without breaking things

Source: https://ryansam.com/agent-auto-continue/overnight/
Published: 2026-10-02 Updated: 2026-10-02

It's 23:30 and Claude Code is halfway through a migration.
You want progress by morning, not a wrecked branch or a turn stuck on a permission prompt since 01:00.

The safe overnight run is a bounded one: a turn limit, a permission mode you'd leave alone and a throwaway branch.
Then the worst case is a wasted night, not a mess.

Claude Code's [own wait](https://code.claude.com/docs/en/interactive-mode#wait-for-a-usage-limit-to-reset) only resumes once after a usage limit, in an open session.
[Agent Auto-Continue](https://ryansam.com/agent-auto-continue/) handles the turn limit and the sending; the rest is on you.

## Before you go to bed

1. **Work on a branch** (`git switch -c overnight`), so the worst case is deleting it.
2. **Put the plan in the repo.**
   A `PLAN.md` beats anything you'll type at 23:30.
3. **Ask Claude Code for a commit per step.**
   [What to say](https://ryansam.com/agent-auto-continue/what-to-say/) has a message for that.
   Codex keeps `.git` [read-only](https://learn.chatgpt.com/docs/agent-approvals-security#protected-paths-in-writable-roots) by default, so there a commit needs approval.
4. **Pick Up to a few turns, not Until done.**
   A stop phrase like `TASK COMPLETE` helps; the limit is the real guard.
5. **Keep the Mac awake and plugged in.**
   [Keep-awake](https://ryansam.com/agent-auto-continue/keep-mac-awake/) is off by default, and a closed lid sleeps anyway outside closed-display mode.
6. **Quit `claude` or `codex` in the terminal.**
   An open Claude Code session counts as busy; the chain waits.
   Codex waits too while another process holds the thread's writer lock.

## Pick a permission mode you'd leave alone

The app runs Claude Code headless in the session's last [permission mode](https://code.claude.com/docs/en/permission-modes#available-modes), and headless [denies anything that would prompt](https://code.claude.com/docs/en/headless#turn-off-permission-prompts-in-unattended-runs).
So the mode decides what gets done:

- **Manual** only runs reads without asking, so overnight it mostly reads.
- **Auto** runs everything with background safety checks, and Anthropic lists it for long tasks.
  Blocked actions are skipped and Claude keeps working.
- **bypassPermissions** is for isolated containers and VMs only, in Anthropic's words.
  Not your laptop at 03:00.

For progress by morning, Auto on a throwaway branch is the reasonable pick.

Codex stops instead.
Its default [Auto preset](https://learn.chatgpt.com/docs/agent-approvals-security#common-sandbox-and-approval-combinations) asks before editing outside the workspace or using the network.
Nobody's there to approve, so the turn stops and the chain pauses.
One `npm install` at 02:00 can end your night.

## What can go wrong, and what stops it

| Risk | What stops it |
| --- | --- |
| It carries on after the task's done | The turn limit. Three sub-minute turns in a row pause it |
| It keeps hitting the usage limit | Those turns don't count, and three in a row pause it |
| A turn never ends | After 24 hours the chain pauses and lets the Mac sleep |
| The same message twice | Stable message IDs; an unclear send is marked unconfirmed, never retried |
| You typed in the thread at 02:00 | A re-check before each send pauses it; a gone or archived thread stops it |
| The agent asks you something | The chain pauses, turn unsent |
| A restart or sleep | Jobs survive; missed schedules catch up after wake |
| You want it stopped | **Stop**, or **Stop all** in the queue; a running turn finishes, nothing more is sent |

## The morning review

What's still going is in the queue; **Recent** and **All history** show how the rest ended.
Click a run for each turn's outcome.

![The Agent Auto-Continue queue with three items: Migrate billing webhooks to v2 running turn 2 of 6, Add rate limit headers in 7 hours for up to 6 turns, and Dark mode for the settings page in 8 hours once. Under Recent, Fix the flaky auth tests finished after 3 turns and Flaky checkout tests is paused, with a link to All history.](https://ryansam.com/_astro/queue-light.C5REkav5.png)

*The first thing to look at in the morning: what is still running, and how the rest ended.*

A paused run says why, and **Resume** never resends a delivered turn.
If it's unconfirmed, **Check delivery** first; it only reads the conversation.

The app knows what it sent, not whether the work's any good.
That's git and you:

```sh
git log --oneline main..overnight
git diff --stat main
```

Read the diff, run the tests, then decide whether to [stay in this thread](https://ryansam.com/agent-auto-continue/continue-or-new-thread/).
Unattended isn't the same as unreviewed.

## Honest limits

- **It can't tell when the task's done.**
  No harness reports it, so Until done ends at the stop phrase, a pause or you.
- **The Mac has to be awake and the app running.**
  Quitting interrupts Claude Code and private Codex turns.
- **Claude Desktop and the ChatGPT app need the Mac unlocked**, so a locked screen waits for morning.
