Repository navigation
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
- Define
reserve -> charge -> ship, wherechargeandshipeach fail once. - Kick it off with
checkpoint=CheckpointConfig(location=..., on_events=["method_execution_finished"])and inputs{"order": 42}. It fails incharge. - Resume with
kickoff(from_checkpoint=CheckpointConfig(restore_from=<latest>, location=..., on_events=[...])).chargesucceeds and the run fails inship. - 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:
- It deserializes the checkpoint with
RuntimeState.from_checkpoint, whose entities are theEntityunionFlow | Crew | Agent(crewai/__init__.py). A flow therefore comes back as a plainFlow, not asOrderFlow. - It calls
crewai_event_bus.set_runtime_state(state)with that deserialized entity as the root. isinstance(entity, cls)fails, so it builds a freshcls()and copies the checkpoint fields into it.
Activity
github-actions commentedon Nov 22, 2026
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.
yifanxiong272 commentedon Nov 22, 2026
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 fromreserve, so the runs are['reserve', 'charge', 'charge', 'ship', 'reserve', 'charge', 'ship']instead of['reserve', 'charge', 'charge', 'ship', 'ship'], andreserveandchargerun 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 onlyship, as expected.cc Greyson LaLonde (@greysonlalonde) Lucas Gomide (@lucasgomide) Gabe Milani (@gabemilani) Vidit Ostwal (@Vidit-Ostwal) João Moura (@joaomdmoura)