Repository navigation
fix(artifacts): never cache save_artifact tool results - #9595
Conversation
Strix Security ReviewWarning This pull request has 3 commits after the last Strix review ( ✅ No open security findings. PR summary: Disables tool-result caching for `SaveArtifactTool` so a second `save_artifact` call with the same arguments saves a new artifact version instead of returning the previous cached URL, with a regression test covering two identical calls on a rewritten file. Review summaryReviewed the full change: The field is not new surface — No security-relevant findings in the changed code; the change is a net reduction in exposure. Review 1 on this PR · Reviewed by Strix |
Gabe Milani (gabemilani)
left a comment
There was a problem hiding this comment.
Good catch, thank you!
With Crew(cache=True), a second save_artifact call with the same arguments was served from the tool cache, so no new version was saved and a file rewritten at the same path was silently dropped.
4bf11a6 to
ab40a89
Compare
Thanks for your first contribution to CrewAI, Aditya Gupta (@MaiAditya)!We really appreciate the time and care you put into this PR. Your work is now part of CrewAI — welcome to the contributor community. Want to share your contribution? Totally optional: Share on X · Share the PR on LinkedIn If the links don't work, feel free to copy and personalize this: If you share, we'd love to see it — tag crewAI (@crewAIInc) on X and CrewAI on LinkedIn. |
Related issue
Fixes #9594
Summary
SaveArtifactToolkept the defaultcache_function, so withCrew(cache=True)a secondsave_artifactcall with the same arguments was served from the tool cache: no new version was saved and the agent got the old URL back. For a file the agent rewrites at the same path (a redrawn chart), the revision was silently lost.The tool now uses
_never_cache_function, the same opt-out the spreadsheet tools use. Each call saves a new version, as the artifacts docs describe.Verification
Tests added or updated for the changed behavior
Relevant tests and quality checks pass locally
New
test_tool_saves_a_rewritten_file_again_when_tool_caching_is_onruns two identicalsave_artifactcalls throughexecute_single_native_tool_callwith a cache on, rewriting the file in between. It fails on main ([1, 1] != [1, 2]) and passes with the fix.uv run pytest lib/crewai/tests/test_artifacts.py lib/crewai/tests/test_tool_cache_default.py lib/crewai/tests/tools/test_deserialization_guard.py lib/crewai/tests/test_checkpoint.py lib/crewai/tests/tools/test_tool_usage.pyuv run ruff check/ruff format --check/mypyon the changed files.Additional context
None.