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

オープン
#9,840 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@RealAdii がすでに取り組んでいます。

2026年11月28日 から。

  • #9897 @RealAdii による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
61.2k
フォーク
9.2k
平均マージ
1日 14時間
マージ済み PR(30日)
180

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。