Skip to content

File Writer

Overview

The File Writer node writes data to a file in the configured storage backend (local gateway filesystem or cloud storage). Use it to persist battle outputs, model responses, or intermediate workflow data as files for downstream consumption or export. The node emits an error port on write failure, allowing workflows to handle storage errors without halting. A valid storage destination (path and bucket/directory) must be configured before the node can execute.

Configuration

FieldTypeRequiredDescription
destination_pathstringYesTarget file path relative to the storage root (e.g. results/battle-123/output.json). Supports template variables such as {{run_id}} and {{timestamp}}.
storage_bucketstringYesName of the storage bucket or root directory to write into. Must exist and be writable by the workflow's service credentials.
write_modeenumNoControls behavior when the target file already exists. One of overwrite (default), append, or error_if_exists.
content_typeenumNoMIME type hint for the stored file. One of text/plain, application/json, text/csv, or application/octet-stream. Defaults to application/json when the input data is an object.
create_dirsbooleanNoWhen true, automatically creates any missing parent directories in destination_path. Defaults to false.

Inputs

PortTypeDescription
dataanyThe content to write to the file. Accepts strings, objects (serialized to JSON), or binary buffers. If an object is received, it is serialized with JSON.stringify before writing.

Outputs

PortTypeDescription
outputobjectEmitted on success. Contains { path: string, bytes_written: number, storage_bucket: string } describing the written file.
errorobjectEmitted when the write fails (e.g. permission denied, bucket not found, disk full). Contains { message: string, code: string, destination_path: string }.

Example

json
{
  "nodeType": "file_writer",
  "config": {
    "destination_path": "battles/{{run_id}}/judge-output.json",
    "storage_bucket": "battle-artifacts",
    "write_mode": "overwrite",
    "create_dirs": true
  }
}