-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Open
Description
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)]
pub struct Fixed(i32);
impl Fixed {
const FRACTIONAL_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 characters
EOFEnvironment
- 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels