[BUG] Failed pickle saves erase previously saved training data

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

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

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

2026年11月6日 から。

  • #9201 @vatsalyd による — オープン
  • #9202 @badrbel による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

Start by reading PickleHandler.save() and CrewTrainingHandler in the training handler implementation, then inspect the related tests. Reproduce the failure with an unpicklable object and verify that a failed save preserves existing training data and does not leave an empty destination file. Two open pull requests are already linked to this issue.

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

説明

Description

PickleHandler.save() opens its destination with wb before calling pickle.dump(). If serialization fails, the existing file has already been truncated. CrewTrainingHandler inherits this behavior, so one invalid save can erase training data for previously saved agents.

Steps to Reproduce
  1. Save valid agent training data.
  2. Attempt to save another agent's data containing an unpicklable object.
  3. Catch the serialization error and load the saved training data.
Expected behavior

The save raises its serialization error and preserves the earlier file and training data.

Screenshots/Code snippets
from pathlib import Path
from tempfile import TemporaryDirectory
from threading import Lock

from crewai.utilities.training_handler import CrewTrainingHandler

with TemporaryDirectory() as directory:
    path = Path(directory) / "training.pkl"
    handler = CrewTrainingHandler(str(path))
    handler.save_trained_data("saved-agent", {"score": 10})
    try:
        handler.save_trained_data("new-agent", {"lock": Lock()})
    except TypeError as error:
        print(error)
    print(handler.load())
    print(path.stat().st_size)
Operating System

Windows

Python Version

3.13.13

crewAI Version

1.15.36, main at 7abc196a176a5552c35c6e7a16817aa115f10655.

crewAI Tools Version

Not used.

Virtual Environment

Venv managed by uv with the repository lockfile.

Evidence

Before the failing save the file contains {'saved-agent': {'score': 10}} (42 bytes). Afterward:

cannot pickle '_thread.lock' object
{}
0

The failure also creates an empty file when the destination did not previously exist. Both regression cases reproduce locally without LLM calls.

Possible Solution

Serialize with pickle.dumps() before opening the destination, then write the resulting bytes under the existing lock.

Additional context

Prepared with AI assistance. This account cannot add labels; please apply the required llm-generated label.

主要言語
Python
スター
60.6k
フォーク
9.1k
平均マージ
1日 9時間
マージ済み PR(30日)
218

環境構築

はじめの一歩

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

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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