Resuming a Flow from an automatic checkpoint re-runs already completed methods when on_events=["*"]

Abierto
#9,839 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Sun-Wukhan ya está trabajando en esto.

Desde el 27/11/2026.

  • #9844 de @Sun-Wukhan — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend, testing

Línea de trabajo

The payload does not name implementation or test files. Start by tracing how Flow.from_checkpoint(...) restores checkpoint_completed_methods and how on_events=["*"] selects checkpoint events; compare with the working method_execution_finished case. Reproduce the three step flow with both JsonProvider and SqliteProvider, then verify that resuming runs only C. Linked PR #9844 is already open, so coordinate with that work before taking this on.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Thank you to the maintainers, and to everyone who reported and worked on the related checkpoint issues (#9290, #9022, #9023, #8438). This was found with ATLAS, an AI finder and verifier.

What happens
A flow a -> b -> c crashes in c. Resuming from the most recently written automatic checkpoint should run only c, since the docs say completed tasks are skipped on restore. With on_events=["method_execution_finished"] that is what happens. With on_events=["*"] (documented in CheckpointConfig) the resume runs A, B and C again, so side effects of completed methods are repeated.

Reproduction (crewAI main at 77237ae, Python 3.13, JsonProvider)

# crewAI main 77237ae. Resume after a crash re-runs completed flow methods when on_events=["*"].
import glob, os, tempfile
from crewai.flow.flow import Flow, start, listen
from crewai.state.checkpoint_config import CheckpointConfig

def run(events):
    ran, crash = [], {"on": True}
    class F(Flow):
        @start()
        def a(self): ran.append("A"); return "a"
        @listen(a)
        def b(self, x): ran.append("B"); return "b"
        @listen(b)
        def c(self, x):
            ran.append("C")
            if crash["on"]: raise RuntimeError("crash after B")
            return "c"
    d = tempfile.mkdtemp()
    try: F(checkpoint=CheckpointConfig(location=d, on_events=events)).kickoff()
    except Exception: pass
    last = max(glob.glob(d + "/**/*.json", recursive=True), key=os.path.getmtime)
    ran.clear(); crash["on"] = False
    F.from_checkpoint(CheckpointConfig(location=d, restore_from=last)).kickoff()
    return "".join(ran)

for ev in (["method_execution_finished"], ["*"]):
    print(ev, "-> after resume ran:", run(ev), "(expected: C)")

Output:

['method_execution_finished'] -> after resume ran: C (expected: C)
['*'] -> after resume ran: ABC (expected: C)

Measured

on_events main main + PR #9023 applied locally (PR is still open)
method_execution_finished C (5/5) C (5/5)
method_execution_started 1 of 5 runs: B, C C (5/5)
flow_failed C (5/5) C (5/5)
"*" A, B, C (5/5) A, B, C (5/5)

(5 runs per setting, a fresh process per run; the single-process script above gave ABC in both runs I made.) PR #9023 fixes the out-of-order case in my runs, but not the "*" case.

Checked to rule out a file-selection artifact
Same flow, 3 ways of choosing the checkpoint to restore (last written, the one with the most completed methods, one from the middle), JsonProvider and SqliteProvider:

  • ["method_execution_finished"]: C in all 6 cases.
  • ["*"]: ABC in all 6 cases.

So it does not depend on which file is picked or on the storage backend.

Workaround
on_events=["method_execution_finished"] resumes correctly in my runs.

Observation, cause not located
The checkpoint file written last holds checkpoint_completed_methods: ["a", "b"], but after Flow.from_checkpoint(...) the restored flow reports checkpoint_completed_methods = None, so nothing is skipped.

Limits
Simple three-step flow, no human feedback, no routers, no crews. "Latest" means the most recently written file. I did not check whether this is the same root cause as #8438 (a resumed flow writing checkpoints of a blank flow); the blank restored state looks related.

Happy to adjust the reproduction or test a fix.

Lenguaje dominante
Python
Estrellas
61.2k
Forks
9.2k
Merge medio
1 d 14 h
PR fusionados (30 d)
180

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de crewAIInc/crewAI

Todos los issues de crewAIInc/crewAI

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.