Generating files

A workflow can produce text, such as a summary or CSV, or a file object, such as an image or audio clip. Save the result to workspace Files when it needs a stable workspace identity for later runs, editing, or sharing.

A file returned by a block can belong only to the execution. Returning it and saving it to Files are separate actions.

Save text with Write

To save an Agent's summary as Markdown:

  1. Connect the Agent to a File block.
  2. Select Write.
  3. Set File Name to research_summary.md.
  4. Set Content to <agent.content> and leave File empty.
  5. Choose a destination folder if needed, then run the workflow.

The saved file appears in workspace Files. Write returns:

FieldMeaning
idCanonical workspace file ID
nameSaved name, including any suffix added to avoid a duplicate
sizeStored file size in bytes
urlFile access URL; it does not grant public access
versionContent version recorded by the write
revisionOpaque token identifying the written content

The content type is inferred from the extension: .md becomes text/markdown, and .csv becomes text/csv. Content Type in advanced mode overrides it. Setting application/pdf on a text string does not render a PDF; use an actual PDF file for that format.

A Function can build text deterministically, such as CSV or JSON. Use <function.result> as Content when the returned value is the text you want to store. See Using files in workflows for the full read → summarize → save example.

Save an existing file

If a block already returns a file object, pass it to Write's File input and leave Content empty. Set File Name and the destination folder. Provide exactly one source: text in Content, or an existing object in File.

For example, ElevenLabs text-to-speech returns <elevenlabs.audioFile>. An image generator returns an image file, and a remote Function can return <function.files[0]>. These objects can go directly to compatible attachment or upload inputs. Write's File input copies their bytes into workspace Files so later runs can reuse them.

At the tool level, file_write accepts fileInput and can inherit the source name when fileName is omitted. The current block editor still requires File Name.

Create, overwrite, or append

By default, Write keeps an existing file with the same name in the destination folder and adds a numeric suffix to the new file: data.csv, data (1).csv, then data (2).csv.

Turn on Overwrite Existing File to replace the file at the exact destination name and folder. If that path does not exist, Write creates it. Use Append to add text to the end of an existing file instead. Select the file directly, or use its name with a folder scope to avoid targeting an ambiguous name.

For file tools or API operations that accept expectedRevision, use it to guard a content change based on an earlier read. A version number can stay the same across coalesced collaborative or workflow writes, so it is not an exact content precondition. For Write, expectedRevision requires overwrite: true. See the file content API and version history API.

Generate files with Function

A remote Function can write files under /tmp/sim/outputs. Sim returns those files as the block's files output, ready for a compatible downstream input:

with open('/tmp/sim/outputs/summary.csv', 'w') as handle:
    handle.write('category,count\ncompleted,12\nfailed,2\n')

Pass <function.files[0]> to File Write to keep this execution artifact in workspace Files. Automatic exports allow up to 20 files and 50 MiB total; exceeding a cap fails the export rather than returning a partial set.

The Chat workbench uses a per-call SIM_OUTPUT_DIR; outputs written there are exported to workspace Files. Use the environment-provided directory in that context. The separate Function tool also supports explicit outputPath and outputSandboxPath persistence. These are tool capabilities, not fields in the current Function block editor.

Reuse and return a file

Saved files belong to the workspace. Authorized later runs can select them in a file picker or read them by canonical ID with Read; use Get Content when the next step needs extracted text. Renaming or moving a file does not require another workflow to generate it again.

A Response block can return a file object or a saved file ID to an API caller. The response does not create public access. API-key callers download saved workspace files through the Files API, or run-produced files through the run-file endpoint. Optional base64 output can include eligible bytes within its limits. See Passing files.

Related docs