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

Đang mở
#9,840 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@RealAdii đang làm issue này rồi.

Từ ngày 28/11/2026.

  • #9897 của @RealAdii — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend, databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
61.2k
Fork
9.2k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
180

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của crewAIInc/crewAI

Tất cả issue của crewAIInc/crewAI

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.