What is Mark File for Export?
Mark File for Export is a specialized tool that immediately exports files from the remote machine as run attachments. When the agent calls this tool, the file is read and saved right away, providing instant feedback on whether the export succeeded or failed.
In your prompts, always refer to this tool as mark_file_for_export (lowercase, with underscores).
Many workflows generate or manipulate files that need to be retrieved:
- Downloaded reports
- Generated documents
- Processed data files
- Exported configurations
- Created screenshots or images
The mark_file_for_export tool ensures these files are immediately exported as Run attachments with clear success/failure feedback, allowing agents to retry or investigate if a file doesn’t exist.
How It Works
- During workflow execution, the agent identifies files to export
- The agent calls
mark_file_for_export with the file path
- The file is immediately read from the machine and saved as a run attachment
- The agent receives instant feedback:
- Success: File exported with attachment ID
- Failure: Error message explaining why the file couldn’t be read (e.g., file not found)
- If the file doesn’t exist, the agent can retry or investigate the issue
- File attachment IDs are available in the Run’s
output_attachment_ids array
Since files are exported immediately, you can safely delete the file from the machine after calling mark_file_for_export if needed (e.g., using execute_terminal_command).
Cached execution behavior: During cached runs, if a file doesn’t exist when mark_file_for_export is called, the run will fail immediately with a clear error message. This is because retrying isn’t useful in cached mode - the trajectory assumed the file would exist.
When to Use Mark File for Export
1. Report Downloads
"Navigate to the reports section, generate the monthly sales report for {month},
download it as PDF, then use mark_file_for_export to export the file from
D:\Downloads\sales_report_{month}.pdf"
"Export the customer database to CSV format. Save it to C:\Exports\customers.csv,
then use mark_file_for_export to mark this file for extraction."
3. Generated Documents
"Fill out the insurance claim form with the provided data, save it as
D:\Documents\claim_{claim_number}.pdf, then use mark_file_for_export
to ensure we retrieve the completed form."
4. Batch Processing
"Process all invoices in the queue. For each processed invoice, save it to
D:\Processed\{invoice_id}.pdf and use mark_file_for_export to mark it
for extraction."
How to Prompt for File Export
Best Practices
- Specify Exact Paths: Be as specific as possible about file locations
- Include File Extensions: Always specify the expected file type
- Use Input Variables: Leverage variables for dynamic file names
- Confirm File Creation: Ensure the file exists before marking for export
Prompt Template
"[Describe action that creates/downloads file], save it to [specific file path],
then use mark_file_for_export to mark this file for export."
Real-World Examples
Healthcare: Patient Records
"Search for patient {patient_id} and navigate to their medical records.
Download the complete patient history as PDF to
D:\PatientRecords\{patient_id}_history.pdf.
Use mark_file_for_export to mark this file for extraction."
Finance: Statement Downloads
"Log into the banking portal and navigate to statements. Download statements
for account {account_number} from {start_date} to {end_date}. Save each as
D:\Statements\{account_number}_{month}_{year}.pdf and use mark_file_for_export
for each downloaded statement."
HR: Employee Onboarding
"Generate the new employee welcome packet for {employee_name}. Include the
offer letter, benefits summary, and tax forms. Save the complete packet as
D:\HR\Onboarding\{employee_id}_welcome_packet.pdf and use mark_file_for_export
to mark it for extraction."
Legal: Document Compilation
"Compile all documents for case {case_number}. Merge them into a single PDF at
D:\LegalDocs\{case_number}_complete.pdf. After successful merge, use
mark_file_for_export to mark the compiled document for extraction."
Working with Dynamic File Paths
"Download the {report_type} report for {department} and save it as
D:\Reports\{department}_{report_type}_{timestamp}.xlsx.
Use mark_file_for_export to mark this file for extraction."
Pattern-Based Exports
"After processing all orders, use mark_file_for_export to mark each generated
invoice following the pattern D:\Invoices\{order_date}\INV_{order_id}.pdf"
Using Runtime Variables
"Use focused_action to find the dynamically generated report file (it will have
a timestamp in the name). Save the full path as {{generated_report_path}}.
Then use mark_file_for_export to export {{generated_report_path}}."
Sensitive Variables
If your prompt includes {$variable}, the value is handled securely and is not exposed to the agent or logs. Avoid including secrets in file paths or filenames. Sensitive values are typically used for actions like login; they should not appear in exported file paths or content.
Conditional Exports
"If the analysis finds anomalies, export the detailed report to
D:\Anomalies\anomaly_report_{run_date}.csv and use mark_file_for_export
to mark it for extraction. If no anomalies, skip the export."
Common Patterns and Tips
"After clicking 'Generate Report', wait for the download to complete,
then use mark_file_for_export on D:\Downloads\report.pdf. If the export
fails, verify the file was downloaded correctly and retry."
Multiple File Exports
"For each patient in the list {patient_ids}, download their:
1. Medical history to D:\Exports\{patient_id}_history.pdf
2. Recent labs to D:\Exports\{patient_id}_labs.pdf
3. Medications list to D:\Exports\{patient_id}_meds.pdf
Use mark_file_for_export for each file after it's downloaded."
Handling Download Locations
"The system will download the file to the default downloads folder.
After download completes, use mark_file_for_export to mark
C:\Users\{username}\Downloads\{expected_filename}.pdf for extraction."
Error Prevention
Common mistakes to avoid:
- Exporting files before they’re created (you’ll get an immediate error if the file doesn’t exist)
- Using incorrect file paths
- Forgetting file extensions
- Not accounting for dynamic file names
❌ Incorrect Usage
"Use mark_file_for_export on the report" // No file path specified
"Mark D:\Reports\* for export" // Wildcards not supported
"Export the file from somewhere in Documents" // Vague path
✅ Correct Usage
"Use mark_file_for_export to export D:\Reports\quarterly_summary.pdf"
"Export each file using mark_file_for_export: D:\Reports\Q1.pdf, D:\Reports\Q2.pdf"
"Use mark_file_for_export on C:\Users\admin\Documents\output_{date}.xlsx"
Handling Export Errors
Since mark_file_for_export provides immediate feedback, your prompts can instruct the agent how to handle failures:
"After the download completes, use mark_file_for_export on D:\Downloads\report.pdf.
If the export fails because the file doesn't exist, check the Downloads folder for
the actual filename (it may include a timestamp) and retry with the correct path."
With Focused Action
"Use focused_action to identify which reports are marked as 'Ready'.
For each ready report, download it and use mark_file_for_export to
export D:\Downloads\{report_name}.pdf."
With Terminal Commands
"Use execute_terminal_command to run 'dir C:\ProcessedFiles\ /B > C:\file_list.txt'
to create a list of processed files. Then use mark_file_for_export to export
C:\file_list.txt."
Cleanup After Export
Since files are exported immediately, you can clean up the machine right after:
"Use mark_file_for_export to export D:\Temp\processed_data.csv. Once exported
successfully, use execute_terminal_command to delete the file:
'Remove-Item D:\Temp\processed_data.csv'"
With Screenshots
"Generate the analytics dashboard for {client_name}. Export the data as
D:\Analytics\{client_name}_data.csv and use mark_file_for_export on it.
Also use save_screenshot_as_run_attachment to capture the visual dashboard."
Advanced Usage
Batch Operations
"Process all PDFs in the input folder. For each:
1. Apply OCR and save to D:\OCR_Output\{filename}_ocr.pdf
2. Extract text and save to D:\OCR_Output\{filename}.txt
3. Use mark_file_for_export on both the PDF and TXT files
4. Move the original to D:\Processed\
Computed File Names
"The system generates files with timestamps. After generation, look in
D:\Output\ for the most recent file matching pattern 'report_*.pdf'
and use mark_file_for_export on that specific file."
Workflow Output Integration
"Your workflow should output a JSON with 'exported_files' array containing
the paths of all files marked for export. Each time you use mark_file_for_export
on a file, add its path to this array in your output."