Configuration
config/extended_openai_conversation/).Working Directory
The default working directory isconfig/extended_openai_conversation/.
- Relative Path
- Subdirectory
- Absolute Path
Examples
Edit File
Custom Allowed Directories
Extend allowed directories beyond the default workspace. Theallow_dir parameter adds additional directories where files can be edited.
How It Works
Edit File is safer than Write File because it:- Reads the current file to verify it exists
- Searches for exact match of
old_text - Validates single occurrence - fails if text appears 0 or 2+ times
- Performs replacement - replaces only the one matched occurrence
- Writes back to the same file
File is read
Text is searched
old_textOccurrence check
- If found 0 times → Error: “Text not found in file”
- If found 1 time → Proceed with replacement
- If found 2+ times → Error: “Text appears N times in file”
Replacement performed
new_textFile is written
Return Value
On success:Safety Features
Exact Match Required
Exact Match Required
old_text must match exactly, including:- Whitespace (spaces, tabs, newlines)
- Case sensitivity
- Special characters
Single Occurrence Validation
Single Occurrence Validation
old_text more specific by including surrounding context.File Must Exist
File Must Exist
Atomic Operation
Atomic Operation
Common Patterns
Update YAML Configuration Value
Update Python Variable
Comment Out a Line
Update Automation Trigger
Use Cases
Configuration Updates
Version Updates
Entity ID Changes
Text Corrections
Advanced Examples
Multi-line Replacement
Edit File supports multi-line text:Replace with Empty String (Delete)
\n) in old_text so the empty line is also removed.Conditional Edit with Validation
Best Practices
Include context for uniqueness
Preserve exact formatting
Read file first to verify content
Handle errors gracefully
Troubleshooting
Text not found in file
Text not found in file
old_text doesn’t exist in the file. Common causes:- Typo in
old_text - Whitespace mismatch (spaces vs tabs)
- Case sensitivity
- File has already been edited
Text appears N times in file
Text appears N times in file
old_text appears multiple times. This is blocked to prevent unintended changes.Solution: Make old_text more specific by including surrounding context:File not found
File not found
Access denied
Access denied
allow_dir or move the file to the workspace.Comparison: Edit vs Write
When to use Edit File
When to use Edit File
- Modifying existing files
- You want to change specific values
- You need safety against accidental overwrites
- The file has other content you want to preserve
When to use Write File
When to use Write File
- Creating new files from scratch
- Generating complete file contents
- You want to overwrite the entire file
- The file is a generated output (logs, reports, exports)
FAQ
Can I replace multiple occurrences at once?
Can I replace multiple occurrences at once?
- Make
old_textmore specific so it matches only once - Use bash functions with
sed:
What if I need to edit the same value multiple times?
What if I need to edit the same value multiple times?
old_text specific to one occurrence by including surrounding context.Can I use regular expressions?
Can I use regular expressions?
sed.Does it create backups?
Does it create backups?
Security
Path Restriction
Path Restriction
/config/extended_openai_conversation/(working directory)
allow_dir.Exact Match Only
Exact Match Only
Single Occurrence
Single Occurrence
File Must Exist
File Must Exist