You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Write tool JSON parsing error with large files and special characters #11630
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 string
Invalid input for tool write: JSON parsing failed
JSON 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
Activity
github-actions commentedon Feb 1, 2026
This issue might be a duplicate of existing issues. Please check:
Error message: JSON Parse error: Unterminated stringerrors #10755: JSON Parse error: Unterminated string errors with Write toolFeel free to ignore if none of these address your specific case.
fix: properly encode file URLs with special characters (anomalyco#11790)
fix: properly encode file URLs with special characters (anomalyco#11790)
github-actions commentedon Apr 3, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.