Configuration
Path to the file to read. Can be absolute or relative to the working directory (
config/extended_openai_conversation/).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
Read File
Custom Allowed Directories
Extend allowed directories beyond the default workspace. Theallow_dir parameter adds additional directories where files can be read.
allow_dir accepts templates, so you can use variables like {{ config_dir }}:Return Value
On success:Error Types
- File not found: The specified file doesn’t exist
- Not a file: The path points to a directory
- File too large: File exceeds 1 MB size limit
- Access denied: File is outside allowed directories
- Permission error: Insufficient permissions to read file
File Size Limit
Files larger than 1 MB (1,048,576 bytes) are blocked to prevent memory issues: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 against allowed directories. Attempts to use
../ to escape allowed directories will be blocked:Size Limits
Size Limits
Files over 1 MB are automatically rejected to prevent memory exhaustion.
UTF-8 Encoding
UTF-8 Encoding
Files are read with UTF-8 encoding. Binary files may not be read correctly.
Use Cases
Configuration Review
Read and analyze Home Assistant configuration files
Log Analysis
Read log files to diagnose issues
Data Files
Access JSON, YAML, CSV, or text data files
Script Review
Read automation scripts and templates
Common Patterns
Read YAML Configuration
Read and Parse JSON
Search File Content
Examples
Read Multiple Files
To read multiple files, use a composite function that loops through each file, or create separate function calls for each file.
Read with Error Handling
Best Practices
Be mindful of file size
Large files (>1MB) are blocked. For large files, use bash functions to read portions:
Troubleshooting
Access denied: path not in allowed directories
Access denied: path not in allowed directories
The file is outside allowed directories. Either:
- Move the file to the workspace (
/config/extended_openai_conversation/) - Add the file’s directory to
allow_dir - Use an absolute path to
/config/if appropriate
File too large
File too large
The file exceeds 1 MB. Options:
- Use bash functions to read portions (
head,tail,grep) - Split the file into smaller chunks
- Process the file externally and save results to a smaller file
File not found
File not found
Check:
- File path is correct (relative to working directory)
- File exists at the specified location
- Path separators are correct (use
/on all platforms)
Encoding errors
Encoding errors
Files must be UTF-8 encoded. For binary files or other encodings, consider using bash functions:
FAQ
Can I read binary files?
Can I read binary files?
No. Read File functions use UTF-8 text encoding. For binary files, use bash functions:
What's the maximum file size?
What's the maximum file size?
1 MB (1,048,576 bytes). This limit prevents memory issues when processing large files.
Can I read files outside /config?
Can I read files outside /config?
Yes, by adding directories to
allow_dir. However, the default workspace and /config are always available.Are symbolic links followed?
Are symbolic links followed?
Yes. Paths are resolved to their real locations, then validated against allowed directories.