crewAIInc / crewAIInc/crewAI

[BUG] FileCompressorTool includes its output ZIP in the archive

Open
#7,528 1 comment 0 reactions 1 assignee View on GitHub

@Vidit-Ostwal is already working on this.

Since Sep 17, 2026.

Dominant language
Python
Stars
58.8k
Forks
8.5k
Avg merge
1d 15h
Merged PRs (30d)
109

Description

Description

FileCompressorTool includes the output ZIP as an empty member when the archive is created inside the directory being compressed.

This is easy to hit with input_path="." and output_path="bundle.zip". Opening the ZIP creates the output file before os.walk() enumerates the directory, so the new archive is written into itself.

Steps to Reproduce
from pathlib import Path
from tempfile import TemporaryDirectory
from zipfile import ZipFile

from crewai_tools import FileCompressorTool

with TemporaryDirectory(dir=".") as tmp:
    root = Path(tmp).resolve()
    (root / "payload.txt").write_text("hello", encoding="utf-8")

    FileCompressorTool()._run(
        input_path=str(root),
        output_path=str(root / "bundle.zip"),
    )

    with ZipFile(root / "bundle.zip") as archive:
        print(archive.namelist())

Current output:

['bundle.zip', 'payload.txt']
Expected behavior

The generated archive should contain payload.txt, but not bundle.zip. Extracting it should not create an empty archive that was absent from the source directory.

Screenshots/Code snippets

The directory branch opens output_path first and then walks input_path without excluding that file:

with zipfile.ZipFile(output_path, "w", zipfile.ZIP_DEFLATED) as zipf:
    for root, _, files in os.walk(input_path):
        for file in files:
            full_path = os.path.join(root, file)
            zipf.write(full_path, os.path.relpath(full_path, start=input_path))
Operating System

macOS (15.5)

Python Version

3.13

crewAI Version

Current main at 7a01af27912c; the bug is in crewai-tools.

crewAI Tools Version

1.15.22

Virtual Environment

Venv (uv)

Evidence

A direct execution of the current _compress_zip implementation produces a zero-byte bundle.zip member. Existing compressor tests mock _compress_zip, so they do not inspect real archive membership.

I also searched open issues and pull requests for FileCompressorTool, archive self-inclusion, and ZIP output overlap, and did not find an existing fix.

Possible Solution

While walking a directory, skip entries that identify the output archive. A filesystem identity check also covers a symlink alias to the output. Add a real-filesystem regression test for both a new output and overwrite=True.

Additional context

AI-assisted report. I will open a focused fix with regression coverage and apply the required llm-generated label.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.