Repository navigation
feat: save files as versioned, shareable artifacts - #9551
Gabe Milani (gabemilani) wants to merge 4 commits into
Conversation
Crews, agents and flows can now save reports, charts, PDFs and other files as artifacts. Set Task(artifact=...) to save a task's output, artifacts=True to give agents a save_artifact tool, or call save_artifact() from a flow step. Saving the same identifier again creates a new version. Files go to ./artifacts/ locally
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Strix Security ReviewWarning This pull request has 3 commits after the last Strix review ( To fix before merging (1)
PR summary: This PR adds artifacts to CrewAI: named, versioned files a task, agent, flow, or the new `save_artifact` tool saves (from text, bytes, or a file the agent wrote) into a swappable store, defaulting to `./artifacts/<run>/<identifier>/v<N>.<ext>`, with the saved version exposed on `TaskOutput`/`LiteAgentOutput` and announced through a new `ArtifactCreatedEvent` that reaches traces and an OpenTelemetry span. It also reorders `output_file` writing ahead of task callbacks and refactors the file-path validation into shared helpers. Review summaryThe artifact feature's file handling holds up well: the Ruled out (6)
Fixed the findings? re-run the review, or tag Review 1 on this PR · Reviewed by Strix |
| class ArtifactCreatedEvent(BaseEvent): | ||
| """Emitted when a run saves a new artifact version.""" | ||
|
|
||
| type: Literal["artifact_created"] = "artifact_created" |
There was a problem hiding this comment.
The type here is a bit redundant, isnt?
How about have one event for each type? that way we could easily identify them in the traces, no need to expand the event to get its type
A run can now read back an artifact it saved, so a flow that pauses for
human feedback can revise its report after resuming on another worker.
Call load_artifact() for the latest or a given version, or list
{artifact: <identifier>} under input_files on a declarative agent step.
Custom stores add an optional load(). Docs cover it in all four languages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
A run can only return plain text today. Reports, charts and files a crew makes never reach the people who use the automation. This adds artifacts: named, versioned files a run saves for people to preview, download and share.
Ways to save one:
Task(artifact=Artifact(identifier="q3-report", title="Q3 report", kind="html"))saves the task's output with no tool call, so the model can't forget.agent.kickoff(..., artifact=...)does the same for single agents, andartifact:undercall: agentdoes it in declarative flows.artifact=Truefills in the details: the name comes from the task, the flow method or the agent role, and the kind is detected from the output.Artifact(..., file_path="output/{quarter}.png")saves a file the agent's tools write (charts, PDFs) instead of the text.{placeholders}and${...}get the same path checks asoutput_file.Crew(artifacts=True)/Agent(artifacts=True)give agents asave_artifacttool that returns the link. It works in crews, in standalone task runs and inkickoff.save_artifact(...)from code, such as a flow step, with text or bytes. Image bytes are detected as PNG, JPEG, GIF or WebP.Saving the same identifier again in a run creates the next version. The saved version is on
TaskOutput.artifactandLiteAgentOutput.artifact, so callbacks and later steps can send the link on. Each save gets a UUIDidbefore upload, so a retrying store can be deduped. Every save emitsArtifactCreatedEventwith the agent and task that saved it. It reaches AMP traces and becomes asave artifactOpenTelemetry span.Locally, files go to
./artifacts/<run id>/<identifier>/v<N>.<ext>. Each version is claimed with an exclusive create, so concurrent saves never overwrite each other. The store is swappable (set_artifact_store), so it's possible to upload to different places. On async paths the save runs off the event loop. A2A agents keep working: when an agent delegates, the artifact is saved once on the final result.A failed save never fails the run; it is logged as a warning. File paths must stay inside the working directory or the temp dir, and image, pdf and file kinds can't be filled from text.
Also: a docs page
concepts/artifacts(en, pt-BR, ko, ar), a commented example in the JSON crew task template, and a line in the scaffoldedAGENTS.md.Verification
Additional context
output_filebefore its callbacks run (it used to be after), so an artifact can point at that file and callbacks see the saved artifact.TaskOutputandLiteAgentOutputnow serialize anartifactkey (null when unused).