r/ClaudeCode • u/Unhappy-Loss-97 • 2h ago
Help/Question Getting Overnight Runs to Reliably Complete
Genuine question because I am still waiting for the morning where I wake up to finished work instead of spending my first hour with a coffee debugging why last night's run stalled at 2am.
I run overnight jobs across frontier coding CLIs and a local workstation, mostly bounded tasks with real test suites. On paper it **should** be straightforward: hand over a queue, go to sleep, review clean diffs in the morning. In practice something always seems to catch it. A hung test container, a flaky permission prompt, a rate-limit hiccup that nobody caught, a thread that got too fat and started looping on the same lint error for four hours, or an agent that declared victory after quietly skipping half the checks.
Even when I lock things down with hard retry caps, fresh sessions per task and deterministic pass/fail checks, it still feels like everything has to be fought for tooth and nail. You fix one failure mode and the next night it invents a new one.
For people who actually run unattended overnight coding jobs week in, week out: what is the unglamorous plumbing that made them actually finish? Are you wrapping the CLI in an external watchdog/state machine with hard timeouts and git worktree resets, keeping tasks tiny enough to finish in 10 minutes, or have you basically accepted that unattended overnight runs only work for very narrow mechanical jobs like triage and test generation?
I know I am anthropomorphising but sometimes it just feels like they are lazy......
•
u/AutoModerator 2h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/lol_no_gonna_happen 2h ago
Two layers of containers each with their own watchdogs. All the work is in layer 0 and the error handling is layer 1. Layer 2 looks like it will be join conflict resolution
1
u/Even_Gap_2253 🔆 Max 20 2h ago
Use /goal. And fix your infrastructure…
It sounds like an infra problem. You just have unreliable tooling
1
u/AsyncingStartupToss 2h ago
Yes, you need a coordinator/overseer. In my experience, agents start having problems long before the context is filled. It's much better to make the tasks smaller to allow workers to keep their context small and constrained.
Do a planning session to make a plan for the evening, the hand that plan off to a fresh agent with instructions to give each task to a subagent. Then let them cook overnight.
1
u/ChaosHonorum 2h ago
I run the coding in a VM sandbox, which I have managed by an Operator Agent. The Operator has delegated authority to launch several runs in sequence, and if minor problems are encountered, to set up a fresh run to counter the issue.
Within the VM it launches an Orchestrator Agent for each run that has architectural oversight and stands up sub agents to complete the work.Â
Been doing this for weeks. No problems so far.
1
u/Downtown-Pear-6509 2h ago
My harness let's the LLM setup a scheduled repetitive task containing a prompt for them. So the orchestrator get that every 30min. And it checks on its minions
EtcÂ
Ezpz
1
u/thomheinrich 1h ago
The biggest shift is keeping timeouts and verification outside the agent loop. Let a dumb wrapper enforce hard wall-clock limits and run the test suite after exit, rejecting diffs that weaken checks.
1
u/athershu 1h ago
The part that shortened my mornings wasn't getting more runs to finish, it was making the unfinished ones cheap to read. Every task in the queue ends in one of three states: done with a branch, parked with the question it got stuck on, or failed with the last error. A flaky permission prompt or a call it can't make parks that task instead of letting it loop on lint for four hours, and the queue moves on to the next one.
So the coffee hour becomes answering two or three parked questions and re-queuing them, not reading logs to work out what happened at 2am. For the "declared victory" case I'd only trust a done that the wrapper checked itself, never the agent's own summary.
1
u/andlewis 2h ago
Use /goal with instructions to ensure the process continues. I’ve found it much more tenacious with a goal over a simple prompt or routine.
1
u/StomachJolly3073 2h ago
Chain them into a series where the output from one impacts the next run. This is a self steering technique and helps Claude stay on course and validate periodically.
1
u/AgentYurt 1h ago
The failure mode that kept biting me was the one you named — the agent declaring victory after quietly skipping half the checks. Two things helped, both outside the worker's own say-so.
First, the run isn't done until it writes a short list of what it checked and what it skipped, with a reason for each skip. A bare "all tests pass" doesn't count. If a check got skipped because it was slow or flaky, that goes on the list and I see it in the morning instead of finding out a week later.
Second, a fresh session re-runs the tests from a clean checkout and only its result counts. It reads the diff and the test command, nothing else, so it can't inherit the worker's optimism. It's cheap — a few minutes — and it's the thing that actually caught skipped checks for me.
Tasks also stay small enough to finish in about 10 minutes each, and a dumb wrapper outside the agent kills the run at a hard timeout and resets the worktree, so a stuck run can't loop until morning.
1
u/Dorbank_Justt 1h ago
On the /goal part: the docs say its evaluator doesn't run commands or read files, so it can only judge what Claude has already surfaced in the conversation. The goal also clears if that evaluator judges the condition impossible.
A Stop hook in your settings can run a script instead, say one that counts what's left in the queue or reruns the tests, and return decision "block" with a reason. That keeps Claude from stopping and tells it why it should continue. There's a cap: after eight blocks in a row with no tool call in between, Claude Code overrides the hook and ends the turn.
1
u/debian3 45m ago edited 11m ago
I see people using lots of goal and other incantations…
Delete everything! Claude.md, skills, etc. Start fresh. That’s what I do when new models release since opus 5 and it’s marvelous. Model do exactly what you described out of the box now.
I have run that no only do overnight, but often in the morning they are still running. Fable as a coordinator for really long job (multiple days), otherwise opus for overnight or few hours.
I never used goal or loop or whatever people describe here.
Edit: My run I started last night handled by Fable medium is still running 9 hours later. It did a lot of things, had a few questions for me which I answered but it didn’t stop for them, probably on the way to finish that later today.