Bug Description
The Write tool consistently fails with JSON parsing errors when writing files that contain:
- Large content (>~1000 characters)
- Special characters (quotes, newlines, backticks)
- Code blocks with nested structures
Error Messages
Common errors encountered:
JSON Parse error: Unterminated stringInvalid input for tool write: JSON parsing failedJSON Parse error: Expected ']'
Reproduction Steps
- Try to write a Rust file with ~200+ lines using the Write tool
- Content includes code with quotes, backticks, or special characters
- Error occurs consistently
Example that fails:
/// Fixed-point arithmetic module (16.16 format)#[derive(Debug,Clone,Copy,PartialEq,Eq)]pubstructFixed(i32);implFixed{constFRACTIONAL_BITS:i32 = 16;// ... more code with quotes and special chars}Workaround
Using bash with heredoc works reliably:
cat > /path/to/file.rs << 'EOF'// Large file content here// With any special charactersEOF
Environment
- Platform: macOS (darwin)
- Model: kimi-k2.5-free
- Working with: Rust code files, Markdown documentation
Impact
- Must use bash workarounds for any substantial file writes
- Breaks flow when editing multiple files
- Limits ability to use Write tool effectively
Suggested Fix
Either:
- Increase JSON string size limits
- Better escaping for special characters
- Alternative write method for large files
- Document the limitation and recommend bash for large files
Bug Description
The Write tool consistently fails with JSON parsing errors when writing files that contain:
Error Messages
Common errors encountered:
JSON Parse error: Unterminated stringInvalid input for tool write: JSON parsing failedJSON Parse error: Expected ']'Reproduction Steps
Example that fails:
Workaround
Using bash with heredoc works reliably:
Environment
Impact
Suggested Fix
Either: