Repository navigation
Resume crashed multi-phase workflow runs from the interrupted phase (#182) - #1568
Conversation
…182) Persist the orchestrated workflow view (incl. settled agent outputs) in a new workflowRunByThread store map and reload it at boot. Crash recovery marks running/pending agents failed + __interrupted; Retry on any agent reruns its interrupted siblings and continues later phases, reusing finished phase outputs. Stop/quit flag interrupted agents the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f39127da11
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Siblings cut off by a crash, quit, or stop rerun with the picked slot, | ||
| // so a resumed phase is whole again (#182). Settled phases are reused. |
There was a problem hiding this comment.
Retain usage from completed phases when resuming
When a crash occurs after an earlier phase has settled, its token and cost totals exist only in the original run's in-memory agg* variables; finishSuccess has not yet committed them to thread usage. The resumed run initializes those aggregates to zero and reuses the settled phase here without restoring its usage, so the eventual setUsage and recordUsage calls report only the retried and later phases. Persist and restore the accumulated usage alongside the workflow view, or commit usage per completed phase.
Useful? React with 👍 / 👎.
| lastWorkflowByThread.set(threadId, workflow); | ||
| if (workflow.__orchestrated) store.setWorkflowRun(threadId, workflow); |
There was a problem hiding this comment.
Clear a persisted workflow when a regular run supersedes it
The persisted map is updated only for orchestrated workflows. If a thread completes an orchestrated workflow and subsequently runs a normal Claude/Codex/etc. turn, the in-memory entry is replaced by that provider state but the stored orchestration remains; after restarting, the bootstrap loop restores the obsolete workflow and threads:get displays its old Agents panel and Retry actions as though it were the latest run. Clear or replace workflowRunByThread[threadId] when a non-orchestrated run supersedes it.
Useful? React with 👍 / 👎.
| if (agent && (agent.status === "running" || agent.status === "pending")) { | ||
| agent.status = "failed"; | ||
| agent.__interrupted = true; | ||
| healed = true; |
There was a problem hiding this comment.
Keep future phases pending during crash healing
On a crash in an early phase, this converts every later, never-started agent from pending to retryable failed and marks it interrupted. The Agents panel exposes Retry on each failed slot, so selecting a later-phase slot runs that phase immediately with unavailable outputs for the unfinished earlier phase and can finalize the workflow while permanently skipping required work. Only agents in the phase that was active at interruption should become failed/interrupted; later phases should remain pending for runPhases to continue in order.
Useful? React with 👍 / 👎.
Closes #182.
What
workflowRunByThreadstore map, updated on everypushDetailand reloaded intolastWorkflowByThreadat boot.removeThreadclears it through the existing*ByThreadcascade.recoverInterruptedRunsflips running/pending agents tofailedand sets__interruptedon them. The crash event now says Retry resumes the run and finished phases are kept.__interruptedsiblings in that phase, in parallel. The run then continues into later phases usingcollectPriorOutputsfrom the settled phases, so they aren't re-run.stopWorkflowEntry(user stop / quit) flags agents the same way.Behavior change
After a mid-phase Stop, Retry on one agent now reruns every stopped sibling in that phase, not only the clicked one.
Tests
store.testcascade test now seeds the new map.CODER_*scrubbed:workflow*.test.js+store.test.js200/200.🤖 Generated with Claude Code