Shared checkpoint retention can remove another run%27s only resume point

Abierto
#9,840 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@RealAdii ya está trabajando en esto.

Desde el 28/11/2026.

  • #9897 de @RealAdii — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start by reading JsonProvider.prune() and SqliteProvider.prune(), then inspect the checkpoint pruning tests; the report says it will attach test_checkpoint_prune_shared_location.py with offline reproductions. Compare retention behavior for independent runs sharing a location and branch, including a writer configured with max_checkpoints=None. Done means the intended retention scope is clear and tests establish whether pruning can remove another run’s last resume point.

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

Descripción

Thank you to everyone working on checkpoints, and to the authors of #5381 (forking with lineage tracking). This is a question about intended behaviour; it sits next to #8268, #9022 / #9023, #9674 and #9698, but I did not find it described there. We found this with ATLAS, an AI finder and verifier. This report was prepared with AI assistance (please apply llm-generated).

What happens

JsonProvider.prune() and SqliteProvider.prune() select by location and branch only (<location>/<branch>/*.json by mtime, or WHERE branch = ?). A fresh run starts on main, so independent runs that share one location share one retention budget.

So a later run with max_checkpoints set can delete the only checkpoint of an earlier failed run, even if that earlier run used max_checkpoints=None. None means that writer does not prune; it does not protect its checkpoints from another writer at the same location and branch. CheckpointPrunedEvent reports counts, not which checkpoints were removed.

Reproduction (offline, no model, crewai 1.15.45, main 77237ae)

Run A "pays" (a local list only) and then fails in ship. Runs B and C are unrelated runs in the same folder. A keeps its checkpoint reference; the script then tries to resume from it, and if the file is gone it starts A fresh.

import glob, sys, tempfile, time, json, logging
from crewai import CheckpointConfig
from crewai.flow.flow import Flow, listen, start

# usage: python repro_resume.py <limit of A> <limit of B and C>   ("none" or a number)
lim = lambda s: None if s == "none" else int(s)
LA, LBC = lim(sys.argv[1]), lim(sys.argv[2])
effects = []          # simulated payments (local list only)
warn = []
class H(logging.Handler):
    def emit(self, r): warn.append(r.getMessage())
logging.getLogger().addHandler(H()); logging.getLogger().setLevel(logging.WARNING)

class OrderFlow(Flow):
    @start()
    def charge(self):
        effects.append(self.state["id"])
    @listen(charge)
    def ship(self):
        if self.state.get("fail"):
            raise RuntimeError("ship failed")

loc = tempfile.mkdtemp()
cfg = lambda m, **k: CheckpointConfig(location=loc, on_events=["method_execution_finished"], max_checkpoints=m, **k)
def stored():
    prev = -1
    for _ in range(30):            # wait until write and prune are stable
        time.sleep(0.5)
        now = sorted(glob.glob(loc + "/**/*.json", recursive=True))
        if len(now) == prev: return now
        prev = len(now)
    return now

try: OrderFlow(checkpoint=cfg(LA)).kickoff(inputs={"id": "A", "fail": True})
except RuntimeError: pass
a_files = stored()
a_ref = a_files[-1]
for n in ("B", "C"):
    OrderFlow(checkpoint=cfg(LBC)).kickoff(inputs={"id": n}); stored()
left = stored()
print(f"A limit={LA}, B/C limit={LBC}: A's checkpoint files before={len(a_files)}, after={sum(f in left for f in a_files)}; total files={len(left)}")
print("warnings seen:", warn)
before = len(effects)
if a_ref in left:
    try: OrderFlow.from_checkpoint(cfg(None, restore_from=a_ref)).kickoff()
    except RuntimeError: pass
    print("resume from A's reference: possible; new payments for A =", effects[before:].count("A"))
else:
    print("resume from A's reference: file is gone")
    OrderFlow(checkpoint=cfg(None)).kickoff(inputs={"id": "A"})
    print("fresh start of A: payments for A in total =", effects.count("A"))

Measured output (the simulated payment is a local list, nothing real):

$ python repro_resume.py none none
A limit=None, B/C limit=None: A's checkpoint files before=1, after=1; total files=5
resume from A's reference: possible; new payments for A = 0
$ python repro_resume.py none 3
A limit=None, B/C limit=3: A's checkpoint files before=1, after=0; total files=3
resume from A's reference: file is gone
fresh start of A: payments for A in total = 2
$ python repro_resume.py 3 3
A limit=3, B/C limit=3: A's checkpoint files before=1, after=0; total files=3
resume from A's reference: file is gone
fresh start of A: payments for A in total = 2

A fresh start is a separate operation that the application chooses; no automatic restart or real double payment is claimed. The warning list contains only the error of the failing step, so I saw no warning about the removed checkpoint.

Fixture

I will attach test_checkpoint_prune_shared_location.py as a comment (22 tests, offline). On main: 11 pass (controls without a limit, one run alone, one location per run, and the mixed case with one location per run) and 11 fail. The failures cover the same limit for all runs (Flow with both providers, Crew with JsonProvider) and the mixed case (A without limit, B and C with limit 3; Flow and Crew, each with both providers). The resume tests check that A's last checkpoint is still there.

Workaround

Give every run its own location (own folder, or own SQLite file). The fixture confirms this keeps A's checkpoint for both providers.

Limits

  • Affects only people who share a location between runs and set max_checkpoints in at least one of them. The guide recommends the limit for disk use, and the default ./.checkpoints is shared by a project.
  • Scripted flow and scripted model, not a real provider. The script above uses JsonProvider and Flow; the fixture covers SqliteProvider and Crew. The resume itself (with no new payment) is shown only in the script, with JsonProvider. I did not test fork() or the CLI prune.

Question

As far as I understand, #5381 made pruning branch-scoped so that fork branches do not prune each other. Is it also intended that independent root runs on main share one retention budget? If yes, could the config description and the guide say so, including that max_checkpoints=None does not protect a writer's checkpoints from other writers at the same location and branch? If not, what should the unit of retention be for independent runs (per run, or one budget per store)?

Thank you for taking a look.

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.