[BUG] Crew.copy() fails with ValidationError when a task has input_files

Đang mở
#9,829 1 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

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

Từ ngày 26/11/2026.

  • #9830 của @juemimgcd — đang mở
  • #9831 của @Wooohaaa — đang mở
  • #9838 của @kamalbuilds — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Start in crewai/task.py at Task.copy() and inspect how it rebuilds a task with model_dump() and preserves context, agent, and tools. Reproduce the reported failure with a task containing input_files; the issue suggests retaining the original file objects when constructing the copy. Done means crew.copy() preserves task input files without a Pydantic validation error. Three open pull requests are already linked, so check their status before taking this on.

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

Mô tả

Description

Crew.copy() raises a pydantic ValidationError when any task has input_files. Task.copy() rebuilds the task from self.model_dump(), which turns each file's source (FileBytes, a path, FileUrl) into a plain dict, and the file types' source validator rejects a dict: Cannot convert dict to file source.

Anything that copies a crew therefore cannot be used with file inputs, e.g. code that copies a crew per request so concurrent runs don't share state.

Steps to Reproduce
  1. pip install "crewai[file-processing]==1.15.45" (also reproduced on 1.15.45.dev20261126)
  2. Run the snippet below.
Expected behavior

crew.copy() returns a copy whose task keeps its input_files, as it does for a task without them.

Screenshots/Code snippets
from crewai import Agent, Crew, Task
from crewai_files import FileBytes, ImageFile

agent = Agent(role="Analyst", goal="Describe images", backstory="You describe images.", llm="gpt-4o")
task = Task(
    description="Describe the attached image.",
    expected_output="One sentence.",
    agent=agent,
    input_files={"chart": ImageFile(source=FileBytes(data=b"\x89PNG\r\n\x1a\n", filename="chart.png"))},
)
crew = Crew(agents=[agent], tasks=[task])
crew.copy()  # raises pydantic ValidationError

The same happens with a path source (ImageFile(source=Path("chart.png"))) and with FileUrl(url=...).

Operating System

macOS (also expected on Linux; the failure is in pydantic validation, not platform-specific)

Python Version

3.12

crewAI Version

1.15.45 (and 1.15.45.dev20261126); crewai-files same version

crewAI Tools Version

not installed

Virtual Environment

Venv

Evidence
pydantic_core._pydantic_core.ValidationError: 6 validation errors for Task
input_files.chart.AudioFile.source
  Value error, Cannot convert dict to file source [type=value_error, input_value={'data': b'\x89PNG\r\n\x1...'filename': 'chart.png'}, input_type=dict]
input_files.chart.File.source
  Value error, Cannot convert dict to file source [...]
input_files.chart.ImageFile.source
  Value error, Cannot convert dict to file source [...]
input_files.chart.PDFFile.source
  Value error, Cannot convert dict to file source [...]
input_files.chart.TextFile.source
  Value error, Cannot convert dict to file source [...]
input_files.chart.VideoFile.source
  Value error, Cannot convert dict to file source [...]

With a path source the input value is {'path': PosixPath('.../chart.png')}, same error.

Possible Solution

In Task.copy() (crewai/task.py), exclude input_files from the model_dump and pass the original file objects (or a shallow copy of the dict) to the new task, as is already done for context, agent and tools. Alternatively, let the file source validator accept the dict form it dumps to.

Additional context

Related: #8952 (copying a crew loses task/agent input templates).

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.