[FEATURE] Suspend and auto-resume at usage-limit reset instead of ending the session
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When a session reaches the usage limit, the session ends. The reset time is displayed, but the work itself is dropped, so I have to come back later, notice the limit has refreshed, and restart everything by hand.
This is most painful with long-running orchestration. Running a dynamic workflow, I had roughly 70 of 90 tasks complete when the session was interrupted. On resuming, progress showed 46/90 — about 24 already-finished tasks were discarded and re-run.
So the interruption costs twice: the session stops, and resuming does not restore everything that was already done.
The docs describe resume as replaying "the longest unchanged prefix of agent() calls." In a parallel() or pipeline() fan-out, agents complete out of order, so a contiguous-prefix cache would discard every completed call that sits after the first still-running one. The 70 → 46 drop is consistent with that.
The frustrating part is that long unattended jobs are exactly the workload where a limit window is most likely to be crossed, and exactly where losing the run hurts most.
Proposed Solution
Instead of ending the session at the limit, put it into a suspended state that resumes itself:
- Show
Session resuming in 2:00:00with a live countdown rather than terminating. - Hold the workflow checkpoint / runId while suspended.
- At
0:00, auto-resume viaresumeFromRunId, so nothing already completed is repeated and no manual restart is needed. - Apply the same to
/loopdynamic mode: schedule the next wake at the reset time instead of ending the loop.
For this to be worth much, resume needs to be lossless. Suggested fix for the 70 → 46 behaviour: key the resume cache per agent() call (on prompt + opts) rather than by contiguous prefix, so out-of-order parallel completions survive.
Most of the machinery already exists and simply isn't wired to the limit event — Workflow already supports resumeFromRunId, and /loop dynamic mode already uses ScheduleWakeup to defer work.
Safety valve: this should be opt-in and bounded (for example "resume once", or a maximum number of windows), so an unattended session cannot spend a fresh limit window on work I would have cancelled had I been watching.
Alternative Solutions
- Manual resume, which is what exists today: note the runId, wait, relaunch. It works but requires me to be present at the moment the limit resets, which defeats the point of a long unattended run.
- Fixing only the lossy resume, without auto-resume. This would help, but I would still have to babysit the clock.
- Pre-emptively splitting work into smaller batches sized to fit inside one limit window. This requires guessing the budget in advance and fragments workflows that are naturally one unit.
Priority
High - Significant impact on productivity
Feature Category
Interactive mode (TUI)
Use Case Example
I kick off a dynamic workflow of ~90 tasks (a codebase-wide audit) and leave the machine running while I am away.
Today: it hits the limit partway through, the session ends, and when I come back I restart it and lose a chunk of completed work in the process.
With this feature: the session shows a countdown, resumes on its own when the window refreshes, and by the time I return the run has finished, with every completed task preserved.
Additional Context
The countdown matters as much as the auto-resume. Seeing resuming in 1:47:22 makes it obvious the work is parked rather than lost, which is not clear today when the session simply ends.
3 Comments
The 70 -> 46 regression on resume is the frustrating part of this. You finished work, the checkpoint didn't preserve it correctly because of how the prefix cache works on parallel fan-out, and now you re-pay that cost plus the delay of the limit reset.
Your proposed per-
agent()call keying for the resume cache makes sense for exactly this reason. The contiguous-prefix assumption is designed for sequential pipeline work; parallel fan-out breaks that assumption every time two agents complete out of order.A near-term workaround: if you can restructure the workflow to write each completed agent's output to a file before the session ends (e.g., the agent appends to
progress/<task_id>.jsonas its last step), you can build a lightweight resume wrapper that checks which task IDs already have output files before spawning agents. It's manual bookkeeping but it means the limit interruption only loses agents that were mid-run, not ones that already finished. The tradeoff is you're adding file I/O overhead to every agent completion.The auto-resume with countdown you're describing would make long unattended runs actually tractable. Right now the mental model for anything crossing a limit window is "set a reminder, babysit the clock, restart manually" - which defeats the whole point of kicking off a 90-task audit and walking away.
The lossless-resume half of this (the 70 → 46 drop from contiguous-prefix caching) really does have to be fixed inside Claude Code — per-agent() keying is the right call, and nothing external can rebuild that checkpoint state once it's discarded.
But the other half you name — "requires me to be present at the moment the limit resets" — can be handled outside the session today. I maintain a small open-source tool for exactly that pain (claude-ac). In CLI mode it wraps
claude, watches the output for the usage-limit message, waits for the reset, and relaunches with--continueon its own, so an unattended run picks itself back up without you sitting by the clock. For the desktop app there's an opt-in watcher that clicks the real resume button via UI Automation once the quota returns. It only ever clicks resume — it never buys or upgrades anything — and it's MIT with no telemetry.To be clear about the limits: it won't restore work the prefix cache already dropped (that's the internal fix you're asking for), and
--continueresumes the last session rather than a specific runId. What it does remove is the "set a reminder, babysit the clock, restart by hand" step on the auto-resume side.https://github.com/blackstardigitalstudio/claude-auto-continue
Has this got any attention?