OutputConfig, or let the agent call write_file.
Quick Start
1
Simple Usage
Pass a file path string to
output:2
With Configuration
Use
OutputConfig for template formatting:How It Works
The user sends a request; the agent generates a response and the framework writes it to the configured output file.Methods Comparison
Method 1: String Path (Simplest)
One line - just pass a file path string to
output.Basic Usage
With Directory
Method 2: OutputConfig (With Template)
Use
OutputConfig when you need to save output AND apply template formatting.Recommended: For response templates without file saving, use
TemplateConfig.response instead. See Templates for details.With Template
Combined with Other Settings
Method 3: write_file Tool
Recommended when the agent needs to decide what to save and where.
Basic Usage
With Multiple File Tools
Method 4: Task output_file
Recommended for task-based workflows where you want automatic file saving.
Basic Usage
Multiple Tasks with Different Outputs
Method 5: Workflow output_file
Recommended for YAML-based workflows with variable substitution.
agents.yaml Example
Run the Workflow
Method 6: Manual Capture
Use when you need full control over the saving process.
Basic Manual Save
With Error Handling
Best Practices
Choose the Right Method
Choose the Right Method
Use create_directory
Use create_directory
Always set
create_directory=True when using Task.output_file to avoid errors:Use Variables in Workflows
Use Variables in Workflows
Use variables for flexible output paths:
Handle Large Outputs
Handle Large Outputs
For large outputs, consider streaming to file:
Complete Example
1
Install
2
Create Agent with File Tools
3
Run and Save
Related
File Tools
Complete file operations reference
Workflows
YAML workflow configuration

