crewai - ✅(Solved) Fix [BUG] crewai flow plot saves HTML to a hidden temp directory instead of the current working directory (despite CLI message) [3 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4991Fetched 2026-04-08 01:11:58
View on GitHub
Comments
2
Participants
3
Timeline
16
Reactions
0
Timeline (top)
referenced ×7cross-referenced ×5commented ×2assigned ×1

When running the crewai flow plot command (or calling .plot() programmatically without catching the return path), the framework generates the HTML visualization inside a hidden system temporary directory (e.g., /var/folders/.../T/crewai_flow_.../), instead of the user's current working directory.

Furthermore, the CLI outputs a misleading success message: Flow visualization saved to guide_creator_flow.html, leading the user to believe the file was saved locally in their project folder when it was not.

Root Cause

  1. Fix the CLI Output: If the file must remain in the temporary directory because of dependencies/assets, then update the CLI print statement in crewai.cli.flow to stop lying to the user. Instead of printing "Flow visualization saved to [filename]", it should print the actual absolute path returned by the method: "Flow visualization saved to /var/folders/.../T/crewai_flow/.../filename.html".

Fix Action

Fixed

PR fix notes

PR #4992: fix: save flow plot HTML to current working directory instead of temp dir

Description (problem / solution / changelog)

Summary

Fixes #4991 — flow.plot() and crewai flow plot were saving generated HTML/CSS/JS files to a hidden system temp directory (via tempfile.mkdtemp), making output inaccessible from the user's project folder.

The fix replaces the temp directory with the current working directory as the default output location. An optional output_dir parameter is added to both render_interactive() and Flow.plot() for explicit control.

Files changed:

  • interactive.py: Replaced tempfile.mkdtemp() with Path.cwd() (or user-provided output_dir), removed tempfile import
  • flow.py: Added output_dir parameter passthrough on Flow.plot()
  • test_flow_visualization.py: Added 5 regression tests, updated 1 existing test to use output_dir for isolation

Review & Testing Checklist for Human

  • Silent file overwrite: Writing to CWD means existing files named crewai_flow.html / *_style.css / *_script.js will be overwritten without warning. Verify this is acceptable behavior, or consider whether a warning/prompt should be added.
  • Verify CLI end-to-end: Run crewai flow plot in a real project and confirm the HTML file appears in the current directory and opens correctly in a browser.
  • Confirm os.chdir() in tests is safe: Two new tests change the process CWD inside try/finally. Verify this doesn't cause flakiness with parallel test execution (pytest-xdist).

Notes

  • The CLI print message ("Flow visualization saved to {filename}") is now correct without changes, since files actually land in CWD.
  • dest_dir.mkdir(parents=True, exist_ok=True) is a no-op when output_dir is None (CWD already exists), but handles the explicit output_dir case cleanly.

Link to Devin session: https://app.devin.ai/sessions/57b0c89dae2649feb5c18b8fa710a505

Changed files

  • lib/crewai/src/crewai/flow/flow.py (modified, +11/-2)
  • lib/crewai/src/crewai/flow/visualization/renderers/interactive.py (modified, +13/-9)
  • lib/crewai/tests/test_flow_visualization.py (modified, +94/-4)

PR #4996: fix: save flow plot HTML to CWD instead of temp directory

Description (problem / solution / changelog)

Problem

When running crewai flow plot, the visualization HTML is saved to a hidden system temp directory (e.g. /var/folders/.../T/crewai_flow_.../), but users can't find it because nothing prints the actual path. This breaks CI/CD pipelines trying to capture the HTML as an artifact.

Fixes #4991

Changes

  1. render_interactive() — Save HTML/CSS/JS to Path.cwd() instead of tempfile.mkdtemp(). Removed unused tempfile import.
  2. Template plot() — Now captures the return path from poem_flow.plot() and prints it, so users see the actual absolute path.

Before

$ crewai flow plot
Plotting the Flow
(no output about where file was saved, file in temp dir)

After

$ crewai flow plot
Plotting the Flow
Flow visualization saved to /path/to/project/crewai_flow.html

The HTML file (and its CSS/JS) are now saved in the current working directory where the user expects them.

<!-- CURSOR_SUMMARY -->

[!NOTE] Medium Risk Changes where crewai flow plot writes HTML/CSS/JS artifacts (from a temp dir to the current working directory), which may affect file overwrites and CI artifact collection but is otherwise localized to visualization output.

Overview Flow visualization output is now written to the current working directory instead of a temporary folder, so generated *.html plus its companion CSS/JS files are easy to locate and capture as CI artifacts.

The flow template’s plot() helper now captures the return value from poem_flow.plot() and prints the saved path to stdout.

<sup>Written by Cursor Bugbot for commit 0e0eadd6653ce01202ef6414c69be570f4ba8962. This will update automatically on new commits. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/cli/templates/flow/main.py (modified, +2/-1)
  • lib/crewai/src/crewai/flow/visualization/renderers/interactive.py (modified, +4/-5)

PR #5003: fix(flow): save plot output to CWD instead of hidden temp directory

Description (problem / solution / changelog)

Summary

Fixes #4991

render_interactive() was always writing the HTML, CSS, and JS files into a directory created by tempfile.mkdtemp(prefix="crewai_flow_"). This caused crewai flow plot to print a misleading success message like:

Flow visualization saved to guide_creator_flow.html

…while the actual file landed in a hidden /tmp/crewai_flow_…/ path that the user cannot easily find.

Changes

  • Replace tempfile.mkdtemp() with a CWD-based output directory
  • If filename already contains a directory component, that directory is used
  • Otherwise Path.cwd() is used, so files appear in the user's working directory
  • Remove now-unused import tempfile
  • Update docstring to document the new resolution logic

Testing

Existing tests continue to pass. The fix is consistent with user expectation described in the issue: running crewai flow plot now produces guide_creator_flow.html (and its sibling CSS/JS files) in the current working directory.

Changed files

  • lib/crewai/src/crewai/flow/visualization/renderers/interactive.py (modified, +15/-10)
RAW_BUFFERClick to expand / collapse

Description

When running the crewai flow plot command (or calling .plot() programmatically without catching the return path), the framework generates the HTML visualization inside a hidden system temporary directory (e.g., /var/folders/.../T/crewai_flow_.../), instead of the user's current working directory.

Furthermore, the CLI outputs a misleading success message: Flow visualization saved to guide_creator_flow.html, leading the user to believe the file was saved locally in their project folder when it was not.

Steps to Reproduce

  1. Create a basic CrewAI Flow.
  2. Run crewai flow plot in the terminal.
  3. Observe the output: Flow visualization saved to guide_creator_flow.html.
  4. Run ls in the current directory. The .html file is nowhere to be found.

Expected behavior

The .plot() method and the crewai flow plot CLI command should either:

Save the HTML file directly into the current working directory. Print the actual absolute path to the temporary directory where it was saved so the user can locate it.

Screenshots/Code snippets

  1. Run the command $ crewai flow plot Plotting the Flow Flow visualization saved to guide_creator_flow.html

  2. Check the directory immediately after $ ls -l guide_creator_flow.html ls: guide_creator_flow.html: No such file or directory

  3. Prove where it actually went using a Python script $ python -c "from src.guide_creator_flow.main import GuideCreatorFlow; print('Actual path:', GuideCreatorFlow().plot('guide_creator_flow.html'))" Actual path: /var/folders/ct/dgmxjsz54hx42xb88jzb5h1m0000gn/T/crewai_flow_1dw9hg68/guide_creator_flow.html

Operating System

macOS Sonoma

Python Version

3.11

crewAI Version

crewai, version 1.11.0

crewAI Tools Version

crewai-tools 1.11.0

Virtual Environment

Venv

Evidence

  1. Running the CLI command tells the user it saved in the current directory:
$ crewai flow plot
Plotting the Flow
Flow visualization saved to guide_creator_flow.html

2. However, checking the directory immediately after shows the file is missing:

bash
$ ls -l guide_creator_flow.html
ls: guide_creator_flow.html: No such file or directory

### Possible Solution

There are a couple of ways the maintainers could address this:

1. Fix the Save Location (Preferred): Update the plot() method in crewai/flow/flow.py. After generating the Pyvis HTML in the system's temporary directory, the framework should forcefully copy that .html artifact into the user's current working directory (os.getcwd()) so it's accessible.

2. Fix the CLI Output: If the file must remain in the temporary directory because of dependencies/assets, then update the CLI print statement in crewai.cli.flow to stop lying to the user. Instead of printing "Flow visualization saved to [filename]", it should print the actual absolute path returned by the method: "Flow visualization saved to /var/folders/.../T/crewai_flow/.../filename.html".

### Additional context

1. Operating System: macOS (applicable strictly given the /var/folders/ path, though likely affects Linux/Windows temp dirs as well).
2. Context: This completely breaks CI/CD pipelines or headless servers trying to generate the HTML diagram as an artifact, because users are currently forced to write their own wrapper script using shutil to extract the file from the hidden temp directory to the workspace.

extent analysis

Fix Plan

To address the issue, we will implement the preferred solution: updating the plot() method to copy the generated HTML file to the user's current working directory.

Step-by-Step Solution

  1. Locate the plot() method: Find the plot() method in crewai/flow/flow.py.
  2. Import necessary modules: Add the following imports at the top of the file:

import os import shutil

3. **Modify the `plot()` method**: Update the `plot()` method to copy the generated HTML file to the user's current working directory:
   ```python
def plot(self, filename):
    # ... (existing code to generate the HTML file in a temporary directory)
    temp_dir = '/var/folders/.../T/crewai_flow_.../'  # replace with actual temp dir path
    temp_filename = os.path.join(temp_dir, filename)
    # ... (existing code to generate the HTML file)

    # Copy the HTML file to the user's current working directory
    current_dir = os.getcwd()
    dest_filename = os.path.join(current_dir, filename)
    shutil.copy2(temp_filename, dest_filename)

    # Update the CLI print statement to reflect the actual save location
    print(f"Flow visualization saved to {dest_filename}")
    return dest_filename
  1. Update the CLI print statement: Modify the CLI print statement in crewai.cli.flow to print the actual absolute path of the saved file:

print(f"Flow visualization saved to {filename}")

   should be replaced with:
   ```python
print(f"Flow visualization saved to {os.path.abspath(filename)}")

Verification

To verify the fix, run the crewai flow plot command and check that the generated HTML file is saved in the user's current working directory. The CLI output should display the correct path to the saved file.

Extra Tips

  • Make sure to test the fix on different operating systems to ensure compatibility.
  • Consider adding error handling to the plot() method to handle cases where the file cannot be copied to the user's current working directory.
  • If the temporary directory is not accessible, consider using a different approach to generate the HTML file, such as using a temporary file in the user's current working directory.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The .plot() method and the crewai flow plot CLI command should either:

Save the HTML file directly into the current working directory. Print the actual absolute path to the temporary directory where it was saved so the user can locate it.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

crewai - ✅(Solved) Fix [BUG] crewai flow plot saves HTML to a hidden temp directory instead of the current working directory (despite CLI message) [3 pull requests, 2 comments, 3 participants]