Skip to content

[BUG] A flow resumed from a checkpoint writes checkpoints of a blank flow, so a second resume starts over #8438

Open

Description

Description

A flow fails, is resumed with kickoff(from_checkpoint=...), and fails again later. It cannot be resumed correctly a second time. The checkpoints that the resumed run writes restore a flow with an empty state and no completed methods. The second resume therefore runs the flow again from its first method: methods that already completed run again, so side effects such as a charge repeat, and the kickoff inputs are gone.

Steps to Reproduce

  1. Define reserve -> charge -> ship, where charge and ship each fail once.
  2. Kick it off with checkpoint=CheckpointConfig(location=..., on_events=["method_execution_finished"]) and inputs {"order": 42}. It fails in charge.
  3. Resume with kickoff(from_checkpoint=CheckpointConfig(restore_from=<latest>, location=..., on_events=[...])). charge succeeds and the run fails in ship.
  4. Resume again from the latest checkpoint.

Expected behavior

The second resume skips reserve and charge and runs only ship:

  • runs: ['reserve', 'charge', 'charge', 'ship', 'ship'];
  • final state: {'order': 42, 'reserved': True}.

Screenshots/Code snippets

import glob
import os
import tempfile
import time
from importlib.metadata import version

from crewai import CheckpointConfig
from crewai.flow.flow import Flow, listen, start

runs = []
failures = {"charge": 1, "ship": 1}  # Each fails once, then succeeds.


class OrderFlow(Flow):
    @start()
    def reserve(self):
        runs.append("reserve")
        self.state["reserved"] = True

    @listen(reserve)
    def charge(self):
        runs.append("charge")
        time.sleep(0.1)
        if failures["charge"]:
            failures["charge"] -= 1
            raise RuntimeError("charge failed")

    @listen(charge)
    def ship(self):
        runs.append("ship")
        time.sleep(0.1)
        if failures["ship"]:
            failures["ship"] -= 1
            raise RuntimeError("ship failed")
        return {key: value for key, value in self.state.items() if key != "id"}


location = tempfile.mkdtemp()
settings = {"location": location, "on_events": ["method_execution_finished"]}
restore_from = None
for attempt in range(3):
    try:
        if restore_from is None:
            result = OrderFlow(checkpoint=CheckpointConfig(**settings)).kickoff(inputs={"order": 42})
        else:
            result = OrderFlow().kickoff(from_checkpoint=CheckpointConfig(restore_from=restore_from, **settings))
        break
    except RuntimeError as exc:
        restore_from = max(glob.glob(f"{location}/**/*.json", recursive=True), key=os.path.getmtime)
        print(f"{exc}; resuming from the latest checkpoint")
print(f"crewai {version('crewai')}: runs {runs}, final state {result}")

Operating System

Ubuntu 22.04

Python Version

3.12

crewAI Version

1.15.28

crewAI Tools Version

not installed

Virtual Environment

Venv

Evidence

charge failed; resuming from the latest checkpoint
ship failed; resuming from the latest checkpoint
crewai 1.15.28: runs ['reserve', 'charge', 'charge', 'ship', 'reserve', 'charge', 'ship'], final state {'reserved': True}

main (fa6d712) prints the same. The checkpoint written after charge succeeded on the first resume restores a flow with state {} and no completed methods.

Possible Solution

In Flow.from_checkpoint, make the restored instance the entity of the runtime state, so that later checkpoints serialize the flow that actually runs: replace the deserialized Flow in state.root with instance before set_runtime_state. Since the checkpoint's entities deserialize to plain Flow objects, from_checkpoint should also pick the entity that belongs to the flow being restored rather than the first Flow in the list.

Additional context

Probable root cause. Flow.from_checkpoint (crewai/flow/runtime/__init__.py) works as follows:

  1. It deserializes the checkpoint with RuntimeState.from_checkpoint, whose entities are the Entity union Flow | Crew | Agent (crewai/__init__.py). A flow therefore comes back as a plain Flow, not as OrderFlow.
  2. It calls crewai_event_bus.set_runtime_state(state) with that deserialized entity as the root.
  3. isinstance(entity, cls) fails, so it builds a fresh cls() and copies the checkpoint fields into it.

Activity

  1. added
    bug
    on Oct 23, 2026
  2. github-actions commented on Nov 22, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

  3. yifanxiong272 commented on Nov 22, 2026

    @yifanxiong272
    Author

    Still reproduces on crewAI 1.15.44 (the latest release) and on main (56c26a7, 2026-11-20) with the script in the description: the second resume starts over from reserve, so the runs are ['reserve', 'charge', 'charge', 'ship', 'reserve', 'charge', 'ship'] instead of ['reserve', 'charge', 'charge', 'ship', 'ship'], and reserve and charge run again although the first resume already completed them. Any flow that resumes twice from its automatic checkpoints repeats its side effects this way. With PR #8448 applied (on 1.15.28), the second resume runs only ship, as expected.

    cc Greyson LaLonde (@greysonlalonde) Lucas Gomide (@lucasgomide) Gabe Milani (@gabemilani) Vidit Ostwal (@Vidit-Ostwal) João Moura (@joaomdmoura)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions