Durable state and recovery for coding agents that work for days
Short answer: A coding agent recovers only what was written down outside its session. Keep the work, its acceptance, what was tried, the next action and the receipts of what shipped in a durable record; on restart, rebuild the state from that record and current repository truth, then resume the same job.
What a stopped session loses
A coding agent such as Claude Code or Codex keeps its working knowledge in the session: the conversation, the files it has read, the reasons it chose one fix over another. A session can end, lose its context, run out of quota or be replaced. When it does, that knowledge goes with it. The repository keeps the edits, but not which revision was rejected, which check failed, or what the agent was about to do next.
For a task that fits in one session, that is fine. For work that lasts days, it means every restart begins with rediscovery, and rediscovery is where the same rejected fix gets proposed again. Durable state is the part of the work that does not live in any session.
What to write down, and when
A durable record is useful only if it is written as the work moves, not summarized at the end. Keep these outside the chat, tied to the identity of the work item:
- The work and its acceptance. What is being done and the checks that will decide it is done, written before the first session starts.
- What was tried. Each rejected revision with the check that failed and its cause, so the next session starts from the failure instead of repeating it.
- The next action. One concrete step. A session that starts in the middle of the night should not spend its quota working out where things stand.
- Receipts, not recollections. A PR, a merge, a deployment and a verification are separate facts with separate records. A merged PR does not establish what is live, and a deployment does not prove the problem is gone.
- Waits with a return condition. When work waits on evidence, a decision or a release, record what it is waiting for and a condition that can be checked, such as a due time or a number of new occurrences. “When traffic returns” alone is not a condition.
Orchestro’s Factory lifecycle describes this as an append-only record of the cause, remediation, PR, merge, deployment, verification actor and evidence, outcome and any evidence plan. A confident message in chat is never a replacement for those records.
How a new session recovers the same job
Recovery is a procedure, not a retry. The work lifecycle reference walks through one turn of it; the shape is:
- Reconstruct before acting. Read the recorded history together with the current repository and release truth. Which work is in progress, which waits on evidence, which needs an owner decision.
- Resume active work first. A new turn does not discard an active repair, its branch, its release boundary or an unresolved decision.
- Start from the recorded failure. The new worker reads the cause, the rejected revision and the remaining check. A fresh session is not a fresh backlog.
- Check the new revision again. Evidence belongs to the revision it was collected on. The session that wrote the change does not write the verdict on it.
- Reconstruct again before selecting more. The next choice is made from the updated record, not from what the previous session remembered.
The interactive simulation plays this step with sample data: the session ends, a configured recovery resumes from the durable checkpoint, and the next worker sees the cause, the rejected revision and the remaining check instead of starting over.
Alive is not the same as moving
A process that keeps waking up can still be doing nothing useful. Over several days this is the failure that is easiest to miss: the heartbeat is green while the same job is picked again and again, or a wait never expires. Record the last durable progress as its own fact, separate from liveness and from the wake schedule, and look at the record, not the ping, when you ask whether the run is healthy.
How to test that recovery works
- Stop a session in the middle of a task and start a new one. Does it name the same job?
- Reject a revision on purpose. Does the next session avoid proposing it again?
- Merge without deploying. Does the record still say the change is not live?
- Leave a wait with no return condition. Does anything refuse it, or does it sit open forever?
The limits that remain
- Recovery restores the work, not the host: if the machine is off, nothing resumes.
- Expired logins, missing permissions or missing credentials wait for the owner.
- A resolved blocker and a verified resumption are separate facts. Resuming a job is not proof it will now succeed.
- Elapsed time is never a cure: missing evidence stays inconclusive.
For the requirements of the run itself (an awake host, a schedule, signed-in CLIs and quota), see keeping Claude Code and Codex working for days. For where durable state sits among the other parts, see what a control plane for coding agents is.
How Orchestro handles it
Orchestro is a control plane for autonomous software agents: it keeps agent loops going with durable state, work selection, recovery and independent verification, around the coding agents you already use. The Factory persists identity-linked receipts, decisions and state so the next session can reconstruct what happened from authoritative records, and a worker’s report triggers an independent check instead of closing the work. Execution stays on your own Mac or server, with your own coding-agent subscriptions. Read how Orchestro works for the loop from the owner’s side, or try the 64-second simulation, no signup needed.