Skip to content
Download for Mac

Combine Files

Type @combine-files in the composer to make the file merger tool available. The agent reads multiple files from disk, concatenates their contents, and writes the result to a single output file. This is a pipeline utility — the combined content goes to a file on disk, not directly into the conversation context.

Combine Files tool view

The agent provides an ordered list of file paths. QARK reads each file, joins them with a separator (default: two newlines), and writes the result to either a specified output path or a temporary file. The tool returns metadata about the operation:

  • Output file path — where the combined file was written
  • Files combined — how many files were successfully read
  • Word count — total words in the combined output
  • Errors — any files that couldn’t be read (missing, permissions, etc.)
ParameterRequiredDescription
pathsYesArray of file paths to combine, in order
output_pathNoWhere to write the result. If omitted, QARK creates a temp file
separatorNoText inserted between files. Defaults to two newlines
expected_countNoValidation — if the number of successfully read files doesn’t match, the tool returns an error

If expected_count is set and the actual number of successfully read files doesn’t match, the tool fails with an error listing which files couldn’t be read. This is useful in agent pipelines where missing files should halt the workflow rather than produce incomplete output.

This tool is primarily used by agent-tools (sub-agents) in multi-step workflows rather than directly by users. Common patterns:

A research orchestrator dispatches multiple sub-agents that each write findings to separate files. The orchestrator then combines them into a single document for final synthesis.

When an agent-as-tool pipeline produces intermediate files (analysis results, extracted sections, transformed data), combine_files merges them into a single file that the next stage can process.

Combine multiple markdown sections into a single file before passing it to @save-paper-pdf for PDF generation.