Skip to content

docs(file-writer): fix accuracy of FileWriterTool page#6374

Draft
theCyberTech wants to merge 3 commits into
mainfrom
docs/file-writer-tool-accuracy
Draft

docs(file-writer): fix accuracy of FileWriterTool page#6374
theCyberTech wants to merge 3 commits into
mainfrom
docs/file-writer-tool-accuracy

Conversation

@theCyberTech

@theCyberTech theCyberTech commented Jun 28, 2026

Copy link
Copy Markdown
Member

What

Fixes accuracy issues on the FileWriterTool docs page (docs/edge/en/tools/file-document/filewritetool.mdx) measured against the actual tool source at lib/crewai-tools/src/crewai_tools/tools/file_writer_tool/file_writer_tool.py.

Why

The page made claims that don't match the implementation:

  • "supports UTF-8 encoding" — the code calls open(real_filepath, mode) with no encoding= argument, so the byte encoding follows locale.getpreferredencoding() (UTF-8 on Linux/macOS, typically cp1252 on stock Windows). Replaced with an accurate note + a PYTHONUTF8=1 workaround for Windows.
  • No mention of text-only. The tool writes content (a str) in text mode. Added a warning that it is not suitable for binary files (images, PDFs, archives, executables) — feeding it binary data raises or corrupts the output.
  • overwrite argument missing from docs. The schema has overwrite: str | bool = False and it materially changes behavior: False → exclusive-create mode ("x") + "already exists" error; truthy → write mode ("w"). Documented it.
  • Auto-mkdir is conditional. The MDX implied directories are always created if missing; in reality os.makedirs only runs when directory is explicitly passed (truthy). The default "./" does not trigger creation. Clarified.
  • Broken example. The example called ._run('example.txt', '...', 'test_directory') positionally, but _run is def _run(self, **kwargs) — positional calls would KeyError on kwargs["filename"]. Switched to keyword arguments.

Scope

Only the English Edge source is touched (docs/edge/en/...), per the docs contributor guide. Frozen docs/v*/ snapshots and the shared docs/images/ directory are untouched.

Checklist

  • Edge source only — no docs/v*/ or docs/images/ changes
  • No new images added
  • mintlify broken-links not run locally (CI will verify)

Draft for now — happy to address feedback before flipping to ready.

The Edge MDX for FileWriterTool had several accuracy issues against the
actual tool source (crewai_tools/tools/file_writer_tool/file_writer_tool.py):

- Claimed 'supports UTF-8 encoding' but open() is called without an
  encoding= argument, so behavior follows locale.getpreferredencoding()
  (UTF-8 on Linux/macOS, cp1252 on stock Windows). Replaced the claim
  with an accurate note + PYTHONUTF8 guidance.
- Did not state the tool is text-only. Added a warning that binary files
  (images, PDFs, archives, executables) are not supported.
- The overwrite argument (overwrite: str | bool = False) was missing
  entirely from the Arguments list, even though it controls exclusive
  vs write mode and the already-exists error. Documented it.
- The auto-mkdir behavior is conditional on directory being explicitly
  passed; the docs implied unconditional creation. Clarified.
- The example used positional args against _run(self, **kwargs),
  which would KeyError. Switched to keyword arguments.
@mintlify

mintlify Bot commented Jun 28, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
crewai 🟢 Ready View Preview Jun 28, 2026, 4:33 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c05bcd3-b88c-4ae9-9488-c36bb9699e50

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/file-writer-tool-accuracy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

_run is the internal entrypoint; the public API is .run(). Update the
example so readers aren't shown calling a private method.
Tools are meant to be handed to an Agent via tools=[...] and invoked by
the agent during a task. The previous example called the tool's method
directly, which is not how users should use CrewAI tools. Replace with a
full agent+task+crew example mirroring the pattern used by sibling
tool pages (e.g. seleniumscrapingtool).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant