Configuration
template
required
Path to the file to write. Can be absolute or relative to the working directory (
config/extended_openai_conversation/).template
required
Content to write to the file. Can include Jinja2 templates for dynamic content generation.
array
Optional list of additional allowed directories (as templates). By default, only the working directory is allowed.
Working Directory
The default working directory isconfig/extended_openai_conversation/.
- Relative Path
- Subdirectory
- Absolute Path
Examples
Write File
Custom Allowed Directories
Extend allowed directories beyond the default workspace. Theallow_dir parameter adds additional directories where files can be written.
allow_dir accepts templates with access to variables like {{ config_dir }}:Return Value
On success:Error Types
- Access denied: File path is outside allowed directories
- Permission error: Insufficient permissions to write file
- No such file or directory: Parent directory doesn’t exist
- Other errors: Encoding issues, disk full, etc.
Dynamic Content Generation
Write File functions support Jinja2 templates in thecontent field:
Generate YAML Configuration
Generate JSON Data
Generate Python Script
Use Cases
Note Taking
Save user notes, reminders, and documentation
Configuration Generation
Generate automation configs, scripts, templates
Data Export
Export sensor data, logs, or analysis results
Report Generation
Create markdown, CSV, or text reports
Common Patterns
Append Timestamp to Filename
Write Multiple Lines
Write CSV Data
Conditional Content
Security
Path Restriction
Path Restriction
Files must be within allowed directories. By default:
/config/extended_openai_conversation/(working directory)
allow_dir.Path Traversal Protection
Path Traversal Protection
Paths are resolved to absolute paths and validated. Attempts to use
../ to escape allowed directories will be blocked.File Overwrite
File Overwrite
Write File overwrites existing files without confirmation. Use Edit File for safer modifications.
Directory Creation
Directory Creation
Parent directories are not automatically created. The parent directory must exist before writing a file. Use bash functions if you need to create directories:
Best Practices
1
Validate before overwriting
Check if file exists before overwriting (use composite function):
2
Use descriptive filenames
Include timestamps or identifiers in filenames:
3
Handle encoding properly
Always use UTF-8 text. For special characters, ensure proper escaping:
4
Organize files in subdirectories
Use subdirectories to organize files (ensure they exist first):
Troubleshooting
Access denied: path not in allowed directories
Access denied: path not in allowed directories
The target path is outside allowed directories. Either:
- Write to the workspace (
/config/extended_openai_conversation/) - Add the target directory to
allow_dir
No such file or directory
No such file or directory
The parent directory doesn’t exist. Create it first:
Permission denied
Permission denied
Check:
- File permissions on the parent directory
- Available disk space
- SELinux or AppArmor policies (in container environments)
FAQ
What happens to existing files?
What happens to existing files?
Existing files are overwritten without warning. There is no backup or confirmation. Use Edit File for safer modifications to existing files.
Are parent directories created automatically?
Are parent directories created automatically?
No. Parent directories must exist before writing a file. Use bash functions to create directories if needed.
What's the maximum file size I can write?
What's the maximum file size I can write?
There’s no explicit limit, but very large content (>10MB) may cause memory issues. For large files, consider using bash functions with streaming:
Can I append to existing files?
Can I append to existing files?
No. Write File always overwrites. To append, use bash functions:
Next Steps
Read File
Read file contents
Edit File
Safely modify existing files
Bash Functions
Advanced file operations