Skip to content

Resume crashed multi-phase workflow runs from the interrupted phase (#182) - #1568

Merged
currentbits merged 2 commits into
mainfrom
coder/workflow-crash-resume-182
Oct 10, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/workflow-crash-resume-182

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #182.

What

  • Persist the run. The orchestrated workflow view, including settled agent outputs, was only kept in runner memory. It now lives in a new workflowRunByThread store map, updated on every pushDetail and reloaded into lastWorkflowByThread at boot. removeThread clears it through the existing *ByThread cascade.
  • Crash recovery. recoverInterruptedRuns flips running/pending agents to failed and sets __interrupted on them. The crash event now says Retry resumes the run and finished phases are kept.
  • Resume through Retry (User-facing Retry for a failed workflow phase agent #825 path). Retrying any agent also reruns its __interrupted siblings in that phase, in parallel. The run then continues into later phases using collectPriorOutputs from 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

  • New: crash mid-phase 2 of 3, reload the store from disk, then assert the heal and the event. Retry one agent and assert the run completes with phase 1's output reused. Fails without the sibling rerun.
  • store.test cascade test now seeds the new map.
  • Locally, with CODER_* scrubbed: workflow*.test.js + store.test.js 200/200.

🤖 Generated with Claude Code

…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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T07:53:56.671592Z f39127d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit f2f9f1d into main Oct 10, 2026
6 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread electron/workflow.js
Comment on lines +853 to +854
// 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread electron/runner.js
Comment on lines 1107 to +1108
lastWorkflowByThread.set(threadId, workflow);
if (workflow.__orchestrated) store.setWorkflowRun(threadId, workflow);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread electron/store.js
Comment on lines +209 to +212
if (agent && (agent.status === "running" || agent.status === "pending")) {
agent.status = "failed";
agent.__interrupted = true;
healed = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-phase workflow runs have no crash-resume; a crash restarts from zero

1 participant