From b692c193382b6de0b59ff9f56e9daad81ac9b536 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Thu, 16 Apr 2026 23:09:42 +0800 Subject: [PATCH] fix: use recursive glob for JSON checkpoint discovery (#5491) Branch-aware checkpoint storage writes under subdirectories (e.g. main/, fork/exp1/) but _list_json and _info_json_latest used flat globs that missed them. --- lib/crewai/src/crewai/cli/checkpoint_cli.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/crewai/src/crewai/cli/checkpoint_cli.py b/lib/crewai/src/crewai/cli/checkpoint_cli.py index fa6e003aa..1745c224f 100644 --- a/lib/crewai/src/crewai/cli/checkpoint_cli.py +++ b/lib/crewai/src/crewai/cli/checkpoint_cli.py @@ -173,9 +173,11 @@ def _entity_summary(entities: list[dict[str, Any]]) -> str: def _list_json(location: str) -> list[dict[str, Any]]: - pattern = os.path.join(location, "*.json") + pattern = os.path.join(location, "**", "*.json") results = [] - for path in sorted(glob.glob(pattern), key=os.path.getmtime, reverse=True): + for path in sorted( + glob.glob(pattern, recursive=True), key=os.path.getmtime, reverse=True + ): name = os.path.basename(path) try: with open(path) as f: @@ -192,8 +194,10 @@ def _list_json(location: str) -> list[dict[str, Any]]: def _info_json_latest(location: str) -> dict[str, Any] | None: - pattern = os.path.join(location, "*.json") - files = sorted(glob.glob(pattern), key=os.path.getmtime, reverse=True) + pattern = os.path.join(location, "**", "*.json") + files = sorted( + glob.glob(pattern, recursive=True), key=os.path.getmtime, reverse=True + ) if not files: return None path = files[0]