r/ClaudeCode • u/michaelTM_ai • 6h ago
Tips & Workflows Read all 60 replies to the '10 Claude Code agents 24/7' thread. The setups that worked had zero long-running agents
Yesterday someone here asked how to run 10 Claude Code agents 24/7: role chats, 150k+ context per call, state lost on compaction, background jobs finishing with nobody noticing, crons dying with the chat.
I read all ~60 replies. The surprising part: the setups that worked had fewer long-running agents. Most of the time the answer was none at all.
- every piece of work is its own short run: spec, plan, code, review, each a fresh context. Nothing reaches 150k, and compaction has nothing to lose
- the schedule lives on the machine, something that stays up with no chat open. It starts a fresh run only when a work item shows up
- completions go to a small queue, one file or row per item, instead of a chat that's supposed to notice
- state lives in a status file per task, written by a pre-compact hook, so the next run never depends on the last one remembering
Nearly every pain on his list traced back to the same thing: a chat doing a job that belongs to a scheduler or a queue.
Credit to u/tcanuck42, u/KingYF1 and u/London-Boat in that thread. Original: https://www.reddit.com/r/ClaudeCode/comments/1y7qkfm/
(i wrote up all 6 patterns from the thread in r/AI_Loops)
•
u/AutoModerator 6h 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/SnooPuppers9163 4h ago
the bit i still haven't cracked with short runs + a queue is follow-ups. someone adds "oh and also do X" while a run is halfway through, and right now that's either a new item racing the first one or a restart that throws the work away. what if the follow-up got folded into the running item, so the current run picks it up at its next checkpoint instead of being cancelled? anyone doing that, or is it always a fresh run?
12
u/mcmoonrays 6h ago
The short-run + queue setup holds up way better than babysitting long chats, with two catches that show up after a few days. First, per-task status files turn into append-only logs and recreate the same context bloat unless you overwrite them in place instead of appending. Second, they need a short rejected line recording what already failed and why, otherwise fresh sessions keep re-trying the same dead end. Add one git worktree per worker so parallel runs don't step on each other's files, and it actually stays low-maintenance.
5
u/hieuphung97 6h ago
Handoff contracts make or break this. The coordinator should check exit codes and git diffs, never natural language status summaries. Once your orchestrator relies on parsing agent prose to decide the next step, the pipeline degrades right back into babysitting.
4
u/Independent-Sir3234 4h ago
Short stateless runs also make failures much easier to debug. Once a long-lived chat drifts after several hours, there is no clean way to replay one broken step without dragging the whole transcript along.
A plain status file on disk turns each agent call into a normal worker job. When a step times out or writes a bad patch, you inspect the diff, reset that single item, and rerun it cleanly.
3
u/Firm-Jellyfish-1227 6h ago
Fair, and the pre-compact hook writing the status file is the part everyone skips, then they blame compaction for losing work. Put a lock on the queue file too, two crons grabbing the same item is how you end up with duplicate branches.
2
u/Ok-Distance-6388 5h ago edited 4h ago
I built one of these for my own work: a scheduler on the PC fires 12 to 20 short runs a day, each a fresh session, nothing long-running. three things that bit me after the first week:
the state file grows, like mcmoonrays said. mine now has one capped section, a note to the next run of at most 1500 characters, and the scheduler pastes only that into the next prompt. the rest of the file is reference. the note is the only part that reliably changes what the next run does.
the note can also be wrong about where to look. one run checked replies by opening only the threads its note named, and a reply sat 4 hours. now every run starts from the inbox, the real source of truth, and the note only says what to do after that.
every run has to call a done command before it ends. a run that exits without it, or goes over its time, gets marked failed by the scheduler, so a silent death shows up in the log instead of never.
the one I still don't catch well: a run that exits clean and calls done but did nothing useful. how do you check for that?
2
u/Excellent-Issue-5956 4h ago
Same setup here, cron on a PC that stays on and every job is a fresh claude -p that ends when it's done. The thing that bit me with short runs: if a run starts something that has to keep going after the session ends, it gets killed along with the session. I had a job hand off to a script that sleeps a few minutes between each step, the session finished while it was sleeping, and the last step never happened.
Now that script detaches itself with setsid and writes a pid file, and the cron wrapper waits on that pid before it releases the lock. The lock is flock on both cron lines, so two jobs that work on the same stuff never run at the same time.
2
u/Imposter-Eng-24 5h ago
I think the next step beyond this is making sure each fresh session actually benefits from what previous sessions learned. Persisting task state solves continuity, but it doesn't necessarily prevent agents from repeating the same mistakes across runs.
I've been building an open-source project called Rashomon that explores this through graph-based context, evidence-based verification, and steering coding agents toward project-specific conventions.
The goal is similar: make the agent replaceable while keeping the engineering knowledge and verification outside the session. Curious how people here are handling repeated mistakes and verifying that completed tasks are actually done, rather than just trusting the agent's completion status.
https://github.com/altrace-dev-role/rashomon
1
u/Outrageous_Band9708 3h ago
https://github.com/Druthulu/ProjectArchitect
My solution (terminal only) automates this for you. each task gets its own fresh context and runs like like maybe 200k depending on the work. auto passes off at 300k.
this method saves a ton of your weekly usage since the repeat turns on high context is the main killer of usage.
1
u/SpeakCodeToMe 5h ago
Exactly. Once they go off the rails, they just continue further off the rails. Constant human-in-the-loop is required.
0
u/GreenBird-ee 6h ago
The rule is: if there's hype about Claude (which has been shelved due to a lack of infrastructure since the beginning of the year), it's a lie sponsored by Google. No need to think about the rest. Cheers.